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'