diff --git a/app/src/renderer/src/pages/Setting/index.tsx b/app/src/renderer/src/pages/Setting/index.tsx index 2fda3ff..c049efc 100644 --- a/app/src/renderer/src/pages/Setting/index.tsx +++ b/app/src/renderer/src/pages/Setting/index.tsx @@ -1,169 +1,170 @@ import { Button, Form, Input, Select, Space, message } from 'antd'; import styles from './styles.module.scss' -import { useEffect, useState } from 'react'; +import { useState } from 'react'; import { useLoaderData } from 'react-router-dom'; import { localServerBaseUrl } from '@renderer/config'; -export function Setting(){ +export function Setting() { const [form] = Form.useForm(); const config = useLoaderData() as ConfigDataType form.setFieldsValue(config); const { Option } = Select; const tailLayout = { - wrapperCol: { offset: 6, span: 16 }, + wrapperCol: { offset: 6, span: 16 }, + }; + const [keys, setKeys] = useState([]) + const onModelChange = (value: string) => { + switch (value) { + case 'openai': + form.setFieldsValue({ model: 'gpt-4-turbo', base_url: "https://api.openai.com/v1" }); + break; + case 'ollama': + form.setFieldsValue({ model: 'ollama/codeqwen:latest', api_base: "http://localhost:11434" }); + break; + default: + } }; - const [keys, setKeys] = useState([]) - const onModelChange = (value: string) => { - switch (value) { - case 'openai': - form.setFieldsValue({ model: 'gpt-4-turbo', base_url:"https://api.openai.com/v1"}); - break; - case 'ollama': - form.setFieldsValue({ model: 'ollama/llama2',api_base: "http://localhost:11434" }); - break; - default: - } - }; + const onFinish = async (values: any) => { + // 注册快捷键 + window.api.shortCut() + await window.api.sql(`update config set content=@content where id = 1`, + 'update', + { + content: JSON.stringify(values) + }) + // window.close(); + }; - const onFinish = async (values: any) => { - // 注册快捷键 - window.api.shortCut() - await window.api.sql(`update config set content=@content where id = 1`, - 'update', - { - content: JSON.stringify(values) - }) - // window.close(); - }; - - const onClose = () => { - window.close() - }; + const onClose = () => { + window.close() + }; - return ( -
-

Setting

-
-
-
快捷键定义
- - { - if (e.metaKey || e.ctrlKey || e.altKey) { - const code = e.code.replace(/Left|Right|Key|Digit/, '') - if (keys.includes(code)) return - keys.push(code) - setKeys(keys) - // 如果以数字或字母或者空格结尾 - if (code.match(/^(\w|\s)$/gi)) { - e.currentTarget.value = keys.join('+') - form.setFieldsValue({shortcut: e.currentTarget.value}) - setKeys([]) - } - } - }} - /> - -
-
- -
-
大模型配置信息
- + return ( +
+

Setting

+ +
+
快捷键定义
+ + { + if (e.metaKey || e.ctrlKey || e.altKey) { + const code = e.code.replace(/Left|Right|Key|Digit/, '') + if (keys.includes(code)) return + keys.push(code) + setKeys(keys) + // 如果以数字或字母或者空格结尾 + if (code.match(/^(\w|\s)$/gi)) { + e.currentTarget.value = keys.join('+') + form.setFieldsValue({ shortcut: e.currentTarget.value }) + setKeys([]) + } + } + }} + /> + +
+
+ +
+
大模型配置信息
+ +
+ + + + + + + + + prevValues.format !== currentValues.format} + > + {({ getFieldValue }) => + getFieldValue('format') === 'openai' ? ( +
+ + + + + + +
+ ) : null + } +
+ + prevValues.format !== currentValues.format} + > + {({ getFieldValue }) => + getFieldValue('format') === 'ollama' ? ( + + + + ) : null + } + +
+
+ + + + + + + +
+
- - - - - - - - - prevValues.format !== currentValues.format} - > - {({ getFieldValue }) => - getFieldValue('format') === 'openai' ? ( -
- - - - - - -
- ) : null - } -
- - prevValues.format !== currentValues.format} - > - {({ getFieldValue }) => - getFieldValue('format') === 'ollama' ? ( - - - - ) : null - } - -
-
- - - - - - - -
- -
- ); + ); };