You've already forked bilibili-subtitle
章节模式配置项
This commit is contained in:
@@ -160,8 +160,8 @@ const useSubtitleService = () => {
|
|||||||
|
|
||||||
segments = []
|
segments = []
|
||||||
|
|
||||||
// 如果有章节信息,按章节分割
|
// 如果启用章节模式且有章节信息,按章节分割
|
||||||
if (chapters && chapters.length > 0) {
|
if ((envData.chapterMode ?? true) && chapters && chapters.length > 0) {
|
||||||
for (let chapterIdx = 0; chapterIdx < chapters.length; chapterIdx++) {
|
for (let chapterIdx = 0; chapterIdx < chapters.length; chapterIdx++) {
|
||||||
const chapter = chapters[chapterIdx]
|
const chapter = chapters[chapterIdx]
|
||||||
const nextChapter = chapters[chapterIdx + 1]
|
const nextChapter = chapters[chapterIdx + 1]
|
||||||
|
@@ -77,6 +77,7 @@ const OptionsPage = () => {
|
|||||||
const {value: askEnabledValue, onChange: setAskEnabledValue} = useEventChecked(envData.askEnabled??ASK_ENABLED_DEFAULT)
|
const {value: askEnabledValue, onChange: setAskEnabledValue} = useEventChecked(envData.askEnabled??ASK_ENABLED_DEFAULT)
|
||||||
const {value: cnSearchEnabledValue, onChange: setCnSearchEnabledValue} = useEventChecked(envData.cnSearchEnabled)
|
const {value: cnSearchEnabledValue, onChange: setCnSearchEnabledValue} = useEventChecked(envData.cnSearchEnabled)
|
||||||
const {value: summarizeFloatValue, onChange: setSummarizeFloatValue} = useEventChecked(envData.summarizeFloat)
|
const {value: summarizeFloatValue, onChange: setSummarizeFloatValue} = useEventChecked(envData.summarizeFloat)
|
||||||
|
const {value: chapterModeValue, onChange: setChapterModeValue} = useEventChecked(envData.chapterMode ?? true)
|
||||||
const [apiKeyValue, { onChange: onChangeApiKeyValue }] = useEventTarget({initialValue: envData.apiKey??''})
|
const [apiKeyValue, { onChange: onChangeApiKeyValue }] = useEventTarget({initialValue: envData.apiKey??''})
|
||||||
const [serverUrlValue, setServerUrlValue] = useState(envData.serverUrl)
|
const [serverUrlValue, setServerUrlValue] = useState(envData.serverUrl)
|
||||||
const [languageValue, { onChange: onChangeLanguageValue }] = useEventTarget({initialValue: envData.language??LANGUAGE_DEFAULT})
|
const [languageValue, { onChange: onChangeLanguageValue }] = useEventTarget({initialValue: envData.language??LANGUAGE_DEFAULT})
|
||||||
@@ -139,6 +140,7 @@ const OptionsPage = () => {
|
|||||||
searchEnabled: searchEnabledValue,
|
searchEnabled: searchEnabledValue,
|
||||||
cnSearchEnabled: cnSearchEnabledValue,
|
cnSearchEnabled: cnSearchEnabledValue,
|
||||||
askEnabled: askEnabledValue,
|
askEnabled: askEnabledValue,
|
||||||
|
chapterMode: chapterModeValue,
|
||||||
}))
|
}))
|
||||||
toast.success('保存成功')
|
toast.success('保存成功')
|
||||||
sendExtension(null, 'CLOSE_SIDE_PANEL')
|
sendExtension(null, 'CLOSE_SIDE_PANEL')
|
||||||
@@ -146,7 +148,7 @@ const OptionsPage = () => {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
window.close()
|
window.close()
|
||||||
}, 3000)
|
}, 3000)
|
||||||
}, [dispatch, sendExtension, sidePanelValue, autoInsertValue, autoExpandValue, apiKeyValue, serverUrlValue, modelValue, customModelValue, customModelTokensValue, translateEnableValue, languageValue, hideOnDisableAutoTranslateValue, themeValue, transDisplayValue, summarizeEnableValue, summarizeFloatValue, summarizeLanguageValue, wordsValue, fetchAmountValue, fontSizeValue, promptsValue, searchEnabledValue, cnSearchEnabledValue, askEnabledValue])
|
}, [dispatch, sendExtension, sidePanelValue, autoInsertValue, autoExpandValue, apiKeyValue, serverUrlValue, modelValue, customModelValue, customModelTokensValue, translateEnableValue, languageValue, hideOnDisableAutoTranslateValue, themeValue, transDisplayValue, summarizeEnableValue, summarizeFloatValue, summarizeLanguageValue, wordsValue, fetchAmountValue, fontSizeValue, promptsValue, searchEnabledValue, cnSearchEnabledValue, askEnabledValue, chapterModeValue])
|
||||||
|
|
||||||
const onCancel = useCallback(() => {
|
const onCancel = useCallback(() => {
|
||||||
window.close()
|
window.close()
|
||||||
@@ -207,6 +209,10 @@ const OptionsPage = () => {
|
|||||||
<input id='autoExpand' type='checkbox' className='toggle toggle-primary' checked={autoExpandValue}
|
<input id='autoExpand' type='checkbox' className='toggle toggle-primary' checked={autoExpandValue}
|
||||||
onChange={setAutoExpandValue}/>
|
onChange={setAutoExpandValue}/>
|
||||||
</FormItem>}
|
</FormItem>}
|
||||||
|
<FormItem title='章节模式' htmlFor='chapterMode' tip='如果视频包含章节,则会按章节分割(会导致总结只能按章节来)'>
|
||||||
|
<input id='chapterMode' type='checkbox' className='toggle toggle-primary' checked={chapterModeValue}
|
||||||
|
onChange={setChapterModeValue}/>
|
||||||
|
</FormItem>
|
||||||
<FormItem title='主题'>
|
<FormItem title='主题'>
|
||||||
<div className="btn-group">
|
<div className="btn-group">
|
||||||
<button onClick={onSelTheme1} className={classNames('btn btn-sm no-animation', (!themeValue || themeValue === 'system')?'btn-active':'')}>系统</button>
|
<button onClick={onSelTheme1} className={classNames('btn btn-sm no-animation', (!themeValue || themeValue === 'system')?'btn-active':'')}>系统</button>
|
||||||
|
3
src/typings.d.ts
vendored
3
src/typings.d.ts
vendored
@@ -30,6 +30,9 @@ interface EnvData {
|
|||||||
theme?: 'system' | 'light' | 'dark'
|
theme?: 'system' | 'light' | 'dark'
|
||||||
fontSize?: 'normal' | 'large'
|
fontSize?: 'normal' | 'large'
|
||||||
|
|
||||||
|
// chapter
|
||||||
|
chapterMode?: boolean // 是否启用章节模式,undefined/null/true表示启用,false表示禁用
|
||||||
|
|
||||||
// search
|
// search
|
||||||
searchEnabled?: boolean
|
searchEnabled?: boolean
|
||||||
cnSearchEnabled?: boolean
|
cnSearchEnabled?: boolean
|
||||||
|
Reference in New Issue
Block a user