This commit is contained in:
IndieKKY
2024-10-06 18:48:52 +08:00
parent 97bd23bcc0
commit e5a645611b
11 changed files with 23 additions and 52 deletions

View File

@@ -1,7 +1,6 @@
import { setCurFetched, setCurInfo, setData, setInfos, setTitle, setUrl } from '@/redux/envReducer'
import { useMemo } from 'react'
import { useAppDispatch } from './redux'
import { MESSAGE_TO_APP_SET_INFOS, MESSAGE_TO_APP_SET_VIDEO_INFO } from '@/consts/const'
import useMessagingService from '@/messaging/layer2/useMessagingService'
const useMessageService = () => {
@@ -9,15 +8,15 @@ const useMessageService = () => {
//methods
const methods: {
[key: string]: (params: any, context: MethodContext) => Promise<any>
[K in AllAPPMessages['method']]: (params: Extract<AllAPPMessages, { method: K }>['params'], context: MethodContext) => Promise<any>
} = useMemo(() => ({
[MESSAGE_TO_APP_SET_INFOS]: async (params: any, context: MethodContext) => {
SET_INFOS: async (params, context: MethodContext) => {
dispatch(setInfos(params.infos))
dispatch(setCurInfo(undefined))
dispatch(setCurFetched(false))
dispatch(setData(undefined))
},
[MESSAGE_TO_APP_SET_VIDEO_INFO]: async (params: any, context: MethodContext) => {
SET_VIDEO_INFO: async (params, context: MethodContext) => {
dispatch(setInfos(params.infos))
dispatch(setUrl(params.url))
dispatch(setTitle(params.title))

View File

@@ -1,7 +1,6 @@
import {useAppDispatch, useAppSelector} from './redux'
import React, {useCallback} from 'react'
import {setNeedScroll, setReviewAction, setTempData} from '../redux/envReducer'
import {MESSAGE_TO_INJECT_MOVE} from '../consts/const'
import useMessaging from '../messaging/layer2/useMessaging'
const useSubtitle = () => {
const dispatch = useAppDispatch()

View File

@@ -16,10 +16,9 @@ import {
setTempData,
} from '../redux/envReducer'
import {EventBusContext} from '../Router'
import {EVENT_EXPAND, GEMINI_TOKENS, TOTAL_HEIGHT_MAX, TOTAL_HEIGHT_MIN, WORDS_MIN, WORDS_RATE, MESSAGE_TO_INJECT_GET_VIDEO_STATUS, MESSAGE_TO_INJECT_GET_VIDEO_ELEMENT_INFO, MESSAGE_TO_INJECT_REFRESH_VIDEO_INFO, MESSAGE_TO_INJECT_HIDE_TRANS, MESSAGE_TO_INJECT_UPDATETRANSRESULT, TOTAL_HEIGHT_DEF} from '../consts/const'
import {EVENT_EXPAND, GEMINI_TOKENS, TOTAL_HEIGHT_MAX, TOTAL_HEIGHT_MIN, WORDS_MIN, WORDS_RATE} from '../consts/const'
import {useAsyncEffect, useInterval} from 'ahooks'
import {getModelMaxTokens, getWholeText} from '../utils/bizUtil'
import {MESSAGE_TO_INJECT_GET_SUBTITLE} from '../consts/const'
import useMessaging from '../messaging/layer2/useMessaging'
/**

View File

@@ -16,8 +16,6 @@ import {
import {
LANGUAGE_DEFAULT,
LANGUAGES_MAP,
MESSAGE_TO_EXTENSION_ADD_TASK,
MESSAGE_TO_EXTENSION_GET_TASK,
PROMPT_DEFAULTS,
PROMPT_TYPE_ASK,
PROMPT_TYPE_TRANSLATE,