From abb97813d170f0b5e58acbff464b0a405eaec614 Mon Sep 17 00:00:00 2001 From: IndieKKY Date: Fri, 4 Oct 2024 00:07:11 +0800 Subject: [PATCH] fix --- src/biz/SegmentItem.tsx | 2 +- src/hooks/useSearchService.ts | 4 ++-- src/hooks/useSubtitleService.ts | 5 ++--- src/redux/envReducer.ts | 6 +++--- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/biz/SegmentItem.tsx b/src/biz/SegmentItem.tsx index 0e42e43..0f56daf 100644 --- a/src/biz/SegmentItem.tsx +++ b/src/biz/SegmentItem.tsx @@ -23,7 +23,7 @@ const SegmentItem = (props: { const searchResult = useAppSelector(state => state.env.searchResult) const display = useMemo(() => { if (searchText) { - return searchResult.has(item.idx) ? 'inline' : 'none' + return searchResult[item.idx+''] ? 'inline' : 'none' } else { return 'inline' } diff --git a/src/hooks/useSearchService.ts b/src/hooks/useSearchService.ts index cd16d64..33ad661 100644 --- a/src/hooks/useSearchService.ts +++ b/src/hooks/useSearchService.ts @@ -42,14 +42,14 @@ const useSearchService = () => { // search text useEffect(() => { - const searchResult: Set = new Set() + const searchResult: Record = {} if (envData.searchEnabled && searchText) { // @ts-expect-error const documents: Document[] | undefined = search(searchText) if (documents != null) { for (const document of documents) { - searchResult.add(document.idx) + searchResult[''+document.idx] = true } } } diff --git a/src/hooks/useSubtitleService.ts b/src/hooks/useSubtitleService.ts index c65fcae..28ea003 100644 --- a/src/hooks/useSubtitleService.ts +++ b/src/hooks/useSubtitleService.ts @@ -74,13 +74,12 @@ const useSubtitleService = () => { useEffect(() => { if (curInfo && !curFetched) { sendInject(MESSAGE_TO_INJECT_GET_SUBTITLE, {info: curInfo}).then(data => { - const data_ = data.data - data_?.body?.forEach((item: TranscriptItem, idx: number) => { + data?.body?.forEach((item: TranscriptItem, idx: number) => { item.idx = idx }) // dispatch(setCurInfo(data.data.info)) dispatch(setCurFetched(true)) - dispatch(setData(data_)) + dispatch(setData(data)) console.log('subtitle', data) }) diff --git a/src/redux/envReducer.ts b/src/redux/envReducer.ts index e7e0c59..4727be0 100644 --- a/src/redux/envReducer.ts +++ b/src/redux/envReducer.ts @@ -46,7 +46,7 @@ interface EnvState { inputting: boolean searchText: string - searchResult: Set + searchResult: Record //当前视频是否计算过操作 reviewAction: boolean @@ -74,7 +74,7 @@ const initialState: EnvState = { inputting: false, searchText: '', - searchResult: new Set(), + searchResult: {}, asks: [], @@ -109,7 +109,7 @@ export const slice = createSlice({ setSearchText: (state, action: PayloadAction) => { state.searchText = action.payload }, - setSearchResult: (state, action: PayloadAction>) => { + setSearchResult: (state, action: PayloadAction>) => { state.searchResult = action.payload }, setFloatKeyPointsSegIdx: (state, action: PayloadAction) => {