diff --git a/manifest.json b/manifest.json index da83e1a..5547ffc 100644 --- a/manifest.json +++ b/manifest.json @@ -6,6 +6,10 @@ "permissions": [ "storage" ], + "host_permissions": [ + "http://localhost/*", + "http://127.0.0.1/*" + ], "background": { "service_worker": "src/chrome/background.ts" }, diff --git a/src/biz/Settings.tsx b/src/biz/Settings.tsx index f34da70..78dd48f 100644 --- a/src/biz/Settings.tsx +++ b/src/biz/Settings.tsx @@ -3,6 +3,8 @@ import {setEnvData, setPage} from '../redux/envReducer' import {useAppDispatch, useAppSelector} from '../hooks/redux' import { ASK_ENABLED_DEFAULT, + CUSTOM_MODEL_TOKENS, + DEFAULT_SERVER_URL_OPENAI, GEMINI_TOKENS, HEADER_HEIGHT, LANGUAGE_DEFAULT, @@ -69,6 +71,8 @@ const Settings = () => { const [geminiApiKeyValue, { onChange: onChangeGeminiApiKeyValue }] = useEventTarget({initialValue: envData.geminiApiKey??''}) const [languageValue, { onChange: onChangeLanguageValue }] = useEventTarget({initialValue: envData.language??LANGUAGE_DEFAULT}) const [modelValue, { onChange: onChangeModelValue }] = useEventTarget({initialValue: envData.model??MODEL_DEFAULT}) + const [customModelValue, { onChange: onChangeCustomModelValue }] = useEventTarget({initialValue: envData.customModel}) + const [customModelTokensValue, setCustomModelTokensValue] = useState(envData.customModelTokens) const [summarizeLanguageValue, { onChange: onChangeSummarizeLanguageValue }] = useEventTarget({initialValue: envData.summarizeLanguage??SUMMARIZE_LANGUAGE_DEFAULT}) const [hideOnDisableAutoTranslateValue, setHideOnDisableAutoTranslateValue] = useState(envData.hideOnDisableAutoTranslate) const [themeValue, setThemeValue] = useState(envData.theme) @@ -114,6 +118,8 @@ const Settings = () => { apiKey: apiKeyValue, serverUrl: serverUrlValue, model: modelValue, + customModel: customModelValue, + customModelTokens: customModelTokensValue, geminiApiKey: geminiApiKeyValue, translateEnable: translateEnableValue, language: languageValue, @@ -133,7 +139,7 @@ const Settings = () => { })) dispatch(setPage(PAGE_MAIN)) toast.success('保存成功') - }, [dispatch, autoExpandValue, 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, customModelValue, customModelTokensValue, geminiApiKeyValue, translateEnableValue, languageValue, hideOnDisableAutoTranslateValue, themeValue, transDisplayValue, summarizeEnableValue, summarizeFloatValue, summarizeLanguageValue, wordsValue, fetchAmountValue, fontSizeValue, promptsValue, searchEnabledValue, cnSearchEnabledValue, askEnabledValue]) const onCancel = useCallback(() => { dispatch(setPage(PAGE_MAIN)) @@ -224,7 +230,7 @@ const Settings = () => { setServerUrlValue(e.target.value)}/>
@@ -233,7 +239,7 @@ const Settings = () => {
官方网址:点击访问
服务器地址: setServerUrlValue('https://api.openai.com')} + onClick={() => setServerUrlValue(DEFAULT_SERVER_URL_OPENAI)} rel='noreferrer'>点击设置
【第三方代理】
代理网址: { {MODELS.map(model => )} -
- {promptsFold ? '点击查看提示词' : '点击折叠提示词'} -
- {!promptsFold &&
- {PROMPT_TYPES.map((item, idx) => -
{item.name}
-
{ - setPromptsValue({ - ...promptsValue, - // @ts-expect-error - [item.type]: PROMPT_DEFAULTS[item.type] ?? '' - }) - }}>点击填充默认 -
-
} htmlFor={`prompt-${item.type}`}> -