You've already forked bilibili-subtitle
优化
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import {v4} from 'uuid'
|
||||
import {handleTask, initTaskService, tasksMap} from './taskService'
|
||||
import {MESSAGE_TARGET_INJECT, MESSAGE_TO_EXTENSION_ADD_TASK, MESSAGE_TO_EXTENSION_CLOSE_SIDE_PANEL, MESSAGE_TO_EXTENSION_GET_TASK, MESSAGE_TO_EXTENSION_SHOW_FLAG, MESSAGE_TO_INJECT_TOGGLE_DISPLAY, STORAGE_ENV} from '@/consts/const'
|
||||
import ExtensionMessage from '@/messaging/ExtensionMessage'
|
||||
import { MESSAGE_TO_EXTENSION_ADD_TASK, MESSAGE_TO_EXTENSION_CLOSE_SIDE_PANEL, MESSAGE_TO_EXTENSION_GET_TASK, MESSAGE_TO_EXTENSION_SHOW_FLAG, MESSAGE_TO_INJECT_TOGGLE_DISPLAY, STORAGE_ENV} from '@/consts/const'
|
||||
import ExtensionMessage from '@/messaging/layer2/ExtensionMessage'
|
||||
import { TAG_TARGET_INJECT } from '@/messaging/const'
|
||||
|
||||
const setBadgeOk = async (tabId: number, ok: boolean) => {
|
||||
|
@@ -18,7 +18,7 @@ import {formatSrtTime, formatTime, formatVttTime} from '../utils/util'
|
||||
import {downloadText, openUrl} from '@kky002/kky-util'
|
||||
import toast from 'react-hot-toast'
|
||||
import {getSummarize} from '../utils/biz_util'
|
||||
import useMessage from '../messaging/useMessage'
|
||||
import useMessage from '../messaging/layer2/useMessage'
|
||||
interface Props {
|
||||
placement: Placement
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@ import { setCurFetched, setCurInfo, setData, setInfos, setTitle, setUrl } from '
|
||||
import { useMemo } from 'react'
|
||||
import { useAppDispatch } from './redux'
|
||||
import { MESSAGE_TO_APP_SET_INFOS, MESSAGE_TO_APP_SET_VIDEO_INFO } from '@/consts/const'
|
||||
import useMessageService from '@/messaging/useMessageService'
|
||||
import useMessageService from '@/messaging/layer2/useMessageService'
|
||||
|
||||
const useMessagingService = () => {
|
||||
const dispatch = useAppDispatch()
|
||||
|
@@ -2,7 +2,7 @@ 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 useMessage from '../messaging/useMessage'
|
||||
import useMessage from '../messaging/layer2/useMessage'
|
||||
const useSubtitle = () => {
|
||||
const dispatch = useAppDispatch()
|
||||
const reviewed = useAppSelector(state => state.env.tempData.reviewed)
|
||||
|
@@ -20,8 +20,8 @@ import {EVENT_EXPAND, GEMINI_TOKENS, TOTAL_HEIGHT_MAX, TOTAL_HEIGHT_MIN, WORDS_M
|
||||
import {useAsyncEffect, useInterval} from 'ahooks'
|
||||
import {getModelMaxTokens, getWholeText} from '../utils/biz_util'
|
||||
import {MESSAGE_TO_INJECT_GET_SUBTITLE} from '../consts/const'
|
||||
import useMessage from '../messaging/useMessage'
|
||||
import { injectWaiter } from '@/messaging/useMessageService'
|
||||
import useMessage from '../messaging/layer2/useMessage'
|
||||
import { injectWaiter } from '@/messaging/layer2/useMessageService'
|
||||
|
||||
/**
|
||||
* Service是单例,类似后端的服务概念
|
||||
|
@@ -31,7 +31,7 @@ import toast from 'react-hot-toast'
|
||||
import {useMemoizedFn} from 'ahooks/es'
|
||||
import {extractJsonArray, extractJsonObject, getModel} from '../utils/biz_util'
|
||||
import {formatTime} from '../utils/util'
|
||||
import useMessage from '@/messaging/useMessage'
|
||||
import useMessage from '@/messaging/layer2/useMessage'
|
||||
const useTranslate = () => {
|
||||
const dispatch = useAppDispatch()
|
||||
const data = useAppSelector(state => state.env.data)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import { TOTAL_HEIGHT_DEF, HEADER_HEIGHT, TOTAL_HEIGHT_MIN, TOTAL_HEIGHT_MAX, IFRAME_ID, MESSAGE_TO_INJECT_DOWNLOAD_AUDIO, MESSAGE_TARGET_INJECT, MESSAGE_TO_APP_SET_INFOS, MESSAGE_TO_INJECT_TOGGLE_DISPLAY, STORAGE_ENV, MESSAGE_TO_EXTENSION_SHOW_FLAG } from '@/consts/const'
|
||||
import { MESSAGE_TO_INJECT_FOLD, MESSAGE_TO_INJECT_MOVE, MESSAGE_TO_APP_SET_VIDEO_INFO, MESSAGE_TO_INJECT_GET_SUBTITLE, MESSAGE_TO_INJECT_GET_VIDEO_STATUS, MESSAGE_TO_INJECT_GET_VIDEO_ELEMENT_INFO, MESSAGE_TO_INJECT_UPDATETRANSRESULT, MESSAGE_TO_INJECT_PLAY, MESSAGE_TO_INJECT_HIDE_TRANS, MESSAGE_TO_INJECT_REFRESH_VIDEO_INFO } from '@/consts/const'
|
||||
import InjectMessage from '@/messaging/InjectMessage'
|
||||
import InjectMessage from '@/messaging/layer2/InjectMessage'
|
||||
|
||||
const debug = (...args: any[]) => {
|
||||
console.debug('[Inject]', ...args)
|
||||
|
@@ -1,6 +1,5 @@
|
||||
import { MESSAGE_TARGET_INJECT } from '@/consts/const'
|
||||
import Layer1Protocol from './Layer1Protocol'
|
||||
import { L2ReqMsg, L2ResMsg, MESSAGE_TO_EXTENSION_HANDSHAKE, MESSAGE_TO_EXTENSION_ROUTE_MSG } from './const'
|
||||
import Layer1Protocol from '../layer1/Layer1Protocol'
|
||||
import { L2ReqMsg, L2ResMsg, MESSAGE_TO_EXTENSION_HANDSHAKE, MESSAGE_TO_EXTENSION_ROUTE_MSG } from '../const'
|
||||
|
||||
export type PortContext = {
|
||||
id: string
|
@@ -1,6 +1,6 @@
|
||||
import { MESSAGE_TARGET_APP, MESSAGE_TARGET_EXTENSION, MESSAGE_TARGET_INJECT } from '@/consts/const'
|
||||
import Layer1Protocol from './Layer1Protocol'
|
||||
import { L2ReqMsg, L2ResMsg, MESSAGE_TO_EXTENSION_HANDSHAKE, MESSAGE_TO_EXTENSION_ROUTE_MSG, TAG_TARGET_APP, TAG_TARGET_INJECT } from './const'
|
||||
import { MESSAGE_TARGET_INJECT } from '@/consts/const'
|
||||
import Layer1Protocol from '../layer1/Layer1Protocol'
|
||||
import { L2ReqMsg, L2ResMsg, MESSAGE_TO_EXTENSION_HANDSHAKE, MESSAGE_TO_EXTENSION_ROUTE_MSG, TAG_TARGET_APP, TAG_TARGET_INJECT } from '../const'
|
||||
|
||||
class InjectMessage {
|
||||
port?: chrome.runtime.Port
|
@@ -1,8 +1,7 @@
|
||||
import { MESSAGE_TARGET_EXTENSION, MESSAGE_TARGET_INJECT } from '@/consts/const'
|
||||
import { injectWaiter } from './useMessageService'
|
||||
import { useCallback } from 'react'
|
||||
import Layer1Protocol from './Layer1Protocol'
|
||||
import { L2ReqMsg, L2ResMsg, MESSAGE_TO_EXTENSION_ROUTE_MSG, TAG_TARGET_INJECT } from './const'
|
||||
import Layer1Protocol from '../layer1/Layer1Protocol'
|
||||
import { L2ReqMsg, L2ResMsg, MESSAGE_TO_EXTENSION_ROUTE_MSG, TAG_TARGET_INJECT } from '../const'
|
||||
|
||||
const useMessage = () => {
|
||||
const sendExtension = useCallback(async <T = any>(method: string, params?: any) => {
|
@@ -3,8 +3,8 @@ import {
|
||||
MESSAGE_TARGET_APP,
|
||||
} from '@/consts/const'
|
||||
import { Waiter } from '@kky002/kky-util'
|
||||
import Layer1Protocol from './Layer1Protocol'
|
||||
import { L2ReqMsg, L2ResMsg, MESSAGE_TO_EXTENSION_HANDSHAKE, TAG_TARGET_APP } from './const'
|
||||
import Layer1Protocol from '../layer1/Layer1Protocol'
|
||||
import { L2ReqMsg, L2ResMsg, MESSAGE_TO_EXTENSION_HANDSHAKE, TAG_TARGET_APP } from '../const'
|
||||
|
||||
const debug = (...args: any[]) => {
|
||||
console.debug('[App Messaging]', ...args)
|
@@ -8,7 +8,7 @@ import {EventBusContext} from '../Router'
|
||||
import useTranslateService from '../hooks/useTranslateService'
|
||||
import {setTheme} from '../utils/biz_util'
|
||||
import useSearchService from '../hooks/useSearchService'
|
||||
import useMessage from '../messaging/useMessage'
|
||||
import useMessage from '../messaging/layer2/useMessage'
|
||||
import {setFold} from '../redux/envReducer'
|
||||
|
||||
function App() {
|
||||
|
@@ -29,7 +29,7 @@ import classNames from 'classnames'
|
||||
import toast from 'react-hot-toast'
|
||||
import {useBoolean, useEventTarget} from 'ahooks'
|
||||
import {useEventChecked} from '@kky002/kky-hooks'
|
||||
import useMessage from '@/messaging/useMessage'
|
||||
import useMessage from '@/messaging/layer2/useMessage'
|
||||
|
||||
const Section = (props: {
|
||||
title: ShowElement
|
||||
|
Reference in New Issue
Block a user