You've already forked bilibili-subtitle
fix
This commit is contained in:
@@ -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'
|
||||
}
|
||||
|
@@ -42,14 +42,14 @@ const useSearchService = () => {
|
||||
|
||||
// search text
|
||||
useEffect(() => {
|
||||
const searchResult: Set<number> = new Set()
|
||||
const searchResult: Record<string, boolean> = {}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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)
|
||||
})
|
||||
|
@@ -46,7 +46,7 @@ interface EnvState {
|
||||
inputting: boolean
|
||||
|
||||
searchText: string
|
||||
searchResult: Set<number>
|
||||
searchResult: Record<string, boolean>
|
||||
|
||||
//当前视频是否计算过操作
|
||||
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<string>) => {
|
||||
state.searchText = action.payload
|
||||
},
|
||||
setSearchResult: (state, action: PayloadAction<Set<number>>) => {
|
||||
setSearchResult: (state, action: PayloadAction<Record<string, boolean>>) => {
|
||||
state.searchResult = action.payload
|
||||
},
|
||||
setFloatKeyPointsSegIdx: (state, action: PayloadAction<number | undefined>) => {
|
||||
|
Reference in New Issue
Block a user