You've already forked bilibili-subtitle
fix
This commit is contained in:
@@ -3,7 +3,7 @@ import 'tippy.js/dist/tippy.css'
|
||||
import {useAppDispatch, useAppSelector} from './hooks/redux'
|
||||
import {setEnvData, setEnvReady, setTempData, setTempReady} from './redux/envReducer'
|
||||
import {cloneDeep} from 'lodash-es'
|
||||
import {STORAGE_ENV, STORAGE_TEMP} from './const'
|
||||
import {STORAGE_ENV, STORAGE_TEMP} from './consts/const'
|
||||
import OptionsPage from './pages/OptionsPage'
|
||||
import {handleJson} from '@kky002/kky-util'
|
||||
import {useLocalStorage} from '@kky002/kky-hooks'
|
||||
|
@@ -8,6 +8,7 @@ export const EventBusContext = React.createContext<any>(null)
|
||||
|
||||
const map: { [key: string]: string } = {
|
||||
'/options.html': 'options',
|
||||
'/sidepanel.html': 'app',
|
||||
// '/close': 'close',
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import {v4} from 'uuid'
|
||||
import {handleTask, initTaskService, tasksMap} from './taskService'
|
||||
import {MESSAGE_TARGET_INJECT, MESSAGE_TO_EXTENSION_ADD_TASK, MESSAGE_TO_EXTENSION_GET_TASK, MESSAGE_TO_EXTENSION_SHOW_FLAG, MESSAGE_TO_INJECT_TOGGLE_DISPLAY, STORAGE_ENV} from '@/const'
|
||||
import {MESSAGE_TARGET_INJECT, MESSAGE_TO_EXTENSION_ADD_TASK, 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'
|
||||
|
||||
const setBadgeOk = async (tabId: number, ok: boolean) => {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import {DEFAULT_SERVER_URL_OPENAI} from '../const'
|
||||
import {DEFAULT_SERVER_URL_OPENAI} from '../consts/const'
|
||||
|
||||
const getServerUrl = (serverUrl?: string) => {
|
||||
if (!serverUrl) {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import {TASK_EXPIRE_TIME} from '../const'
|
||||
import {TASK_EXPIRE_TIME} from '../consts/const'
|
||||
import {handleChatCompleteTask, handleGeminiChatCompleteTask} from './openaiService'
|
||||
|
||||
export const tasksMap = new Map<string, Task>()
|
||||
|
@@ -30,7 +30,7 @@ import {
|
||||
SEARCH_BAR_HEIGHT,
|
||||
SUMMARIZE_ALL_THRESHOLD,
|
||||
TITLE_HEIGHT
|
||||
} from '../const'
|
||||
} from '../consts/const'
|
||||
import {FaClipboardList} from 'react-icons/fa'
|
||||
import useTranslate from '../hooks/useTranslate'
|
||||
import {openUrl} from '@kky002/kky-util'
|
@@ -1,6 +1,6 @@
|
||||
import React, {useMemo} from 'react'
|
||||
import {useAppSelector} from '../hooks/redux'
|
||||
import {getDisplay, getTransText} from '../util/biz_util'
|
||||
import {getDisplay, getTransText} from '../utils/biz_util'
|
||||
import classNames from 'classnames'
|
||||
|
||||
const CompactSegmentItem = (props: {
|
@@ -5,7 +5,7 @@ import {find, remove} from 'lodash-es'
|
||||
import {setCurFetched, setCurInfo, setData, setInfos, setUploadedTranscript} from '../redux/envReducer'
|
||||
import MoreBtn from './MoreBtn'
|
||||
import classNames from 'classnames'
|
||||
import {parseTranscript} from '../util/biz_util'
|
||||
import {parseTranscript} from '../utils/biz_util'
|
||||
|
||||
const Header = (props: {
|
||||
foldCallback: () => void
|
@@ -13,11 +13,11 @@ import {Placement} from '@popperjs/core/lib/enums'
|
||||
import {useAppDispatch, useAppSelector} from '../hooks/redux'
|
||||
import {setEnvData, setTempData} from '../redux/envReducer'
|
||||
import {EventBusContext} from '../Router'
|
||||
import {EVENT_EXPAND, MESSAGE_TO_INJECT_DOWNLOAD_AUDIO} from '../const'
|
||||
import {formatSrtTime, formatTime, formatVttTime} from '../util/util'
|
||||
import {EVENT_EXPAND, MESSAGE_TO_INJECT_DOWNLOAD_AUDIO} from '../consts/const'
|
||||
import {formatSrtTime, formatTime, formatVttTime} from '../utils/util'
|
||||
import {downloadText, openUrl} from '@kky002/kky-util'
|
||||
import toast from 'react-hot-toast'
|
||||
import {getSummarize} from '../util/biz_util'
|
||||
import {getSummarize} from '../utils/biz_util'
|
||||
import useMessage from '../messaging/useMessage'
|
||||
interface Props {
|
||||
placement: Placement
|
@@ -1,7 +1,7 @@
|
||||
import React, {useMemo} from 'react'
|
||||
import {formatTime} from '../util/util'
|
||||
import {formatTime} from '../utils/util'
|
||||
import {useAppSelector} from '../hooks/redux'
|
||||
import {getDisplay, getTransText} from '../util/biz_util'
|
||||
import {getDisplay, getTransText} from '../utils/biz_util'
|
||||
import classNames from 'classnames'
|
||||
|
||||
const NormalSegmentItem = (props: {
|
@@ -4,7 +4,7 @@ import { IoMdClose } from 'react-icons/io';
|
||||
import { setTempData } from '../redux/envReducer';
|
||||
import { useAppDispatch, useAppSelector } from '../hooks/redux';
|
||||
import { openUrl } from '@kky002/kky-util';
|
||||
import { isEdgeBrowser } from '../util/util';
|
||||
import { isEdgeBrowser } from '../utils/util';
|
||||
|
||||
const RateExtension: React.FC = () => {
|
||||
const dispatch = useAppDispatch()
|
||||
|
@@ -3,14 +3,14 @@ import {useAppDispatch, useAppSelector} from '../hooks/redux'
|
||||
import {setFloatKeyPointsSegIdx, setSegmentFold, setTempData} from '../redux/envReducer'
|
||||
import classNames from 'classnames'
|
||||
import {FaClipboardList} from 'react-icons/fa'
|
||||
import {PAGE_MAIN, PAGE_SETTINGS, SUMMARIZE_THRESHOLD, SUMMARIZE_TYPES} from '../const'
|
||||
import {PAGE_MAIN, PAGE_SETTINGS, SUMMARIZE_THRESHOLD, SUMMARIZE_TYPES} from '../consts/const'
|
||||
import useTranslate from '../hooks/useTranslate'
|
||||
import {BsDashSquare, BsPlusSquare, CgFileDocument, FaQuestion, GrOverview, RiFileCopy2Line} from 'react-icons/all'
|
||||
import toast from 'react-hot-toast'
|
||||
import {getLastTime, getSummaryStr, isSummaryEmpty, parseStrTimeToSeconds} from '../util/biz_util'
|
||||
import {getLastTime, getSummaryStr, isSummaryEmpty, parseStrTimeToSeconds} from '../utils/biz_util'
|
||||
import {useInViewport} from 'ahooks'
|
||||
import SegmentItem from './SegmentItem'
|
||||
import {stopPopFunc} from '../util/util'
|
||||
import {stopPopFunc} from '../utils/util'
|
||||
import useSubtitle from '../hooks/useSubtitle'
|
||||
|
||||
const SummarizeItemOverview = (props: {
|
@@ -1,7 +1,7 @@
|
||||
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 '@/const'
|
||||
import { MESSAGE_TO_APP_SET_INFOS, MESSAGE_TO_APP_SET_VIDEO_INFO } from '@/consts/const'
|
||||
import useMessageService from '@/messaging/useMessageService'
|
||||
|
||||
const useMessagingService = () => {
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import {useAppDispatch, useAppSelector} from './redux'
|
||||
import {useEffect, useMemo} from 'react'
|
||||
import {setSearchResult, setSearchText, } from '../redux/envReducer'
|
||||
import {Search} from '../util/search'
|
||||
import {Search} from '../utils/search'
|
||||
|
||||
interface Document {
|
||||
idx: number
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import {useAppDispatch, useAppSelector} from './redux'
|
||||
import React, {useCallback} from 'react'
|
||||
import {setNeedScroll, setReviewAction, setTempData} from '../redux/envReducer'
|
||||
import {MESSAGE_TO_INJECT_MOVE} from '../const'
|
||||
import {MESSAGE_TO_INJECT_MOVE} from '../consts/const'
|
||||
import useMessage from '../messaging/useMessage'
|
||||
const useSubtitle = () => {
|
||||
const dispatch = useAppDispatch()
|
||||
|
@@ -16,10 +16,10 @@ 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 '../const'
|
||||
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 {useAsyncEffect, useInterval} from 'ahooks'
|
||||
import {getModelMaxTokens, getWholeText} from '../util/biz_util'
|
||||
import {MESSAGE_TO_INJECT_GET_SUBTITLE} from '../const'
|
||||
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'
|
||||
|
||||
|
@@ -26,11 +26,11 @@ import {
|
||||
SUMMARIZE_TYPES,
|
||||
TRANSLATE_COOLDOWN,
|
||||
TRANSLATE_FETCH_DEFAULT,
|
||||
} from '../const'
|
||||
} from '../consts/const'
|
||||
import toast from 'react-hot-toast'
|
||||
import {useMemoizedFn} from 'ahooks/es'
|
||||
import {extractJsonArray, extractJsonObject, getModel} from '../util/biz_util'
|
||||
import {formatTime} from '../util/util'
|
||||
import {extractJsonArray, extractJsonObject, getModel} from '../utils/biz_util'
|
||||
import {formatTime} from '../utils/util'
|
||||
import useMessage from '@/messaging/useMessage'
|
||||
const useTranslate = () => {
|
||||
const dispatch = useAppDispatch()
|
||||
|
@@ -1,5 +1,5 @@
|
||||
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 '@/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 '@/const'
|
||||
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'
|
||||
|
||||
const debug = (...args: any[]) => {
|
||||
|
@@ -4,7 +4,7 @@ import './index.less'
|
||||
import store from './store'
|
||||
import {Provider} from 'react-redux'
|
||||
import Router from './Router'
|
||||
import {APP_DOM_ID} from './const'
|
||||
import {APP_DOM_ID} from './consts/const'
|
||||
|
||||
const body = document.querySelector('body')
|
||||
const app = document.createElement('div')
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { MESSAGE_TARGET_EXTENSION, MESSAGE_TARGET_INJECT, MESSAGE_TO_EXTENSION_ROUTE_MSG } from '@/const'
|
||||
import { MESSAGE_TARGET_EXTENSION, MESSAGE_TO_EXTENSION_ROUTE_MSG } from '@/consts/const'
|
||||
import PortMessageHandler from './PortMessageHandler'
|
||||
|
||||
export type PortContext = {
|
||||
|
@@ -1,5 +1,4 @@
|
||||
import { MESSAGE_TARGET_APP, MESSAGE_TARGET_EXTENSION, MESSAGE_TARGET_INJECT, MESSAGE_TO_EXTENSION_ROUTE_MSG } from '@/const'
|
||||
import { PostMessagePayload, PostMessageResponse, startListening } from 'postmessage-promise'
|
||||
import { MESSAGE_TARGET_APP, MESSAGE_TARGET_EXTENSION, MESSAGE_TARGET_INJECT, MESSAGE_TO_EXTENSION_ROUTE_MSG } from '@/consts/const'
|
||||
import PortMessageHandler from './PortMessageHandler'
|
||||
|
||||
class InjectMessage {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { MESSAGE_TARGET_EXTENSION, MESSAGE_TARGET_INJECT, MESSAGE_TO_EXTENSION_ROUTE_MSG } from '@/const'
|
||||
import { MESSAGE_TARGET_EXTENSION, MESSAGE_TARGET_INJECT, MESSAGE_TO_EXTENSION_ROUTE_MSG } from '@/consts/const'
|
||||
import { injectWaiter } from './useMessageService'
|
||||
import { useCallback } from 'react'
|
||||
import PortMessageHandler from './PortMessageHandler'
|
||||
|
@@ -1,10 +1,7 @@
|
||||
import { useCallback, useEffect, useMemo } from 'react'
|
||||
import { useCallback, useMemo } from 'react'
|
||||
import {
|
||||
MESSAGE_TARGET_APP,
|
||||
MESSAGE_TARGET_EXTENSION,
|
||||
MESSAGE_TARGET_INJECT,
|
||||
} from '@/const'
|
||||
import { callServer, PostMessagePayload, PostMessageResponse } from 'postmessage-promise'
|
||||
} from '@/consts/const'
|
||||
import { Waiter } from '@kky002/kky-util'
|
||||
import PortMessageHandler from './PortMessageHandler'
|
||||
|
||||
|
@@ -1,19 +1,15 @@
|
||||
import React, {useCallback, useContext, useEffect, useMemo} from 'react'
|
||||
import React, {useCallback, useContext, useEffect} from 'react'
|
||||
import {useAppDispatch, useAppSelector} from '../hooks/redux'
|
||||
import {setEnvData, setEnvReady, setFold, setTempData, setTempReady} from '../redux/envReducer'
|
||||
import Header from '../biz/Header'
|
||||
import Body from '../biz/Body'
|
||||
import Header from '../components/Header'
|
||||
import Body from '../components/Body'
|
||||
import useSubtitleService from '../hooks/useSubtitleService'
|
||||
import {cloneDeep} from 'lodash-es'
|
||||
import {EVENT_EXPAND, MESSAGE_TO_INJECT_FOLD, PAGE_MAIN, PAGE_SETTINGS, STORAGE_ENV, STORAGE_TEMP} from '../const'
|
||||
import {EVENT_EXPAND, MESSAGE_TO_INJECT_FOLD} from '../consts/const'
|
||||
import {EventBusContext} from '../Router'
|
||||
import useTranslateService from '../hooks/useTranslateService'
|
||||
import {handleJson} from '@kky002/kky-util'
|
||||
import {useLocalStorage} from '@kky002/kky-hooks'
|
||||
import {Toaster} from 'react-hot-toast'
|
||||
import {setTheme} from '../util/biz_util'
|
||||
import {setTheme} from '../utils/biz_util'
|
||||
import useSearchService from '../hooks/useSearchService'
|
||||
import useMessage from '../messaging/useMessage'
|
||||
import {setFold} from '../redux/envReducer'
|
||||
|
||||
function App() {
|
||||
const dispatch = useAppDispatch()
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import React, {PropsWithChildren, useCallback, useEffect, useMemo, useState} from 'react'
|
||||
import React, {PropsWithChildren, useCallback, useMemo, useState} from 'react'
|
||||
import {setEnvData, setTempData} from '../redux/envReducer'
|
||||
import {useAppDispatch, useAppSelector} from '../hooks/redux'
|
||||
import {
|
||||
@@ -22,7 +22,7 @@ import {
|
||||
TRANSLATE_FETCH_MIN,
|
||||
TRANSLATE_FETCH_STEP,
|
||||
WORDS_RATE,
|
||||
} from '../const'
|
||||
} from '../consts/const'
|
||||
import {IoWarning} from 'react-icons/all'
|
||||
import classNames from 'classnames'
|
||||
import toast from 'react-hot-toast'
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import {createSlice, PayloadAction} from '@reduxjs/toolkit'
|
||||
import {find, findIndex} from 'lodash-es'
|
||||
import {DEFAULT_SERVER_URL_OPENAI, TOTAL_HEIGHT_DEF} from '../const'
|
||||
import {DEFAULT_SERVER_URL_OPENAI, TOTAL_HEIGHT_DEF} from '../consts/const'
|
||||
|
||||
interface EnvState {
|
||||
envData: EnvData
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import {APP_DOM_ID, CUSTOM_MODEL_TOKENS, MODEL_DEFAULT, MODEL_MAP, SUMMARIZE_TYPES} from '../const'
|
||||
import {APP_DOM_ID, CUSTOM_MODEL_TOKENS, MODEL_DEFAULT, MODEL_MAP, SUMMARIZE_TYPES} from '../consts/const'
|
||||
import {isDarkMode} from '@kky002/kky-util'
|
||||
import toast from 'react-hot-toast'
|
||||
import {findIndex} from 'lodash-es'
|
Reference in New Issue
Block a user