mirror of
https://github.com/FranP-code/ChatGPT.git
synced 2025-10-13 00:13:25 +00:00
chore: add pretty
This commit is contained in:
12
src/view/awesome/Form.tsx
vendored
12
src/view/awesome/Form.tsx
vendored
@@ -6,7 +6,7 @@ import Tags from '@comps/Tags';
|
||||
import { DISABLE_AUTO_COMPLETE } from '@/utils';
|
||||
|
||||
interface AwesomeFormProps {
|
||||
record?: Record<string|symbol, any> | null;
|
||||
record?: Record<string | symbol, any> | null;
|
||||
}
|
||||
|
||||
const initFormValue = {
|
||||
@@ -28,11 +28,7 @@ const AwesomeForm: ForwardRefRenderFunction<FormProps, AwesomeFormProps> = ({ re
|
||||
}, [record]);
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={form}
|
||||
labelCol={{ span: 4 }}
|
||||
initialValues={initFormValue}
|
||||
>
|
||||
<Form form={form} labelCol={{ span: 4 }} initialValues={initFormValue}>
|
||||
<Form.Item
|
||||
label="Title"
|
||||
name="title"
|
||||
@@ -57,7 +53,7 @@ const AwesomeForm: ForwardRefRenderFunction<FormProps, AwesomeFormProps> = ({ re
|
||||
<Switch />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
)
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
export default forwardRef(AwesomeForm);
|
||||
|
||||
14
src/view/awesome/config.tsx
vendored
14
src/view/awesome/config.tsx
vendored
@@ -34,7 +34,7 @@ export const awesomeColumns = () => [
|
||||
dataIndex: 'category',
|
||||
key: 'category',
|
||||
width: 120,
|
||||
render: (v: string) => <Tag color="geekblue">{v}</Tag>
|
||||
render: (v: string) => <Tag color="geekblue">{v}</Tag>,
|
||||
},
|
||||
{
|
||||
title: 'Tags',
|
||||
@@ -42,7 +42,11 @@ export const awesomeColumns = () => [
|
||||
key: 'tags',
|
||||
width: 150,
|
||||
render: (v: string[]) => (
|
||||
<span className="chat-tags">{v?.map(i => <Tag key={i}>{i}</Tag>)}</span>
|
||||
<span className="chat-tags">
|
||||
{v?.map((i) => (
|
||||
<Tag key={i}>{i}</Tag>
|
||||
))}
|
||||
</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
@@ -62,7 +66,7 @@ export const awesomeColumns = () => [
|
||||
<a>Delete</a>
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
)
|
||||
}
|
||||
}
|
||||
);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
54
src/view/awesome/index.tsx
vendored
54
src/view/awesome/index.tsx
vendored
@@ -34,7 +34,8 @@ export default function Awesome() {
|
||||
updateJson(data);
|
||||
opInfo.resetRecord();
|
||||
}
|
||||
}, [opInfo.opType, formRef]);
|
||||
}, [opInfo.opType,
|
||||
formRef]);
|
||||
|
||||
const hide = () => {
|
||||
setVisible(false);
|
||||
@@ -46,45 +47,46 @@ export default function Awesome() {
|
||||
const data = opReplace(opInfo?.opRecord?.[opSafeKey], opInfo?.opRecord);
|
||||
updateJson(data);
|
||||
}
|
||||
}, [opInfo.opTime])
|
||||
}, [opInfo.opTime]);
|
||||
|
||||
const handleDelete = () => {
|
||||
|
||||
};
|
||||
const handleDelete = () => {};
|
||||
|
||||
const handleOk = () => {
|
||||
formRef.current?.form?.validateFields()
|
||||
.then(async (vals: Record<string, any>) => {
|
||||
if (opInfo.opType === 'new') {
|
||||
const data = opAdd(vals);
|
||||
await updateJson(data);
|
||||
opInit(data);
|
||||
message.success('Data added successfully');
|
||||
}
|
||||
if (opInfo.opType === 'edit') {
|
||||
const data = opReplace(opInfo?.opRecord?.[opSafeKey], vals);
|
||||
await updateJson(data);
|
||||
message.success('Data updated successfully');
|
||||
}
|
||||
hide();
|
||||
})
|
||||
formRef.current?.form?.validateFields().then(async (vals: Record<string, any>) => {
|
||||
if (opInfo.opType === 'new') {
|
||||
const data = opAdd(vals);
|
||||
await updateJson(data);
|
||||
opInit(data);
|
||||
message.success('Data added successfully');
|
||||
}
|
||||
if (opInfo.opType === 'edit') {
|
||||
const data = opReplace(opInfo?.opRecord?.[opSafeKey], vals);
|
||||
await updateJson(data);
|
||||
message.success('Data updated successfully');
|
||||
}
|
||||
hide();
|
||||
});
|
||||
};
|
||||
|
||||
const handleEnable = (isEnable: boolean) => {
|
||||
const data = opReplaceItems(selectedRowIDs, { enable: isEnable })
|
||||
const data = opReplaceItems(selectedRowIDs, { enable: isEnable });
|
||||
updateJson(data);
|
||||
};
|
||||
|
||||
const modalTitle = `${({ new: 'Create', edit: 'Edit' })[opInfo.opType]} URL`;
|
||||
const modalTitle = `${{ new: 'Create', edit: 'Edit' }[opInfo.opType]} URL`;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="chat-table-btns">
|
||||
<Button className="chat-add-btn" type="primary" onClick={opInfo.opNew}>Add URL</Button>
|
||||
<Button className="chat-add-btn" type="primary" onClick={opInfo.opNew}>
|
||||
Add URL
|
||||
</Button>
|
||||
<div>
|
||||
{selectedItems.length > 0 && (
|
||||
<>
|
||||
<Button type="primary" onClick={() => handleEnable(true)}>Enable</Button>
|
||||
<Button type="primary" onClick={() => handleEnable(true)}>
|
||||
Enable
|
||||
</Button>
|
||||
<Button onClick={() => handleEnable(false)}>Disable</Button>
|
||||
<Popconfirm
|
||||
overlayStyle={{ width: 250 }}
|
||||
@@ -121,5 +123,5 @@ export default function Awesome() {
|
||||
<AwesomeForm ref={formRef} record={opInfo?.opRecord} />
|
||||
</Modal>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
18
src/view/download/config.tsx
vendored
18
src/view/download/config.tsx
vendored
@@ -10,7 +10,7 @@ import { fmtDate, chatRoot } from '@/utils';
|
||||
const colorMap: any = {
|
||||
pdf: 'blue',
|
||||
png: 'orange',
|
||||
}
|
||||
};
|
||||
|
||||
export const downloadColumns = () => [
|
||||
{
|
||||
@@ -61,20 +61,22 @@ export const downloadColumns = () => [
|
||||
<a>Delete</a>
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
)
|
||||
}
|
||||
}
|
||||
);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
const RenderPath = ({ row }: any) => {
|
||||
const [filePath, setFilePath] = useState('');
|
||||
useInit(async () => {
|
||||
setFilePath(await getPath(row));
|
||||
})
|
||||
setFilePath(await getPath(row));
|
||||
});
|
||||
return <a onClick={() => shell.open(filePath)}>{filePath}</a>;
|
||||
};
|
||||
|
||||
export const getPath = async (row: any) => {
|
||||
const isImg = ['png'].includes(row?.ext);
|
||||
return await path.join(await chatRoot(), 'download', isImg ? 'img' : row.ext, row.id) + `.${row.ext}`;
|
||||
}
|
||||
return (
|
||||
(await path.join(await chatRoot(), 'download', isImg ? 'img' : row.ext, row.id)) + `.${row.ext}`
|
||||
);
|
||||
};
|
||||
|
||||
24
src/view/download/index.tsx
vendored
24
src/view/download/index.tsx
vendored
@@ -37,7 +37,12 @@ export default function Download() {
|
||||
(async () => {
|
||||
const record = opInfo?.opRecord;
|
||||
const isImg = ['png'].includes(record?.ext);
|
||||
const file = await path.join(await chatRoot(), 'download', isImg ? 'img' : record?.ext, `${record?.id}.${record?.ext}`);
|
||||
const file = await path.join(
|
||||
await chatRoot(),
|
||||
'download',
|
||||
isImg ? 'img' : record?.ext,
|
||||
`${record?.id}.${record?.ext}`,
|
||||
);
|
||||
if (opInfo.opType === 'preview') {
|
||||
const data = await fs.readBinaryFile(file);
|
||||
const sourceData = renderFile(data, record?.ext);
|
||||
@@ -55,8 +60,8 @@ export default function Download() {
|
||||
message.success('Name has been changed!');
|
||||
}
|
||||
opInfo.resetRecord();
|
||||
})()
|
||||
}, [opInfo.opType])
|
||||
})();
|
||||
}, [opInfo.opType]);
|
||||
|
||||
const handleDelete = async () => {
|
||||
if (opData?.length === selectedRows.length) {
|
||||
@@ -69,10 +74,15 @@ export default function Download() {
|
||||
|
||||
const rows = selectedRows.map(async (i) => {
|
||||
const isImg = ['png'].includes(i?.ext);
|
||||
const file = await path.join(await chatRoot(), 'download', isImg ? 'img' : i?.ext, `${i?.id}.${i?.ext}`);
|
||||
const file = await path.join(
|
||||
await chatRoot(),
|
||||
'download',
|
||||
isImg ? 'img' : i?.ext,
|
||||
`${i?.id}.${i?.ext}`,
|
||||
);
|
||||
await fs.removeFile(file);
|
||||
return file;
|
||||
})
|
||||
});
|
||||
Promise.all(rows).then(async () => {
|
||||
await handleRefresh();
|
||||
message.success('All files selected are cleared!');
|
||||
@@ -131,5 +141,5 @@ export default function Download() {
|
||||
<img style={{ maxWidth: '100%' }} src={source} />
|
||||
</Modal>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
3
src/view/markdown/index.scss
vendored
3
src/view/markdown/index.scss
vendored
@@ -1,4 +1,3 @@
|
||||
|
||||
.md-task {
|
||||
margin-bottom: 5px;
|
||||
display: flex;
|
||||
@@ -14,4 +13,4 @@
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
12
src/view/markdown/index.tsx
vendored
12
src/view/markdown/index.tsx
vendored
@@ -14,7 +14,7 @@ const modeMap: any = {
|
||||
0: 'split',
|
||||
1: 'md',
|
||||
2: 'doc',
|
||||
}
|
||||
};
|
||||
|
||||
export default function Markdown() {
|
||||
const [filePath, setFilePath] = useState('');
|
||||
@@ -26,8 +26,8 @@ export default function Markdown() {
|
||||
useInit(async () => {
|
||||
const file = await getPath(state);
|
||||
setFilePath(file);
|
||||
setSource(await fs.readTextFile(file))
|
||||
})
|
||||
setSource(await fs.readTextFile(file));
|
||||
});
|
||||
|
||||
const handleChange = async (v: string) => {
|
||||
await fs.writeTextFile(filePath, v);
|
||||
@@ -46,9 +46,7 @@ export default function Markdown() {
|
||||
<Breadcrumb.Item onClick={() => history.go(-1)}>
|
||||
<ArrowLeftOutlined />
|
||||
</Breadcrumb.Item>
|
||||
<Breadcrumb.Item onClick={() => shell.open(filePath)}>
|
||||
{filePath}
|
||||
</Breadcrumb.Item>
|
||||
<Breadcrumb.Item onClick={() => shell.open(filePath)}>{filePath}</Breadcrumb.Item>
|
||||
</Breadcrumb>
|
||||
<div>
|
||||
<SplitIcon onClick={handlePreview} style={{ fontSize: 18, color: 'rgba(0,0,0,0.5)' }} />
|
||||
@@ -57,4 +55,4 @@ export default function Markdown() {
|
||||
<MarkdownEditor value={source} onChange={handleChange} mode={modeMap[previewMode]} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
52
src/view/model/SyncCustom/Form.tsx
vendored
52
src/view/model/SyncCustom/Form.tsx
vendored
@@ -1,4 +1,10 @@
|
||||
import { useEffect, useState, ForwardRefRenderFunction, useImperativeHandle, forwardRef } from 'react';
|
||||
import {
|
||||
useEffect,
|
||||
useState,
|
||||
ForwardRefRenderFunction,
|
||||
useImperativeHandle,
|
||||
forwardRef,
|
||||
} from 'react';
|
||||
import { Form, Input, Select, Tooltip } from 'antd';
|
||||
import { v4 } from 'uuid';
|
||||
import type { FormProps } from 'antd';
|
||||
@@ -7,7 +13,7 @@ import { DISABLE_AUTO_COMPLETE, chatRoot } from '@/utils';
|
||||
import useInit from '@/hooks/useInit';
|
||||
|
||||
interface SyncFormProps {
|
||||
record?: Record<string|symbol, any> | null;
|
||||
record?: Record<string | symbol, any> | null;
|
||||
type: string;
|
||||
}
|
||||
|
||||
@@ -54,10 +60,18 @@ const SyncForm: ForwardRefRenderFunction<FormProps, SyncFormProps> = ({ record,
|
||||
|
||||
const jsonTip = (
|
||||
<Tooltip
|
||||
title={<pre>{JSON.stringify([
|
||||
{ cmd: '', act: '', prompt: '' },
|
||||
{ cmd: '', act: '', prompt: '' },
|
||||
], null, 2)}</pre>}
|
||||
title={
|
||||
<pre>
|
||||
{JSON.stringify(
|
||||
[
|
||||
{ cmd: '', act: '', prompt: '' },
|
||||
{ cmd: '', act: '', prompt: '' },
|
||||
],
|
||||
null,
|
||||
2,
|
||||
)}
|
||||
</pre>
|
||||
}
|
||||
>
|
||||
<a>JSON</a>
|
||||
</Tooltip>
|
||||
@@ -65,10 +79,12 @@ const SyncForm: ForwardRefRenderFunction<FormProps, SyncFormProps> = ({ record,
|
||||
|
||||
const csvTip = (
|
||||
<Tooltip
|
||||
title={<pre>{`"cmd","act","prompt"
|
||||
title={
|
||||
<pre>{`"cmd","act","prompt"
|
||||
"cmd","act","prompt"
|
||||
"cmd","act","prompt"
|
||||
"cmd","act","prompt"`}</pre>}
|
||||
"cmd","act","prompt"`}</pre>
|
||||
}
|
||||
>
|
||||
<a>CSV</a>
|
||||
</Tooltip>
|
||||
@@ -76,11 +92,7 @@ const SyncForm: ForwardRefRenderFunction<FormProps, SyncFormProps> = ({ record,
|
||||
|
||||
return (
|
||||
<>
|
||||
<Form
|
||||
form={form}
|
||||
labelCol={{ span: 4 }}
|
||||
initialValues={initFormValue}
|
||||
>
|
||||
<Form form={form} labelCol={{ span: 4 }} initialValues={initFormValue}>
|
||||
<Form.Item
|
||||
label="Name"
|
||||
name="name"
|
||||
@@ -92,7 +104,7 @@ const SyncForm: ForwardRefRenderFunction<FormProps, SyncFormProps> = ({ record,
|
||||
label="PATH"
|
||||
name="path"
|
||||
rules={[{ required: true, message: 'Please enter the path!' }]}
|
||||
>
|
||||
>
|
||||
<Input
|
||||
placeholder="YOUR_PATH"
|
||||
addonBefore={pathOptions}
|
||||
@@ -100,13 +112,17 @@ const SyncForm: ForwardRefRenderFunction<FormProps, SyncFormProps> = ({ record,
|
||||
{...DISABLE_AUTO_COMPLETE}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item style={{ display: 'none' }} name="id" initialValue={v4().replace(/-/g, '')}><input /></Form.Item>
|
||||
<Form.Item style={{ display: 'none' }} name="id" initialValue={v4().replace(/-/g, '')}>
|
||||
<input />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
<div className="tip">
|
||||
<p>The file supports only {csvTip} and {jsonTip} formats.</p>
|
||||
<p>
|
||||
The file supports only {csvTip} and {jsonTip} formats.
|
||||
</p>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
export default forwardRef(SyncForm);
|
||||
|
||||
26
src/view/model/SyncCustom/config.tsx
vendored
26
src/view/model/SyncCustom/config.tsx
vendored
@@ -26,7 +26,7 @@ export const syncColumns = () => [
|
||||
dataIndex: 'path',
|
||||
key: 'path',
|
||||
width: 180,
|
||||
render: (_: string, row: any) => <RenderPath row={row} />
|
||||
render: (_: string, row: any) => <RenderPath row={row} />,
|
||||
},
|
||||
{
|
||||
title: 'Last updated',
|
||||
@@ -36,7 +36,7 @@ export const syncColumns = () => [
|
||||
render: (v: number) => (
|
||||
<div>
|
||||
<HistoryOutlined style={{ marginRight: 5, color: v ? '#52c41a' : '#ff4d4f' }} />
|
||||
{ v ? fmtDate(v) : ''}
|
||||
{v ? fmtDate(v) : ''}
|
||||
</div>
|
||||
),
|
||||
},
|
||||
@@ -56,7 +56,11 @@ export const syncColumns = () => [
|
||||
>
|
||||
<a>Sync</a>
|
||||
</Popconfirm>
|
||||
{row.last_updated && <Link to={`${row.id}`} state={row}>View</Link>}
|
||||
{row.last_updated && (
|
||||
<Link to={`${row.id}`} state={row}>
|
||||
View
|
||||
</Link>
|
||||
)}
|
||||
<a onClick={() => actions.setRecord(row, 'edit')}>Edit</a>
|
||||
<Popconfirm
|
||||
title="Are you sure to delete this path?"
|
||||
@@ -67,23 +71,23 @@ export const syncColumns = () => [
|
||||
<a>Delete</a>
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
)
|
||||
}
|
||||
}
|
||||
);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
const RenderPath = ({ row }: any) => {
|
||||
const [filePath, setFilePath] = useState('');
|
||||
useInit(async () => {
|
||||
setFilePath(await getPath(row));
|
||||
})
|
||||
return <a onClick={() => shell.open(filePath)}>{filePath}</a>
|
||||
setFilePath(await getPath(row));
|
||||
});
|
||||
return <a onClick={() => shell.open(filePath)}>{filePath}</a>;
|
||||
};
|
||||
|
||||
export const getPath = async (row: any) => {
|
||||
if (!/^http/.test(row.protocol)) {
|
||||
return await path.join(await chatRoot(), row.path) + `.${row.ext}`;
|
||||
return (await path.join(await chatRoot(), row.path)) + `.${row.ext}`;
|
||||
} else {
|
||||
return `${row.protocol}://${row.path}.${row.ext}`;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
58
src/view/model/SyncCustom/index.tsx
vendored
58
src/view/model/SyncCustom/index.tsx
vendored
@@ -10,7 +10,13 @@ import { CHAT_MODEL_JSON, chatRoot, readJSON, genCmd } from '@/utils';
|
||||
import { syncColumns, getPath } from './config';
|
||||
import SyncForm from './Form';
|
||||
|
||||
const fmtData = (data: Record<string, any>[] = []) => (Array.isArray(data) ? data : []).map((i) => ({ ...i, cmd: i.cmd ? i.cmd : genCmd(i.act), tags: ['user-sync'], enable: true }));
|
||||
const fmtData = (data: Record<string, any>[] = []) =>
|
||||
(Array.isArray(data) ? data : []).map((i) => ({
|
||||
...i,
|
||||
cmd: i.cmd ? i.cmd : genCmd(i.act),
|
||||
tags: ['user-sync'],
|
||||
enable: true,
|
||||
}));
|
||||
|
||||
export default function SyncCustom() {
|
||||
const [isVisible, setVisible] = useState(false);
|
||||
@@ -37,7 +43,10 @@ export default function SyncCustom() {
|
||||
handleSync(filename).then((isOk: boolean) => {
|
||||
opInfo.resetRecord();
|
||||
if (!isOk) return;
|
||||
const data = opReplace(opInfo?.opRecord?.[opSafeKey], { ...opInfo?.opRecord, last_updated: Date.now() });
|
||||
const data = opReplace(opInfo?.opRecord?.[opSafeKey], {
|
||||
...opInfo?.opRecord,
|
||||
last_updated: Date.now(),
|
||||
});
|
||||
modelSet(data);
|
||||
opInfo.resetRecord();
|
||||
});
|
||||
@@ -48,9 +57,13 @@ export default function SyncCustom() {
|
||||
if (['delete'].includes(opInfo.opType)) {
|
||||
(async () => {
|
||||
try {
|
||||
const file = await path.join(await chatRoot(), 'cache_model', `${opInfo?.opRecord?.id}.json`);
|
||||
const file = await path.join(
|
||||
await chatRoot(),
|
||||
'cache_model',
|
||||
`${opInfo?.opRecord?.id}.json`,
|
||||
);
|
||||
await fs.removeFile(file);
|
||||
} catch(e) {}
|
||||
} catch (e) {}
|
||||
const data = opRemove(opInfo?.opRecord?.[opSafeKey]);
|
||||
modelSet(data);
|
||||
opInfo.resetRecord();
|
||||
@@ -94,29 +107,24 @@ export default function SyncCustom() {
|
||||
};
|
||||
|
||||
const handleOk = () => {
|
||||
formRef.current?.form?.validateFields()
|
||||
.then((vals: Record<string, any>) => {
|
||||
if (opInfo.opType === 'new') {
|
||||
const data = opAdd(vals);
|
||||
modelSet(data);
|
||||
message.success('Data added successfully');
|
||||
}
|
||||
if (opInfo.opType === 'edit') {
|
||||
const data = opReplace(opInfo?.opRecord?.[opSafeKey], vals);
|
||||
modelSet(data);
|
||||
message.success('Data updated successfully');
|
||||
}
|
||||
hide();
|
||||
})
|
||||
formRef.current?.form?.validateFields().then((vals: Record<string, any>) => {
|
||||
if (opInfo.opType === 'new') {
|
||||
const data = opAdd(vals);
|
||||
modelSet(data);
|
||||
message.success('Data added successfully');
|
||||
}
|
||||
if (opInfo.opType === 'edit') {
|
||||
const data = opReplace(opInfo?.opRecord?.[opSafeKey], vals);
|
||||
modelSet(data);
|
||||
message.success('Data updated successfully');
|
||||
}
|
||||
hide();
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Button
|
||||
className="chat-add-btn"
|
||||
type="primary"
|
||||
onClick={opInfo.opNew}
|
||||
>
|
||||
<Button className="chat-add-btn" type="primary" onClick={opInfo.opNew}>
|
||||
Add PATH
|
||||
</Button>
|
||||
<Table
|
||||
@@ -138,5 +146,5 @@ export default function SyncCustom() {
|
||||
<SyncForm ref={formRef} record={opInfo?.opRecord} type={opInfo.opType} />
|
||||
</Modal>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
4
src/view/model/SyncPrompts/config.tsx
vendored
4
src/view/model/SyncPrompts/config.tsx
vendored
@@ -41,8 +41,6 @@ export const syncColumns = () => [
|
||||
dataIndex: 'prompt',
|
||||
key: 'prompt',
|
||||
// width: 300,
|
||||
render: (v: string) => (
|
||||
<span className="chat-prompts-val">{v}</span>
|
||||
),
|
||||
render: (v: string) => <span className="chat-prompts-val">{v}</span>,
|
||||
},
|
||||
];
|
||||
|
||||
3
src/view/model/SyncPrompts/index.scss
vendored
3
src/view/model/SyncPrompts/index.scss
vendored
@@ -1,4 +1,5 @@
|
||||
.chat-table-tip, .chat-table-btns {
|
||||
.chat-table-tip,
|
||||
.chat-table-btns {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
20
src/view/model/SyncPrompts/index.tsx
vendored
20
src/view/model/SyncPrompts/index.tsx
vendored
@@ -52,7 +52,7 @@ export default function SyncPrompts() {
|
||||
}, [opInfo.opTime]);
|
||||
|
||||
const handleEnable = (isEnable: boolean) => {
|
||||
const data = opReplaceItems(selectedRowIDs, { enable: isEnable })
|
||||
const data = opReplaceItems(selectedRowIDs, { enable: isEnable });
|
||||
modelCacheSet(data);
|
||||
};
|
||||
|
||||
@@ -72,7 +72,9 @@ export default function SyncPrompts() {
|
||||
<div>
|
||||
{selectedItems.length > 0 && (
|
||||
<>
|
||||
<Button type="primary" onClick={() => handleEnable(true)}>Enable</Button>
|
||||
<Button type="primary" onClick={() => handleEnable(true)}>
|
||||
Enable
|
||||
</Button>
|
||||
<Button onClick={() => handleEnable(false)}>Disable</Button>
|
||||
<span className="num">Selected {selectedItems.length} items</span>
|
||||
</>
|
||||
@@ -84,7 +86,11 @@ export default function SyncPrompts() {
|
||||
<FilePath url={promptsURL} content="f/awesome-chatgpt-prompts/prompts.csv" />
|
||||
<FilePath label="CACHE" paths="cache_model/chatgpt_prompts.json" />
|
||||
</div>
|
||||
{lastUpdated && <span style={{ marginLeft: 10, color: '#888', fontSize: 12 }}>Last updated on {fmtDate(lastUpdated)}</span>}
|
||||
{lastUpdated && (
|
||||
<span style={{ marginLeft: 10, color: '#888', fontSize: 12 }}>
|
||||
Last updated on {fmtDate(lastUpdated)}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<Table
|
||||
key={lastUpdated}
|
||||
@@ -94,8 +100,10 @@ export default function SyncPrompts() {
|
||||
dataSource={opData}
|
||||
rowSelection={rowSelection}
|
||||
pagination={TABLE_PAGINATION}
|
||||
expandable={{expandedRowRender: (record) => <div style={{ padding: 10 }}>{record.prompt}</div>}}
|
||||
expandable={{
|
||||
expandedRowRender: (record) => <div style={{ padding: 10 }}>{record.prompt}</div>,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
10
src/view/model/SyncRecord/config.tsx
vendored
10
src/view/model/SyncRecord/config.tsx
vendored
@@ -25,7 +25,11 @@ export const syncColumns = () => [
|
||||
key: 'tags',
|
||||
// width: 150,
|
||||
render: (v: string[]) => (
|
||||
<span className="chat-prompts-tags">{v?.map(i => <Tag key={i}>{i}</Tag>)}</span>
|
||||
<span className="chat-prompts-tags">
|
||||
{v?.map((i) => (
|
||||
<Tag key={i}>{i}</Tag>
|
||||
))}
|
||||
</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
@@ -43,8 +47,6 @@ export const syncColumns = () => [
|
||||
dataIndex: 'prompt',
|
||||
key: 'prompt',
|
||||
// width: 300,
|
||||
render: (v: string) => (
|
||||
<span className="chat-prompts-val">{v}</span>
|
||||
),
|
||||
render: (v: string) => <span className="chat-prompts-val">{v}</span>,
|
||||
},
|
||||
];
|
||||
|
||||
22
src/view/model/SyncRecord/index.tsx
vendored
22
src/view/model/SyncRecord/index.tsx
vendored
@@ -30,7 +30,7 @@ export default function SyncRecord() {
|
||||
useInit(async () => {
|
||||
setFilePath(await getPath(state));
|
||||
setJsonPath(await path.join(await chatRoot(), 'cache_model', `${state?.id}.json`));
|
||||
})
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (modelCacheJson.length <= 0) return;
|
||||
@@ -45,7 +45,7 @@ export default function SyncRecord() {
|
||||
}, [opInfo.opTime]);
|
||||
|
||||
const handleEnable = (isEnable: boolean) => {
|
||||
const data = opReplaceItems(selectedRowIDs, { enable: isEnable })
|
||||
const data = opReplaceItems(selectedRowIDs, { enable: isEnable });
|
||||
modelCacheSet(data);
|
||||
};
|
||||
|
||||
@@ -58,7 +58,9 @@ export default function SyncRecord() {
|
||||
<div>
|
||||
{selectedItems.length > 0 && (
|
||||
<>
|
||||
<Button type="primary" onClick={() => handleEnable(true)}>Enable</Button>
|
||||
<Button type="primary" onClick={() => handleEnable(true)}>
|
||||
Enable
|
||||
</Button>
|
||||
<Button onClick={() => handleEnable(false)}>Disable</Button>
|
||||
<span className="num">Selected {selectedItems.length} items</span>
|
||||
</>
|
||||
@@ -70,7 +72,11 @@ export default function SyncRecord() {
|
||||
<FilePath url={filePath} />
|
||||
<FilePath label="CACHE" paths={`cache_model/${state?.id}.json`} />
|
||||
</div>
|
||||
{state?.last_updated && <span style={{ marginLeft: 10, color: '#888', fontSize: 12 }}>Last updated on {fmtDate(state?.last_updated)}</span>}
|
||||
{state?.last_updated && (
|
||||
<span style={{ marginLeft: 10, color: '#888', fontSize: 12 }}>
|
||||
Last updated on {fmtDate(state?.last_updated)}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<Table
|
||||
key="prompt"
|
||||
@@ -80,8 +86,10 @@ export default function SyncRecord() {
|
||||
dataSource={opData}
|
||||
rowSelection={rowSelection}
|
||||
pagination={TABLE_PAGINATION}
|
||||
expandable={{expandedRowRender: (record) => <div style={{ padding: 10 }}>{record.prompt}</div>}}
|
||||
expandable={{
|
||||
expandedRowRender: (record) => <div style={{ padding: 10 }}>{record.prompt}</div>,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
17
src/view/model/UserCustom/Form.tsx
vendored
17
src/view/model/UserCustom/Form.tsx
vendored
@@ -6,7 +6,7 @@ import Tags from '@comps/Tags';
|
||||
import { DISABLE_AUTO_COMPLETE } from '@/utils';
|
||||
|
||||
interface UserCustomFormProps {
|
||||
record?: Record<string|symbol, any> | null;
|
||||
record?: Record<string | symbol, any> | null;
|
||||
}
|
||||
|
||||
const initFormValue = {
|
||||
@@ -16,7 +16,10 @@ const initFormValue = {
|
||||
prompt: '',
|
||||
};
|
||||
|
||||
const UserCustomForm: ForwardRefRenderFunction<FormProps, UserCustomFormProps> = ({ record }, ref) => {
|
||||
const UserCustomForm: ForwardRefRenderFunction<FormProps, UserCustomFormProps> = (
|
||||
{ record },
|
||||
ref,
|
||||
) => {
|
||||
const [form] = Form.useForm();
|
||||
useImperativeHandle(ref, () => ({ form }));
|
||||
|
||||
@@ -27,11 +30,7 @@ const UserCustomForm: ForwardRefRenderFunction<FormProps, UserCustomFormProps> =
|
||||
}, [record]);
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={form}
|
||||
labelCol={{ span: 4 }}
|
||||
initialValues={initFormValue}
|
||||
>
|
||||
<Form form={form} labelCol={{ span: 4 }} initialValues={initFormValue}>
|
||||
<Form.Item
|
||||
label="/{cmd}"
|
||||
name="cmd"
|
||||
@@ -60,7 +59,7 @@ const UserCustomForm: ForwardRefRenderFunction<FormProps, UserCustomFormProps> =
|
||||
<Input.TextArea rows={4} placeholder="Please enter a prompt" {...DISABLE_AUTO_COMPLETE} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
)
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
export default forwardRef(UserCustomForm);
|
||||
|
||||
14
src/view/model/UserCustom/config.tsx
vendored
14
src/view/model/UserCustom/config.tsx
vendored
@@ -7,7 +7,7 @@ export const modelColumns = () => [
|
||||
fixed: 'left',
|
||||
width: 120,
|
||||
key: 'cmd',
|
||||
render: (v: string) => <Tag color="#2a2a2a">/{v}</Tag>
|
||||
render: (v: string) => <Tag color="#2a2a2a">/{v}</Tag>,
|
||||
},
|
||||
{
|
||||
title: 'Act',
|
||||
@@ -21,7 +21,11 @@ export const modelColumns = () => [
|
||||
key: 'tags',
|
||||
width: 150,
|
||||
render: (v: string[]) => (
|
||||
<span className="chat-prompts-tags">{v?.map(i => <Tag key={i}>{i}</Tag>)}</span>
|
||||
<span className="chat-prompts-tags">
|
||||
{v?.map((i) => (
|
||||
<Tag key={i}>{i}</Tag>
|
||||
))}
|
||||
</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
@@ -39,9 +43,7 @@ export const modelColumns = () => [
|
||||
dataIndex: 'prompt',
|
||||
key: 'prompt',
|
||||
width: 300,
|
||||
render: (v: string) => (
|
||||
<span className="chat-prompts-val">{v}</span>
|
||||
),
|
||||
render: (v: string) => <span className="chat-prompts-val">{v}</span>,
|
||||
},
|
||||
{
|
||||
title: 'Action',
|
||||
@@ -61,5 +63,5 @@ export const modelColumns = () => [
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
),
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
77
src/view/model/UserCustom/index.tsx
vendored
77
src/view/model/UserCustom/index.tsx
vendored
@@ -50,10 +50,10 @@ export default function LanguageModel() {
|
||||
const data = opReplace(opInfo?.opRecord?.[opSafeKey], opInfo?.opRecord);
|
||||
modelCacheSet(data);
|
||||
}
|
||||
}, [opInfo.opTime])
|
||||
}, [opInfo.opTime]);
|
||||
|
||||
const handleEnable = (isEnable: boolean) => {
|
||||
const data = opReplaceItems(selectedRowIDs, { enable: isEnable })
|
||||
const data = opReplaceItems(selectedRowIDs, { enable: isEnable });
|
||||
modelCacheSet(data);
|
||||
};
|
||||
|
||||
@@ -63,38 +63,51 @@ export default function LanguageModel() {
|
||||
};
|
||||
|
||||
const handleOk = () => {
|
||||
formRef.current?.form?.validateFields()
|
||||
.then(async (vals: Record<string, any>) => {
|
||||
if (modelCacheJson.map((i: any) => i.cmd).includes(vals.cmd) && opInfo?.opRecord?.cmd !== vals.cmd) {
|
||||
message.warning(`"cmd: /${vals.cmd}" already exists, please change the "${vals.cmd}" name and resubmit.`);
|
||||
return;
|
||||
}
|
||||
let data = [];
|
||||
switch (opInfo.opType) {
|
||||
case 'new': data = opAdd(vals); break;
|
||||
case 'edit': data = opReplace(opInfo?.opRecord?.[opSafeKey], vals); break;
|
||||
default: break;
|
||||
}
|
||||
await modelCacheSet(data);
|
||||
opInit(data);
|
||||
modelSet({
|
||||
id: 'user_custom',
|
||||
last_updated: Date.now(),
|
||||
});
|
||||
hide();
|
||||
})
|
||||
formRef.current?.form?.validateFields().then(async (vals: Record<string, any>) => {
|
||||
if (
|
||||
modelCacheJson.map((i: any) => i.cmd).includes(vals.cmd) &&
|
||||
opInfo?.opRecord?.cmd !== vals.cmd
|
||||
) {
|
||||
message.warning(
|
||||
`"cmd: /${vals.cmd}" already exists, please change the "${vals.cmd}" name and resubmit.`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
let data = [];
|
||||
switch (opInfo.opType) {
|
||||
case 'new':
|
||||
data = opAdd(vals);
|
||||
break;
|
||||
case 'edit':
|
||||
data = opReplace(opInfo?.opRecord?.[opSafeKey], vals);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
await modelCacheSet(data);
|
||||
opInit(data);
|
||||
modelSet({
|
||||
id: 'user_custom',
|
||||
last_updated: Date.now(),
|
||||
});
|
||||
hide();
|
||||
});
|
||||
};
|
||||
|
||||
const modalTitle = `${({ new: 'Create', edit: 'Edit' })[opInfo.opType]} Model`;
|
||||
const modalTitle = `${{ new: 'Create', edit: 'Edit' }[opInfo.opType]} Model`;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="chat-table-btns">
|
||||
<Button className="chat-add-btn" type="primary" onClick={opInfo.opNew}>Add Model</Button>
|
||||
<Button className="chat-add-btn" type="primary" onClick={opInfo.opNew}>
|
||||
Add Model
|
||||
</Button>
|
||||
<div>
|
||||
{selectedItems.length > 0 && (
|
||||
<>
|
||||
<Button type="primary" onClick={() => handleEnable(true)}>Enable</Button>
|
||||
<Button type="primary" onClick={() => handleEnable(true)}>
|
||||
Enable
|
||||
</Button>
|
||||
<Button onClick={() => handleEnable(false)}>Disable</Button>
|
||||
<span className="num">Selected {selectedItems.length} items</span>
|
||||
</>
|
||||
@@ -103,7 +116,11 @@ export default function LanguageModel() {
|
||||
</div>
|
||||
<div className="chat-table-tip">
|
||||
<FilePath label="CACHE" paths="cache_model/user_custom.json" />
|
||||
{lastUpdated && <span style={{ marginLeft: 10, color: '#888', fontSize: 12 }}>Last updated on {fmtDate(lastUpdated)}</span>}
|
||||
{lastUpdated && (
|
||||
<span style={{ marginLeft: 10, color: '#888', fontSize: 12 }}>
|
||||
Last updated on {fmtDate(lastUpdated)}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<Table
|
||||
key={lastUpdated}
|
||||
@@ -113,7 +130,9 @@ export default function LanguageModel() {
|
||||
dataSource={opData}
|
||||
rowSelection={rowSelection}
|
||||
pagination={TABLE_PAGINATION}
|
||||
expandable={{expandedRowRender: (record) => <div style={{ padding: 10 }}>{record.prompt}</div>}}
|
||||
expandable={{
|
||||
expandedRowRender: (record) => <div style={{ padding: 10 }}>{record.prompt}</div>,
|
||||
}}
|
||||
/>
|
||||
<Modal
|
||||
open={isVisible}
|
||||
@@ -126,5 +145,5 @@ export default function LanguageModel() {
|
||||
<UserCustomForm record={opInfo?.opRecord} ref={formRef} />
|
||||
</Modal>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
18
src/view/notes/config.tsx
vendored
18
src/view/notes/config.tsx
vendored
@@ -41,7 +41,9 @@ export const notesColumns = () => [
|
||||
return (
|
||||
<Space>
|
||||
<a onClick={() => actions.setRecord(row, 'preview')}>Preview</a>
|
||||
<Link to={`/md/${row.id}`} state={row}>Edit</Link>
|
||||
<Link to={`/md/${row.id}`} state={row}>
|
||||
Edit
|
||||
</Link>
|
||||
<Popconfirm
|
||||
title="Are you sure to delete this file?"
|
||||
onConfirm={() => actions.setRecord(row, 'delete')}
|
||||
@@ -51,20 +53,20 @@ export const notesColumns = () => [
|
||||
<a>Delete</a>
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
)
|
||||
}
|
||||
}
|
||||
);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
const RenderPath = ({ row }: any) => {
|
||||
const [filePath, setFilePath] = useState('');
|
||||
useInit(async () => {
|
||||
setFilePath(await getPath(row));
|
||||
})
|
||||
setFilePath(await getPath(row));
|
||||
});
|
||||
return <a onClick={() => shell.open(filePath)}>{filePath}</a>;
|
||||
};
|
||||
|
||||
export const getPath = async (row: any) => {
|
||||
const isImg = ['png'].includes(row?.ext);
|
||||
return await path.join(await chatRoot(), 'notes', row.id) + `.${row.ext}`;
|
||||
}
|
||||
return (await path.join(await chatRoot(), 'notes', row.id)) + `.${row.ext}`;
|
||||
};
|
||||
|
||||
10
src/view/notes/index.tsx
vendored
10
src/view/notes/index.tsx
vendored
@@ -46,8 +46,8 @@ export default function Notes() {
|
||||
message.success('Name has been changed!');
|
||||
}
|
||||
opInfo.resetRecord();
|
||||
})()
|
||||
}, [opInfo.opType])
|
||||
})();
|
||||
}, [opInfo.opType]);
|
||||
|
||||
const handleDelete = async () => {
|
||||
if (opData?.length === selectedRows.length) {
|
||||
@@ -62,7 +62,7 @@ export default function Notes() {
|
||||
const file = await path.join(await chatRoot(), 'notes', `${i?.id}.${i?.ext}`);
|
||||
await fs.removeFile(file);
|
||||
return file;
|
||||
})
|
||||
});
|
||||
Promise.all(rows).then(async () => {
|
||||
await handleRefresh();
|
||||
message.success('All files selected are cleared!');
|
||||
@@ -122,5 +122,5 @@ export default function Notes() {
|
||||
<Markdown children={source} />
|
||||
</Modal>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
62
src/view/settings/General.tsx
vendored
62
src/view/settings/General.tsx
vendored
@@ -9,37 +9,47 @@ import { DISABLE_AUTO_COMPLETE } from '@/utils';
|
||||
const AutoUpdateLabel = () => {
|
||||
return (
|
||||
<span>
|
||||
Auto Update
|
||||
{' '}
|
||||
<Tooltip title={(
|
||||
<div>
|
||||
<div>Auto Update Policy</div>
|
||||
<div><strong>Prompt</strong>: prompt to install</div>
|
||||
<div><strong>Silent</strong>: install silently</div>
|
||||
{/* <div><strong>Disable</strong>: disable auto update</div> */}
|
||||
</div>
|
||||
)}><QuestionCircleOutlined style={{ color: '#1677ff' }} /></Tooltip>
|
||||
Auto Update{' '}
|
||||
<Tooltip
|
||||
title={
|
||||
<div>
|
||||
<div>Auto Update Policy</div>
|
||||
<div>
|
||||
<strong>Prompt</strong>: prompt to install
|
||||
</div>
|
||||
<div>
|
||||
<strong>Silent</strong>: install silently
|
||||
</div>
|
||||
{/* <div><strong>Disable</strong>: disable auto update</div> */}
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<QuestionCircleOutlined style={{ color: '#1677ff' }} />
|
||||
</Tooltip>
|
||||
</span>
|
||||
)
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
const GlobalShortcutLabel = () => {
|
||||
return (
|
||||
<div>
|
||||
Global Shortcut
|
||||
{' '}
|
||||
<Tooltip title={(
|
||||
<div>
|
||||
<div>Shortcut definition, modifiers and key separated by "+" e.g. CmdOrControl+Q</div>
|
||||
<div style={{ margin: '10px 0'}}>If empty, the shortcut is disabled.</div>
|
||||
<a href="https://tauri.app/v1/api/js/globalshortcut" target="_blank">https://tauri.app/v1/api/js/globalshortcut</a>
|
||||
</div>
|
||||
)}>
|
||||
Global Shortcut{' '}
|
||||
<Tooltip
|
||||
title={
|
||||
<div>
|
||||
<div>Shortcut definition, modifiers and key separated by "+" e.g. CmdOrControl+Q</div>
|
||||
<div style={{ margin: '10px 0' }}>If empty, the shortcut is disabled.</div>
|
||||
<a href="https://tauri.app/v1/api/js/globalshortcut" target="_blank">
|
||||
https://tauri.app/v1/api/js/globalshortcut
|
||||
</a>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<QuestionCircleOutlined style={{ color: '#1677ff' }} />
|
||||
</Tooltip>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
export default function General() {
|
||||
const [platformInfo, setPlatform] = useState('');
|
||||
@@ -62,9 +72,7 @@ export default function General() {
|
||||
<Radio.Group>
|
||||
<Radio value="Light">Light</Radio>
|
||||
<Radio value="Dark">Dark</Radio>
|
||||
{["darwin", "windows"].includes(platformInfo) && (
|
||||
<Radio value="System">System</Radio>
|
||||
)}
|
||||
{['darwin', 'windows'].includes(platformInfo) && <Radio value="System">System</Radio>}
|
||||
</Radio.Group>
|
||||
</Form.Item>
|
||||
<Form.Item label={<AutoUpdateLabel />} name="auto_update">
|
||||
@@ -78,5 +86,5 @@ export default function General() {
|
||||
<Input placeholder="CmdOrCtrl+Shift+O" {...DISABLE_AUTO_COMPLETE} />
|
||||
</Form.Item>
|
||||
</>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
48
src/view/settings/MainWindow.tsx
vendored
48
src/view/settings/MainWindow.tsx
vendored
@@ -9,25 +9,39 @@ import { DISABLE_AUTO_COMPLETE } from '@/utils';
|
||||
const OriginLabel = ({ url }: { url: string }) => {
|
||||
return (
|
||||
<span>
|
||||
Switch Origin <Tooltip title={`Default: ${url}`}><QuestionCircleOutlined style={{ color: '#1677ff' }} /></Tooltip>
|
||||
Switch Origin{' '}
|
||||
<Tooltip title={`Default: ${url}`}>
|
||||
<QuestionCircleOutlined style={{ color: '#1677ff' }} />
|
||||
</Tooltip>
|
||||
</span>
|
||||
)
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
const PopupSearchLabel = () => {
|
||||
return (
|
||||
<span>
|
||||
Pop-up Search
|
||||
{' '}
|
||||
<Tooltip title={(
|
||||
<div>
|
||||
<div style={{ marginBottom: 10 }}>Generate images according to the content: Select the ChatGPT content with the mouse, no more than 400 characters. the <b>DALL·E 2</b> button appears, and click to jump (Note: because the search content filled by the script cannot trigger the event directly, you need to enter a space in the input box to make the button clickable).</div>
|
||||
<div>The application is built using Tauri, and due to its security restrictions, some of the action buttons will not work, so we recommend going to your browser.</div>
|
||||
</div>
|
||||
)}><QuestionCircleOutlined style={{ color: '#1677ff' }} /></Tooltip>
|
||||
Pop-up Search{' '}
|
||||
<Tooltip
|
||||
title={
|
||||
<div>
|
||||
<div style={{ marginBottom: 10 }}>
|
||||
Generate images according to the content: Select the ChatGPT content with the mouse,
|
||||
no more than 400 characters. the <b>DALL·E 2</b> button appears, and click to jump
|
||||
(Note: because the search content filled by the script cannot trigger the event
|
||||
directly, you need to enter a space in the input box to make the button clickable).
|
||||
</div>
|
||||
<div>
|
||||
The application is built using Tauri, and due to its security restrictions, some of
|
||||
the action buttons will not work, so we recommend going to your browser.
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<QuestionCircleOutlined style={{ color: '#1677ff' }} />
|
||||
</Tooltip>
|
||||
</span>
|
||||
)
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
export default function General() {
|
||||
const [chatConf, setChatConf] = useState<any>(null);
|
||||
@@ -46,8 +60,12 @@ export default function General() {
|
||||
<Input placeholder="https://chat.openai.com" {...DISABLE_AUTO_COMPLETE} />
|
||||
</Form.Item>
|
||||
<Form.Item label="User Agent (Main)" name="ua_window">
|
||||
<Input.TextArea autoSize={{ minRows: 4, maxRows: 4 }} {...DISABLE_AUTO_COMPLETE} placeholder="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36" />
|
||||
<Input.TextArea
|
||||
autoSize={{ minRows: 4, maxRows: 4 }}
|
||||
{...DISABLE_AUTO_COMPLETE}
|
||||
placeholder="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36"
|
||||
/>
|
||||
</Form.Item>
|
||||
</>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
8
src/view/settings/TrayWindow.tsx
vendored
8
src/view/settings/TrayWindow.tsx
vendored
@@ -9,8 +9,12 @@ export default function General() {
|
||||
<Switch />
|
||||
</Form.Item>
|
||||
<Form.Item label="User Agent (SystemTray)" name="ua_tray">
|
||||
<Input.TextArea autoSize={{ minRows: 4, maxRows: 4 }} {...DISABLE_AUTO_COMPLETE} placeholder="Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.0 Mobile/15E148 Safari/604.1" />
|
||||
<Input.TextArea
|
||||
autoSize={{ minRows: 4, maxRows: 4 }}
|
||||
{...DISABLE_AUTO_COMPLETE}
|
||||
placeholder="Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.0 Mobile/15E148 Safari/604.1"
|
||||
/>
|
||||
</Form.Item>
|
||||
</>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
18
src/view/settings/index.tsx
vendored
18
src/view/settings/index.tsx
vendored
@@ -21,7 +21,7 @@ export default function Settings() {
|
||||
|
||||
useEffect(() => {
|
||||
form.setFieldsValue(clone(chatConf));
|
||||
}, [chatConf])
|
||||
}, [chatConf]);
|
||||
|
||||
const onCancel = () => {
|
||||
form.setFieldsValue(chatConf);
|
||||
@@ -31,7 +31,7 @@ export default function Settings() {
|
||||
const chatData = await invoke('reset_chat_conf');
|
||||
setChatConf(chatData);
|
||||
const isOk = await dialog.ask(`Configuration reset successfully, whether to restart?`, {
|
||||
title: 'ChatGPT Preferences'
|
||||
title: 'ChatGPT Preferences',
|
||||
});
|
||||
if (isOk) {
|
||||
process.relaunch();
|
||||
@@ -44,7 +44,7 @@ export default function Settings() {
|
||||
if (!isEqual(omit(chatConf, ['default_origin']), values)) {
|
||||
await invoke('form_confirm', { data: values, label: 'main' });
|
||||
const isOk = await dialog.ask(`Configuration saved successfully, whether to restart?`, {
|
||||
title: 'ChatGPT Preferences'
|
||||
title: 'ChatGPT Preferences',
|
||||
});
|
||||
if (isOk) {
|
||||
process.relaunch();
|
||||
@@ -75,11 +75,15 @@ export default function Settings() {
|
||||
<Form.Item>
|
||||
<Space size={20}>
|
||||
<Button onClick={onCancel}>Cancel</Button>
|
||||
<Button type="primary" htmlType="submit">Submit</Button>
|
||||
<Button type="dashed" onClick={onReset}>Reset to defaults</Button>
|
||||
<Button type="primary" htmlType="submit">
|
||||
Submit
|
||||
</Button>
|
||||
<Button type="dashed" onClick={onReset}>
|
||||
Reset to defaults
|
||||
</Button>
|
||||
</Space>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user