chore: window

This commit is contained in:
lencx
2023-01-23 00:36:39 +08:00
parent f1ec7c6495
commit 84a29d7cda
11 changed files with 96 additions and 65 deletions

30
src/components/SwitchOrigin/index.tsx vendored Normal file
View 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;

View File

@@ -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',

View File

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

View File

@@ -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 }}

View File

@@ -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 }}

View File

@@ -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={[