保存列表/文章视图选择

This commit is contained in:
IndieKKY
2024-01-20 10:19:47 +08:00
parent 728e4dce84
commit 8098d7cf9b
5 changed files with 13 additions and 13 deletions

View File

@@ -3,12 +3,12 @@ import {
setAutoScroll, setAutoScroll,
setAutoTranslate, setAutoTranslate,
setCheckAutoScroll, setCheckAutoScroll,
setCompact,
setFoldAll, setFoldAll,
setNeedScroll, setNeedScroll,
setPage, setPage,
setSearchText, setSearchText,
setSegmentFold setSegmentFold,
setTempData
} from '../redux/envReducer' } from '../redux/envReducer'
import {useAppDispatch, useAppSelector} from '../hooks/redux' import {useAppDispatch, useAppSelector} from '../hooks/redux'
import { import {
@@ -44,7 +44,7 @@ const Body = () => {
const segments = useAppSelector(state => state.env.segments) const segments = useAppSelector(state => state.env.segments)
const foldAll = useAppSelector(state => state.env.foldAll) const foldAll = useAppSelector(state => state.env.foldAll)
const envData = useAppSelector(state => state.env.envData) 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 apiKey = useAppSelector(state => state.env.envData.apiKey)
const floatKeyPointsSegIdx = useAppSelector(state => state.env.floatKeyPointsSegIdx) const floatKeyPointsSegIdx = useAppSelector(state => state.env.floatKeyPointsSegIdx)
const translateEnable = useAppSelector(state => state.env.envData.translateEnable) const translateEnable = useAppSelector(state => state.env.envData.translateEnable)
@@ -60,11 +60,15 @@ const Body = () => {
const searchText = useAppSelector(state => state.env.searchText) const searchText = useAppSelector(state => state.env.searchText)
const normalCallback = useCallback(() => { const normalCallback = useCallback(() => {
dispatch(setCompact(false)) dispatch(setTempData({
compact: false
}))
}, [dispatch]) }, [dispatch])
const compactCallback = useCallback(() => { const compactCallback = useCallback(() => {
dispatch(setCompact(true)) dispatch(setTempData({
compact: true
}))
}, [dispatch]) }, [dispatch])
const posCallback = useCallback(() => { const posCallback = useCallback(() => {

View File

@@ -138,7 +138,7 @@ const SegmentCard = (props: {
const summarizeFloat = useAppSelector(state => state.env.envData.summarizeFloat) const summarizeFloat = useAppSelector(state => state.env.envData.summarizeFloat)
const fold = useAppSelector(state => state.env.fold) const fold = useAppSelector(state => state.env.fold)
const page = useAppSelector(state => state.env.page) 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 floatKeyPointsSegIdx = useAppSelector(state => state.env.floatKeyPointsSegIdx)
const showCurrent = useMemo(() => curIdx != null && segment.startIdx <= curIdx && curIdx <= segment.endIdx, [curIdx, segment.endIdx, segment.startIdx]) const showCurrent = useMemo(() => curIdx != null && segment.startIdx <= curIdx && curIdx <= segment.endIdx, [curIdx, segment.endIdx, segment.startIdx])
const curSummaryType = useAppSelector(state => state.env.tempData.curSummaryType) const curSummaryType = useAppSelector(state => state.env.tempData.curSummaryType)

View File

@@ -18,7 +18,7 @@ const SegmentItem = (props: {
const ref = useRef<any>() const ref = useRef<any>()
const {move} = useSubtitle() 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 searchText = useAppSelector(state => state.env.searchText)
const searchResult = useAppSelector(state => state.env.searchResult) const searchResult = useAppSelector(state => state.env.searchResult)
const display = useMemo(() => { const display = useMemo(() => {

View File

@@ -17,7 +17,6 @@ interface EnvState {
autoScroll?: boolean autoScroll?: boolean
checkAutoScroll?: boolean checkAutoScroll?: boolean
curOffsetTop?: number curOffsetTop?: number
compact?: boolean // 是否紧凑视图
floatKeyPointsSegIdx?: number // segment的startIdx floatKeyPointsSegIdx?: number // segment的startIdx
noVideo?: boolean noVideo?: boolean
@@ -81,7 +80,7 @@ export const slice = createSlice({
setEnvReady: (state) => { setEnvReady: (state) => {
state.envReady = true state.envReady = true
}, },
setTempData: (state, action: PayloadAction<TempData>) => { setTempData: (state, action: PayloadAction<Partial<TempData>>) => {
state.tempData = { state.tempData = {
...state.tempData, ...state.tempData,
...action.payload, ...action.payload,
@@ -102,9 +101,6 @@ export const slice = createSlice({
setFoldAll: (state, action: PayloadAction<boolean>) => { setFoldAll: (state, action: PayloadAction<boolean>) => {
state.foldAll = action.payload state.foldAll = action.payload
}, },
setCompact: (state, action: PayloadAction<boolean>) => {
state.compact = action.payload
},
setPage: (state, action: PayloadAction<string | undefined>) => { setPage: (state, action: PayloadAction<string | undefined>) => {
state.page = action.payload state.page = action.payload
}, },
@@ -275,7 +271,6 @@ export const {
setCurOffsetTop, setCurOffsetTop,
setFloatKeyPointsSegIdx, setFloatKeyPointsSegIdx,
setFoldAll, setFoldAll,
setCompact,
setSegmentFold, setSegmentFold,
setSummaryContent, setSummaryContent,
setSummaryStatus, setSummaryStatus,

1
src/typings.d.ts vendored
View File

@@ -27,6 +27,7 @@ interface EnvData {
interface TempData { interface TempData {
curSummaryType: SummaryType curSummaryType: SummaryType
compact?: boolean // 是否紧凑视图
} }
interface TaskDef { interface TaskDef {