You've already forked bilibili-subtitle
保存列表/文章视图选择
This commit is contained in:
@@ -3,12 +3,12 @@ import {
|
||||
setAutoScroll,
|
||||
setAutoTranslate,
|
||||
setCheckAutoScroll,
|
||||
setCompact,
|
||||
setFoldAll,
|
||||
setNeedScroll,
|
||||
setPage,
|
||||
setSearchText,
|
||||
setSegmentFold
|
||||
setSegmentFold,
|
||||
setTempData
|
||||
} from '../redux/envReducer'
|
||||
import {useAppDispatch, useAppSelector} from '../hooks/redux'
|
||||
import {
|
||||
@@ -44,7 +44,7 @@ const Body = () => {
|
||||
const segments = useAppSelector(state => state.env.segments)
|
||||
const foldAll = useAppSelector(state => state.env.foldAll)
|
||||
const envData = useAppSelector(state => state.env.envData)
|
||||
const compact = useAppSelector(state => state.env.compact)
|
||||
const compact = useAppSelector(state => state.env.tempData.compact)
|
||||
const apiKey = useAppSelector(state => state.env.envData.apiKey)
|
||||
const floatKeyPointsSegIdx = useAppSelector(state => state.env.floatKeyPointsSegIdx)
|
||||
const translateEnable = useAppSelector(state => state.env.envData.translateEnable)
|
||||
@@ -60,11 +60,15 @@ const Body = () => {
|
||||
const searchText = useAppSelector(state => state.env.searchText)
|
||||
|
||||
const normalCallback = useCallback(() => {
|
||||
dispatch(setCompact(false))
|
||||
dispatch(setTempData({
|
||||
compact: false
|
||||
}))
|
||||
}, [dispatch])
|
||||
|
||||
const compactCallback = useCallback(() => {
|
||||
dispatch(setCompact(true))
|
||||
dispatch(setTempData({
|
||||
compact: true
|
||||
}))
|
||||
}, [dispatch])
|
||||
|
||||
const posCallback = useCallback(() => {
|
||||
|
@@ -138,7 +138,7 @@ const SegmentCard = (props: {
|
||||
const summarizeFloat = useAppSelector(state => state.env.envData.summarizeFloat)
|
||||
const fold = useAppSelector(state => state.env.fold)
|
||||
const page = useAppSelector(state => state.env.page)
|
||||
const compact = useAppSelector(state => state.env.compact)
|
||||
const compact = useAppSelector(state => state.env.tempData.compact)
|
||||
const floatKeyPointsSegIdx = useAppSelector(state => state.env.floatKeyPointsSegIdx)
|
||||
const showCurrent = useMemo(() => curIdx != null && segment.startIdx <= curIdx && curIdx <= segment.endIdx, [curIdx, segment.endIdx, segment.startIdx])
|
||||
const curSummaryType = useAppSelector(state => state.env.tempData.curSummaryType)
|
||||
|
@@ -18,7 +18,7 @@ const SegmentItem = (props: {
|
||||
const ref = useRef<any>()
|
||||
const {move} = useSubtitle()
|
||||
|
||||
const compact = useAppSelector(state => state.env.compact)
|
||||
const compact = useAppSelector(state => state.env.tempData.compact)
|
||||
const searchText = useAppSelector(state => state.env.searchText)
|
||||
const searchResult = useAppSelector(state => state.env.searchResult)
|
||||
const display = useMemo(() => {
|
||||
|
@@ -17,7 +17,6 @@ interface EnvState {
|
||||
autoScroll?: boolean
|
||||
checkAutoScroll?: boolean
|
||||
curOffsetTop?: number
|
||||
compact?: boolean // 是否紧凑视图
|
||||
floatKeyPointsSegIdx?: number // segment的startIdx
|
||||
|
||||
noVideo?: boolean
|
||||
@@ -81,7 +80,7 @@ export const slice = createSlice({
|
||||
setEnvReady: (state) => {
|
||||
state.envReady = true
|
||||
},
|
||||
setTempData: (state, action: PayloadAction<TempData>) => {
|
||||
setTempData: (state, action: PayloadAction<Partial<TempData>>) => {
|
||||
state.tempData = {
|
||||
...state.tempData,
|
||||
...action.payload,
|
||||
@@ -102,9 +101,6 @@ export const slice = createSlice({
|
||||
setFoldAll: (state, action: PayloadAction<boolean>) => {
|
||||
state.foldAll = action.payload
|
||||
},
|
||||
setCompact: (state, action: PayloadAction<boolean>) => {
|
||||
state.compact = action.payload
|
||||
},
|
||||
setPage: (state, action: PayloadAction<string | undefined>) => {
|
||||
state.page = action.payload
|
||||
},
|
||||
@@ -275,7 +271,6 @@ export const {
|
||||
setCurOffsetTop,
|
||||
setFloatKeyPointsSegIdx,
|
||||
setFoldAll,
|
||||
setCompact,
|
||||
setSegmentFold,
|
||||
setSummaryContent,
|
||||
setSummaryStatus,
|
||||
|
1
src/typings.d.ts
vendored
1
src/typings.d.ts
vendored
@@ -27,6 +27,7 @@ interface EnvData {
|
||||
|
||||
interface TempData {
|
||||
curSummaryType: SummaryType
|
||||
compact?: boolean // 是否紧凑视图
|
||||
}
|
||||
|
||||
interface TaskDef {
|
||||
|
Reference in New Issue
Block a user