mirror of
https://github.com/FranP-code/ChatGPT.git
synced 2025-10-13 00:13:25 +00:00
chore: window
This commit is contained in:
30
src/components/SwitchOrigin/index.tsx
vendored
Normal file
30
src/components/SwitchOrigin/index.tsx
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
import { FC } from 'react';
|
||||
import { Form, Select, Tag } from 'antd';
|
||||
|
||||
import useJson from '@/hooks/useJson';
|
||||
import { DISABLE_AUTO_COMPLETE, CHAT_CONF_JSON, CHAT_AWESOME_JSON } from '@/utils';
|
||||
|
||||
interface SwitchOriginProps {
|
||||
name: string;
|
||||
}
|
||||
|
||||
const SwitchOrigin: FC<SwitchOriginProps> = ({ name }) => {
|
||||
const { json: list = [] } = useJson<any[]>(CHAT_AWESOME_JSON);
|
||||
|
||||
return (
|
||||
<Form.Item
|
||||
label={<span>Switch Origin ({name === 'origin' ? 'Main' : 'SystemTray'})</span>}
|
||||
name={name}
|
||||
>
|
||||
<Select showSearch {...DISABLE_AUTO_COMPLETE} optionLabelProp="url">
|
||||
{[{ title: 'ChatGPT', url: 'https://chat.openai.com' }, ...list].map((i) => (
|
||||
<Select.Option key={i.url} label={i.title} value={i.url}>
|
||||
<Tag color="geekblue">{i.title}</Tag> {i.url}
|
||||
</Select.Option>
|
||||
))}
|
||||
</Select>
|
||||
</Form.Item>
|
||||
);
|
||||
};
|
||||
|
||||
export default SwitchOrigin;
|
||||
2
src/view/awesome/config.tsx
vendored
2
src/view/awesome/config.tsx
vendored
@@ -1,4 +1,5 @@
|
||||
import { Tag, Space, Popconfirm, Switch } from 'antd';
|
||||
import { open } from '@tauri-apps/api/shell';
|
||||
|
||||
export const awesomeColumns = () => [
|
||||
{
|
||||
@@ -13,6 +14,7 @@ export const awesomeColumns = () => [
|
||||
dataIndex: 'url',
|
||||
key: 'url',
|
||||
width: 200,
|
||||
render: (v: string) => <a onClick={() => open(v)}>{v}</a>,
|
||||
},
|
||||
// {
|
||||
// title: 'Icon',
|
||||
|
||||
5
src/view/settings/General.tsx
vendored
5
src/view/settings/General.tsx
vendored
@@ -68,6 +68,11 @@ export default function General() {
|
||||
<Switch />
|
||||
</Form.Item>
|
||||
)}
|
||||
{platformInfo === 'darwin' && (
|
||||
<Form.Item label="Hide Dock Icon" name="hide_dock_icon" valuePropName="checked">
|
||||
<Switch />
|
||||
</Form.Item>
|
||||
)}
|
||||
<Form.Item label="Theme" name="theme">
|
||||
<Radio.Group>
|
||||
<Radio value="Light">Light</Radio>
|
||||
|
||||
26
src/view/settings/MainWindow.tsx
vendored
26
src/view/settings/MainWindow.tsx
vendored
@@ -1,22 +1,9 @@
|
||||
import { useState } from 'react';
|
||||
import { Form, Switch, Input, Tooltip } from 'antd';
|
||||
import { QuestionCircleOutlined } from '@ant-design/icons';
|
||||
import { invoke } from '@tauri-apps/api';
|
||||
|
||||
import useInit from '@/hooks/useInit';
|
||||
import SwitchOrigin from '@/components/SwitchOrigin';
|
||||
import { DISABLE_AUTO_COMPLETE } from '@/utils';
|
||||
|
||||
const OriginLabel = ({ url }: { url: string }) => {
|
||||
return (
|
||||
<span>
|
||||
Switch Origin{' '}
|
||||
<Tooltip title={`Default: ${url}`}>
|
||||
<QuestionCircleOutlined style={{ color: '#1677ff' }} />
|
||||
</Tooltip>
|
||||
</span>
|
||||
);
|
||||
};
|
||||
|
||||
const PopupSearchLabel = () => {
|
||||
return (
|
||||
<span>
|
||||
@@ -44,21 +31,12 @@ const PopupSearchLabel = () => {
|
||||
};
|
||||
|
||||
export default function General() {
|
||||
const [chatConf, setChatConf] = useState<any>(null);
|
||||
|
||||
useInit(async () => {
|
||||
const chatData = await invoke('get_chat_conf');
|
||||
setChatConf(chatData);
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
<Form.Item label={<PopupSearchLabel />} name="popup_search" valuePropName="checked">
|
||||
<Switch />
|
||||
</Form.Item>
|
||||
<Form.Item label={<OriginLabel url={chatConf?.default_origin} />} name="origin">
|
||||
<Input placeholder="https://chat.openai.com" {...DISABLE_AUTO_COMPLETE} />
|
||||
</Form.Item>
|
||||
<SwitchOrigin name="origin" />
|
||||
<Form.Item label="User Agent (Main)" name="ua_window">
|
||||
<Input.TextArea
|
||||
autoSize={{ minRows: 4, maxRows: 4 }}
|
||||
|
||||
2
src/view/settings/TrayWindow.tsx
vendored
2
src/view/settings/TrayWindow.tsx
vendored
@@ -1,6 +1,7 @@
|
||||
import { Form, Switch, Input } from 'antd';
|
||||
|
||||
import { DISABLE_AUTO_COMPLETE } from '@/utils';
|
||||
import SwitchOrigin from '@/components/SwitchOrigin';
|
||||
|
||||
export default function General() {
|
||||
return (
|
||||
@@ -8,6 +9,7 @@ export default function General() {
|
||||
<Form.Item label="Enable SystemTray" name="tray" valuePropName="checked">
|
||||
<Switch />
|
||||
</Form.Item>
|
||||
<SwitchOrigin name="tray_origin" />
|
||||
<Form.Item label="User Agent (SystemTray)" name="ua_tray">
|
||||
<Input.TextArea
|
||||
autoSize={{ minRows: 4, maxRows: 4 }}
|
||||
|
||||
4
src/view/settings/index.tsx
vendored
4
src/view/settings/index.tsx
vendored
@@ -61,8 +61,8 @@ export default function Settings() {
|
||||
form={form}
|
||||
style={{ maxWidth: 500 }}
|
||||
onFinish={onFinish}
|
||||
labelCol={{ span: 8 }}
|
||||
wrapperCol={{ span: 15, offset: 1 }}
|
||||
labelCol={{ span: 10 }}
|
||||
wrapperCol={{ span: 13, offset: 1 }}
|
||||
>
|
||||
<Tabs
|
||||
items={[
|
||||
|
||||
Reference in New Issue
Block a user