Revert "去除是否自动展开配置"

This reverts commit e6db6747
This commit is contained in:
IndieKKY
2024-03-19 21:39:16 +08:00
parent 2383603b39
commit 9b2d620cdf
5 changed files with 20 additions and 18 deletions

View File

@@ -313,7 +313,7 @@ const Body = () => {
{/* onClick={onCopy}>点击复制生成的{SUMMARIZE_TYPES[curSummaryType].name}<RiFileCopy2Line/> */}
{/* </button>} */}
{/* </div> */}
{((infos == null) || infos.length === 0) && <div className='flex flex-col'>
<div className='flex flex-col'>
<div className='flex flex-col items-center text-center py-2 mx-4'>
<div className='font-semibold text-accent flex items-center gap-1'><img src='/bibigpt.png'
alt='BibiGPT logo'
@@ -349,7 +349,8 @@ const Body = () => {
e.preventDefault()
openUrl('https://microsoftedge.microsoft.com/addons/detail/galeejdehabppfgooagmkclpppnbccpc')
}} className='link text-sm text-accent'>Edge商店</a>
<a title='Crx搜搜(国内可访问)' href='https://www.crxsoso.com/webstore/detail/fiaeclpicddpifeflpmlgmbjgaedladf'
<a title='Crx搜搜(国内可访问)'
href='https://www.crxsoso.com/webstore/detail/fiaeclpicddpifeflpmlgmbjgaedladf'
onClick={(e) => {
e.preventDefault()
openUrl('https://www.crxsoso.com/webstore/detail/fiaeclpicddpifeflpmlgmbjgaedladf')
@@ -376,7 +377,7 @@ const Body = () => {
}} className='link text-sm text-accent'>Crx搜搜(访)</a>
</div>
</div>
</div>}
</div>
</div>
{/* recommend */}
@@ -417,7 +418,8 @@ const Body = () => {
}}><img src='/openai-up.ico'
alt='Openai Up logo'
className='w-8 h-8'/>Openai代理</a>
<span className='text-sm desc flex items-center'>6<FaGripfire className='text-amber-600'/></span>
<span className='text-sm desc flex items-center'>6<FaGripfire
className='text-amber-600'/></span>
</div>}
</div>
</div>

View File

@@ -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 = () => {
}}>
<div className="flex flex-col gap-3 p-2">
<Section title='通用配置'>
{/* <FormItem title='自动展开' htmlFor='autoExpand' tip='是否视频有字幕时自动展开字幕列表'> */}
{/* <input id='autoExpand' type='checkbox' className='toggle toggle-primary' checked={autoExpandValue} */}
{/* onChange={setAutoExpandValue}/> */}
{/* </FormItem> */}
<FormItem title='自动展开' htmlFor='autoExpand' tip='是否视频有字幕时自动展开字幕列表'>
<input id='autoExpand' type='checkbox' className='toggle toggle-primary' checked={autoExpandValue}
onChange={setAutoExpandValue}/>
</FormItem>
<FormItem title='主题'>
<div className="btn-group">
<button onClick={onSelTheme1} className={classNames('btn btn-xs no-animation', (!themeValue || themeValue === 'system')?'btn-active':'')}></button>

View File

@@ -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) {

View File

@@ -54,7 +54,7 @@ const initialState: EnvState = {
serverUrl: SERVER_URL_OPENAI,
translateEnable: true,
summarizeEnable: true,
// autoExpand: true,
autoExpand: true,
theme: 'light',
searchEnabled: true,
},

2
src/typings.d.ts vendored
View File

@@ -1,5 +1,5 @@
interface EnvData {
// autoExpand?: boolean
autoExpand?: boolean
flagDot?: boolean
aiType?: 'openai' | 'gemini'