This commit is contained in:
IndieKKY
2024-10-04 00:07:11 +08:00
parent f50a2e3abd
commit abb97813d1
4 changed files with 8 additions and 9 deletions

View File

@@ -23,7 +23,7 @@ const SegmentItem = (props: {
const searchResult = useAppSelector(state => state.env.searchResult) const searchResult = useAppSelector(state => state.env.searchResult)
const display = useMemo(() => { const display = useMemo(() => {
if (searchText) { if (searchText) {
return searchResult.has(item.idx) ? 'inline' : 'none' return searchResult[item.idx+''] ? 'inline' : 'none'
} else { } else {
return 'inline' return 'inline'
} }

View File

@@ -42,14 +42,14 @@ const useSearchService = () => {
// search text // search text
useEffect(() => { useEffect(() => {
const searchResult: Set<number> = new Set() const searchResult: Record<string, boolean> = {}
if (envData.searchEnabled && searchText) { if (envData.searchEnabled && searchText) {
// @ts-expect-error // @ts-expect-error
const documents: Document[] | undefined = search(searchText) const documents: Document[] | undefined = search(searchText)
if (documents != null) { if (documents != null) {
for (const document of documents) { for (const document of documents) {
searchResult.add(document.idx) searchResult[''+document.idx] = true
} }
} }
} }

View File

@@ -74,13 +74,12 @@ const useSubtitleService = () => {
useEffect(() => { useEffect(() => {
if (curInfo && !curFetched) { if (curInfo && !curFetched) {
sendInject(MESSAGE_TO_INJECT_GET_SUBTITLE, {info: curInfo}).then(data => { 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 item.idx = idx
}) })
// dispatch(setCurInfo(data.data.info)) // dispatch(setCurInfo(data.data.info))
dispatch(setCurFetched(true)) dispatch(setCurFetched(true))
dispatch(setData(data_)) dispatch(setData(data))
console.log('subtitle', data) console.log('subtitle', data)
}) })

View File

@@ -46,7 +46,7 @@ interface EnvState {
inputting: boolean inputting: boolean
searchText: string searchText: string
searchResult: Set<number> searchResult: Record<string, boolean>
//当前视频是否计算过操作 //当前视频是否计算过操作
reviewAction: boolean reviewAction: boolean
@@ -74,7 +74,7 @@ const initialState: EnvState = {
inputting: false, inputting: false,
searchText: '', searchText: '',
searchResult: new Set(), searchResult: {},
asks: [], asks: [],
@@ -109,7 +109,7 @@ export const slice = createSlice({
setSearchText: (state, action: PayloadAction<string>) => { setSearchText: (state, action: PayloadAction<string>) => {
state.searchText = action.payload state.searchText = action.payload
}, },
setSearchResult: (state, action: PayloadAction<Set<number>>) => { setSearchResult: (state, action: PayloadAction<Record<string, boolean>>) => {
state.searchResult = action.payload state.searchResult = action.payload
}, },
setFloatKeyPointsSegIdx: (state, action: PayloadAction<number | undefined>) => { setFloatKeyPointsSegIdx: (state, action: PayloadAction<number | undefined>) => {