From 9b2d620cdf7d49e0f1411aaacae02238a7c1976a Mon Sep 17 00:00:00 2001 From: IndieKKY Date: Tue, 19 Mar 2024 21:39:16 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"=E5=8E=BB=E9=99=A4=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=B1=95=E5=BC=80=E9=85=8D=E7=BD=AE"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit e6db6747 --- src/biz/Body.tsx | 10 ++++++---- src/biz/Settings.tsx | 14 +++++++------- src/hooks/useSubtitleService.ts | 10 +++++----- src/redux/envReducer.ts | 2 +- src/typings.d.ts | 2 +- 5 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/biz/Body.tsx b/src/biz/Body.tsx index c41051f..6743ed8 100644 --- a/src/biz/Body.tsx +++ b/src/biz/Body.tsx @@ -313,7 +313,7 @@ const Body = () => { {/* onClick={onCopy}>点击复制生成的{SUMMARIZE_TYPES[curSummaryType].name} */} {/* } */} {/* */} - {((infos == null) || infos.length === 0) &&
+
BibiGPT logo { e.preventDefault() openUrl('https://microsoftedge.microsoft.com/addons/detail/galeejdehabppfgooagmkclpppnbccpc') }} className='link text-sm text-accent'>Edge商店 - { e.preventDefault() openUrl('https://www.crxsoso.com/webstore/detail/fiaeclpicddpifeflpmlgmbjgaedladf') @@ -376,7 +377,7 @@ const Body = () => { }} className='link text-sm text-accent'>Crx搜搜(国内可访问)
-
} +
{/* recommend */} @@ -417,7 +418,8 @@ const Body = () => { }}>Openai Up logoOpenai代理 - 目前价格不到官方的6折 + 目前价格不到官方的6折 } diff --git a/src/biz/Settings.tsx b/src/biz/Settings.tsx index dd662cf..f34da70 100644 --- a/src/biz/Settings.tsx +++ b/src/biz/Settings.tsx @@ -56,7 +56,7 @@ const FormItem = (props: { const Settings = () => { const dispatch = useAppDispatch() const envData = useAppSelector(state => state.env.envData) - // const {value: autoExpandValue, onChange: setAutoExpandValue} = useEventChecked(envData.autoExpand) + const {value: autoExpandValue, onChange: setAutoExpandValue} = useEventChecked(envData.autoExpand) // const {value: autoScrollValue, onChange: setAutoScrollValue} = useEventChecked(envData.autoScroll) const {value: translateEnableValue, onChange: setTranslateEnableValue} = useEventChecked(envData.translateEnable) const {value: summarizeEnableValue, onChange: setSummarizeEnableValue} = useEventChecked(envData.summarizeEnable) @@ -109,7 +109,7 @@ const Settings = () => { const onSave = useCallback(() => { dispatch(setEnvData({ - // autoExpand: autoExpandValue, + autoExpand: autoExpandValue, aiType: aiTypeValue, apiKey: apiKeyValue, serverUrl: serverUrlValue, @@ -133,7 +133,7 @@ const Settings = () => { })) dispatch(setPage(PAGE_MAIN)) toast.success('保存成功') - }, [dispatch, aiTypeValue, apiKeyValue, serverUrlValue, modelValue, geminiApiKeyValue, translateEnableValue, languageValue, hideOnDisableAutoTranslateValue, themeValue, transDisplayValue, summarizeEnableValue, summarizeFloatValue, summarizeLanguageValue, wordsValue, fetchAmountValue, fontSizeValue, promptsValue, searchEnabledValue, cnSearchEnabledValue, askEnabledValue]) + }, [dispatch, autoExpandValue, aiTypeValue, apiKeyValue, serverUrlValue, modelValue, geminiApiKeyValue, translateEnableValue, languageValue, hideOnDisableAutoTranslateValue, themeValue, transDisplayValue, summarizeEnableValue, summarizeFloatValue, summarizeLanguageValue, wordsValue, fetchAmountValue, fontSizeValue, promptsValue, searchEnabledValue, cnSearchEnabledValue, askEnabledValue]) const onCancel = useCallback(() => { dispatch(setPage(PAGE_MAIN)) @@ -192,10 +192,10 @@ const Settings = () => { }}>
- {/* */} - {/* */} - {/* */} + + +
diff --git a/src/hooks/useSubtitleService.ts b/src/hooks/useSubtitleService.ts index 1afbae3..e4bd42d 100644 --- a/src/hooks/useSubtitleService.ts +++ b/src/hooks/useSubtitleService.ts @@ -100,20 +100,20 @@ const useSubtitleService = () => { // 有数据时自动展开 useEffect(() => { - if (infos != null) { + if ((data != null) && data.body.length > 0) { eventBus.emit({ type: EVENT_EXPAND }) } - }, [eventBus, infos]) + }, [data, eventBus, infos]) - // 当前未展示 & 未折叠 & 有列表 => 展示第一个 + // 当前未展示 & (未折叠 | 自动展开) & 有列表 => 展示第一个 useEffect(() => { - if (!curInfo && !fold && (infos != null) && infos.length > 0) { + if (!curInfo && (!fold || (envReady && envData.autoExpand)) && (infos != null) && infos.length > 0) { dispatch(setCurInfo(infos[0])) dispatch(setCurFetched(false)) } - }, [curInfo, dispatch, envReady, fold, infos]) + }, [curInfo, dispatch, envData.autoExpand, envReady, fold, infos]) // 获取 useEffect(() => { if (curInfo && !curFetched) { diff --git a/src/redux/envReducer.ts b/src/redux/envReducer.ts index d54f652..d17096b 100644 --- a/src/redux/envReducer.ts +++ b/src/redux/envReducer.ts @@ -54,7 +54,7 @@ const initialState: EnvState = { serverUrl: SERVER_URL_OPENAI, translateEnable: true, summarizeEnable: true, - // autoExpand: true, + autoExpand: true, theme: 'light', searchEnabled: true, }, diff --git a/src/typings.d.ts b/src/typings.d.ts index 9fa6505..58d5888 100644 --- a/src/typings.d.ts +++ b/src/typings.d.ts @@ -1,5 +1,5 @@ interface EnvData { - // autoExpand?: boolean + autoExpand?: boolean flagDot?: boolean aiType?: 'openai' | 'gemini'