From 8098d7cf9baef46d5dba2d4f4af778ee55ae5b34 Mon Sep 17 00:00:00 2001 From: IndieKKY Date: Sat, 20 Jan 2024 10:19:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=9D=E5=AD=98=E5=88=97=E8=A1=A8/=E6=96=87?= =?UTF-8?q?=E7=AB=A0=E8=A7=86=E5=9B=BE=E9=80=89=E6=8B=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/biz/Body.tsx | 14 +++++++++----- src/biz/SegmentCard.tsx | 2 +- src/biz/SegmentItem.tsx | 2 +- src/redux/envReducer.ts | 7 +------ src/typings.d.ts | 1 + 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/biz/Body.tsx b/src/biz/Body.tsx index 7265c9b..04006c4 100644 --- a/src/biz/Body.tsx +++ b/src/biz/Body.tsx @@ -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(() => { diff --git a/src/biz/SegmentCard.tsx b/src/biz/SegmentCard.tsx index a29286c..8eed898 100644 --- a/src/biz/SegmentCard.tsx +++ b/src/biz/SegmentCard.tsx @@ -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) diff --git a/src/biz/SegmentItem.tsx b/src/biz/SegmentItem.tsx index d261281..80e2956 100644 --- a/src/biz/SegmentItem.tsx +++ b/src/biz/SegmentItem.tsx @@ -18,7 +18,7 @@ const SegmentItem = (props: { const ref = useRef() 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(() => { diff --git a/src/redux/envReducer.ts b/src/redux/envReducer.ts index 2ca7f10..00e9532 100644 --- a/src/redux/envReducer.ts +++ b/src/redux/envReducer.ts @@ -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) => { + setTempData: (state, action: PayloadAction>) => { state.tempData = { ...state.tempData, ...action.payload, @@ -102,9 +101,6 @@ export const slice = createSlice({ setFoldAll: (state, action: PayloadAction) => { state.foldAll = action.payload }, - setCompact: (state, action: PayloadAction) => { - state.compact = action.payload - }, setPage: (state, action: PayloadAction) => { state.page = action.payload }, @@ -275,7 +271,6 @@ export const { setCurOffsetTop, setFloatKeyPointsSegIdx, setFoldAll, - setCompact, setSegmentFold, setSummaryContent, setSummaryStatus, diff --git a/src/typings.d.ts b/src/typings.d.ts index 06e4808..d3980ba 100644 --- a/src/typings.d.ts +++ b/src/typings.d.ts @@ -27,6 +27,7 @@ interface EnvData { interface TempData { curSummaryType: SummaryType + compact?: boolean // 是否紧凑视图 } interface TaskDef {