mirror of
https://github.com/FranP-code/ChatGPT.git
synced 2025-10-13 00:13:25 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5dd671c98e | ||
|
|
75a7b9c78d | ||
|
|
47a3bace5b | ||
|
|
8966ebbd03 |
@@ -22,9 +22,9 @@
|
|||||||
|
|
||||||
**最新版:**
|
**最新版:**
|
||||||
|
|
||||||
- `Mac`: [ChatGPT_0.5.0_x64.dmg](https://github.com/lencx/ChatGPT/releases/download/v0.5.0/ChatGPT_0.5.0_x64.dmg)
|
- `Mac`: [ChatGPT_0.5.1_x64.dmg](https://github.com/lencx/ChatGPT/releases/download/v0.5.1/ChatGPT_0.5.1_x64.dmg)
|
||||||
- `Linux`: [chat-gpt_0.5.0_amd64.deb](https://github.com/lencx/ChatGPT/releases/download/v0.5.0/chat-gpt_0.5.0_amd64.deb)
|
- `Linux`: [chat-gpt_0.5.1_amd64.deb](https://github.com/lencx/ChatGPT/releases/download/v0.5.1/chat-gpt_0.5.1_amd64.deb)
|
||||||
- `Windows`: [ChatGPT_0.5.0_x64_en-US.msi](https://github.com/lencx/ChatGPT/releases/download/v0.5.0/ChatGPT_0.5.0_x64_en-US.msi)
|
- `Windows`: [ChatGPT_0.5.1_x64_en-US.msi](https://github.com/lencx/ChatGPT/releases/download/v0.5.1/ChatGPT_0.5.1_x64_en-US.msi)
|
||||||
|
|
||||||
[其他版本...](https://github.com/lencx/ChatGPT/releases)
|
[其他版本...](https://github.com/lencx/ChatGPT/releases)
|
||||||
|
|
||||||
|
|||||||
@@ -23,9 +23,9 @@
|
|||||||
|
|
||||||
**Latest:**
|
**Latest:**
|
||||||
|
|
||||||
- `Mac`: [ChatGPT_0.5.0_x64.dmg](https://github.com/lencx/ChatGPT/releases/download/v0.5.0/ChatGPT_0.5.0_x64.dmg)
|
- `Mac`: [ChatGPT_0.5.1_x64.dmg](https://github.com/lencx/ChatGPT/releases/download/v0.5.1/ChatGPT_0.5.1_x64.dmg)
|
||||||
- `Linux`: [chat-gpt_0.5.0_amd64.deb](https://github.com/lencx/ChatGPT/releases/download/v0.5.0/chat-gpt_0.5.0_amd64.deb)
|
- `Linux`: [chat-gpt_0.5.1_amd64.deb](https://github.com/lencx/ChatGPT/releases/download/v0.5.1/chat-gpt_0.5.1_amd64.deb)
|
||||||
- `Windows`: [ChatGPT_0.5.0_x64_en-US.msi](https://github.com/lencx/ChatGPT/releases/download/v0.5.0/ChatGPT_0.5.0_x64_en-US.msi)
|
- `Windows`: [ChatGPT_0.5.1_x64_en-US.msi](https://github.com/lencx/ChatGPT/releases/download/v0.5.1/ChatGPT_0.5.1_x64_en-US.msi)
|
||||||
|
|
||||||
[Other version...](https://github.com/lencx/ChatGPT/releases)
|
[Other version...](https://github.com/lencx/ChatGPT/releases)
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
# UPDATE LOG
|
# UPDATE LOG
|
||||||
|
|
||||||
|
## v0.5.1
|
||||||
|
|
||||||
|
some optimization
|
||||||
|
|
||||||
## v0.5.0
|
## v0.5.0
|
||||||
|
|
||||||
feat: `Control Center` added `chatgpt-prompts` synchronization
|
feat: `Control Center` added `chatgpt-prompts` synchronization
|
||||||
|
|||||||
@@ -10,19 +10,32 @@ mod utils;
|
|||||||
use app::{cmd, fs_extra, menu, setup};
|
use app::{cmd, fs_extra, menu, setup};
|
||||||
use conf::{ChatConfJson, ChatState};
|
use conf::{ChatConfJson, ChatState};
|
||||||
use tauri::api::path;
|
use tauri::api::path;
|
||||||
use tauri_plugin_log::{fern::colors::ColoredLevelConfig, LogTarget, LoggerBuilder};
|
use tauri_plugin_log::{
|
||||||
|
fern::colors::{Color, ColoredLevelConfig},
|
||||||
|
LogTarget, LoggerBuilder,
|
||||||
|
};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
ChatConfJson::init();
|
ChatConfJson::init();
|
||||||
let chat_conf = ChatConfJson::get_chat_conf();
|
let chat_conf = ChatConfJson::get_chat_conf();
|
||||||
let context = tauri::generate_context!();
|
let context = tauri::generate_context!();
|
||||||
let colors = ColoredLevelConfig::default();
|
let colors = ColoredLevelConfig {
|
||||||
|
error: Color::Red,
|
||||||
|
warn: Color::Yellow,
|
||||||
|
debug: Color::Blue,
|
||||||
|
info: Color::BrightGreen,
|
||||||
|
trace: Color::Cyan,
|
||||||
|
};
|
||||||
|
|
||||||
tauri::Builder::default()
|
tauri::Builder::default()
|
||||||
// https://github.com/tauri-apps/tauri/pull/2736
|
// https://github.com/tauri-apps/tauri/pull/2736
|
||||||
.plugin(
|
.plugin(
|
||||||
LoggerBuilder::new()
|
LoggerBuilder::new()
|
||||||
// .level(log::LevelFilter::Error)
|
.level(if cfg!(debug_assertions) {
|
||||||
|
log::LevelFilter::Debug
|
||||||
|
} else {
|
||||||
|
log::LevelFilter::Trace
|
||||||
|
})
|
||||||
.with_colors(colors)
|
.with_colors(colors)
|
||||||
.targets([
|
.targets([
|
||||||
// LogTarget::LogDir,
|
// LogTarget::LogDir,
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
},
|
},
|
||||||
"package": {
|
"package": {
|
||||||
"productName": "ChatGPT",
|
"productName": "ChatGPT",
|
||||||
"version": "0.5.0"
|
"version": "0.5.1"
|
||||||
},
|
},
|
||||||
"tauri": {
|
"tauri": {
|
||||||
"allowlist": {
|
"allowlist": {
|
||||||
|
|||||||
12
src/hooks/useData.ts
vendored
12
src/hooks/useData.ts
vendored
@@ -7,9 +7,8 @@ export default function useData(oData: any[]) {
|
|||||||
const [opData, setData] = useState<any[]>([]);
|
const [opData, setData] = useState<any[]>([]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const nData = oData.map(i => ({ [safeKey]: v4(), ...i }));
|
opInit(oData);
|
||||||
setData(nData);
|
}, [])
|
||||||
}, [oData])
|
|
||||||
|
|
||||||
const opAdd = (val: any) => {
|
const opAdd = (val: any) => {
|
||||||
const v = [val, ...opData];
|
const v = [val, ...opData];
|
||||||
@@ -17,6 +16,11 @@ export default function useData(oData: any[]) {
|
|||||||
return v;
|
return v;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const opInit = (val: any[] = []) => {
|
||||||
|
const nData = val.map(i => ({ [safeKey]: v4(), ...i }));
|
||||||
|
setData(nData);
|
||||||
|
};
|
||||||
|
|
||||||
const opRemove = (id: string) => {
|
const opRemove = (id: string) => {
|
||||||
const nData = opData.filter(i => i[safeKey] !== id);
|
const nData = opData.filter(i => i[safeKey] !== id);
|
||||||
setData(nData);
|
setData(nData);
|
||||||
@@ -31,5 +35,5 @@ export default function useData(oData: any[]) {
|
|||||||
return nData;
|
return nData;
|
||||||
};
|
};
|
||||||
|
|
||||||
return { opSafeKey: safeKey, opReplace, opAdd, opRemove, opData };
|
return { opSafeKey: safeKey, opInit, opReplace, opAdd, opRemove, opData };
|
||||||
}
|
}
|
||||||
2
src/layout/index.scss
vendored
2
src/layout/index.scss
vendored
@@ -19,6 +19,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.ant-menu {
|
.ant-menu {
|
||||||
|
user-select: none;
|
||||||
|
-webkit-user-select: none;
|
||||||
.ant-menu-item {
|
.ant-menu-item {
|
||||||
background-color: #f8f8f8;
|
background-color: #f8f8f8;
|
||||||
}
|
}
|
||||||
|
|||||||
8
src/layout/index.tsx
vendored
8
src/layout/index.tsx
vendored
@@ -34,7 +34,13 @@ const ChatLayout: FC<ChatLayoutProps> = ({ children }) => {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div className="chat-logo"><img src="/logo.png" /></div>
|
<div className="chat-logo"><img src="/logo.png" /></div>
|
||||||
<Menu defaultSelectedKeys={[location.pathname]} mode="vertical" items={menuItems} onClick={(i) => go(i.key)} />
|
<Menu
|
||||||
|
defaultSelectedKeys={[location.pathname]}
|
||||||
|
mode="inline"
|
||||||
|
inlineIndent={12}
|
||||||
|
items={menuItems}
|
||||||
|
onClick={(i) => go(i.key)}
|
||||||
|
/>
|
||||||
</Sider>
|
</Sider>
|
||||||
<Layout className="chat-layout" style={{ marginLeft: collapsed ? 80 : 200, transition: 'margin-left 300ms ease-out' }}>
|
<Layout className="chat-layout" style={{ marginLeft: collapsed ? 80 : 200, transition: 'margin-left 300ms ease-out' }}>
|
||||||
<Content
|
<Content
|
||||||
|
|||||||
42
src/routes.tsx
vendored
42
src/routes.tsx
vendored
@@ -3,20 +3,27 @@ import {
|
|||||||
DesktopOutlined,
|
DesktopOutlined,
|
||||||
BulbOutlined,
|
BulbOutlined,
|
||||||
SyncOutlined,
|
SyncOutlined,
|
||||||
|
UserOutlined,
|
||||||
} from '@ant-design/icons';
|
} from '@ant-design/icons';
|
||||||
import type { RouteObject } from 'react-router-dom';
|
|
||||||
import type { MenuProps } from 'antd';
|
import type { MenuProps } from 'antd';
|
||||||
|
|
||||||
import General from '@view/General';
|
import General from '@view/General';
|
||||||
import LanguageModel from '@/view/LanguageModel';
|
import LanguageModel from '@/view/LanguageModel';
|
||||||
import SyncPrompts from '@/view/SyncPrompts';
|
import SyncPrompts from '@/view/SyncPrompts';
|
||||||
|
|
||||||
export type ChatRouteObject = {
|
export type ChatRouteMetaObject = {
|
||||||
label: string;
|
label: string;
|
||||||
icon?: React.ReactNode,
|
icon?: React.ReactNode,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const routes: Array<RouteObject & { meta: ChatRouteObject }> = [
|
type ChatRouteObject = {
|
||||||
|
path: string;
|
||||||
|
element?: JSX.Element;
|
||||||
|
meta: ChatRouteMetaObject;
|
||||||
|
children?: ChatRouteObject[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export const routes: Array<ChatRouteObject> = [
|
||||||
{
|
{
|
||||||
path: '/',
|
path: '/',
|
||||||
element: <General />,
|
element: <General />,
|
||||||
@@ -27,19 +34,28 @@ export const routes: Array<RouteObject & { meta: ChatRouteObject }> = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/language-model',
|
path: '/language-model',
|
||||||
element: <LanguageModel />,
|
|
||||||
meta: {
|
meta: {
|
||||||
label: 'Language Model',
|
label: 'Language Model',
|
||||||
icon: <BulbOutlined />,
|
icon: <BulbOutlined />,
|
||||||
},
|
},
|
||||||
},
|
children: [
|
||||||
{
|
{
|
||||||
path: '/sync-prompts',
|
path: 'user-custom',
|
||||||
element: <SyncPrompts />,
|
element: <LanguageModel />,
|
||||||
meta: {
|
meta: {
|
||||||
label: 'Sync Prompts',
|
label: 'User Custom',
|
||||||
icon: <SyncOutlined />,
|
icon: <UserOutlined />,
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'sync-prompts',
|
||||||
|
element: <SyncPrompts />,
|
||||||
|
meta: {
|
||||||
|
label: 'Sync Prompts',
|
||||||
|
icon: <SyncOutlined />,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -47,6 +63,8 @@ type MenuItem = Required<MenuProps>['items'][number];
|
|||||||
export const menuItems: MenuItem[] = routes.map(i => ({
|
export const menuItems: MenuItem[] = routes.map(i => ({
|
||||||
...i.meta,
|
...i.meta,
|
||||||
key: i.path || '',
|
key: i.path || '',
|
||||||
|
children: i?.children?.map((j) =>
|
||||||
|
({ ...j.meta, key: `${i.path}/${j.path}` || ''})),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export default () => {
|
export default () => {
|
||||||
|
|||||||
15
src/view/LanguageModel/config.tsx
vendored
15
src/view/LanguageModel/config.tsx
vendored
@@ -1,4 +1,4 @@
|
|||||||
import { Tag, Switch, Tooltip, Space } from 'antd';
|
import { Tag, Switch, Tooltip, Space, Popconfirm } from 'antd';
|
||||||
|
|
||||||
export const modelColumns = () => [
|
export const modelColumns = () => [
|
||||||
{
|
{
|
||||||
@@ -29,7 +29,9 @@ export const modelColumns = () => [
|
|||||||
dataIndex: 'enable',
|
dataIndex: 'enable',
|
||||||
key: 'enable',
|
key: 'enable',
|
||||||
width: 80,
|
width: 80,
|
||||||
render: (v: boolean = false) => <Switch checked={v} disabled />,
|
render: (v: boolean = false, row: Record<string, any>, action: Record<string, any>) => (
|
||||||
|
<Switch checked={v} onChange={(v) => action.setRecord({ ...row, enable: v }, 'enable')} />
|
||||||
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Prompt',
|
title: 'Prompt',
|
||||||
@@ -48,7 +50,14 @@ export const modelColumns = () => [
|
|||||||
render: (_: any, row: any, actions: any) => (
|
render: (_: any, row: any, actions: any) => (
|
||||||
<Space size="middle">
|
<Space size="middle">
|
||||||
<a onClick={() => actions.setRecord(row, 'edit')}>Edit</a>
|
<a onClick={() => actions.setRecord(row, 'edit')}>Edit</a>
|
||||||
<a onClick={() => actions.setRecord(row, 'delete')}>Delete</a>
|
<Popconfirm
|
||||||
|
title="Are you sure to delete this model?"
|
||||||
|
onConfirm={() => actions.setRecord(row, 'delete')}
|
||||||
|
okText="Yes"
|
||||||
|
cancelText="No"
|
||||||
|
>
|
||||||
|
<a>Delete</a>
|
||||||
|
</Popconfirm>
|
||||||
</Space>
|
</Space>
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|||||||
16
src/view/LanguageModel/index.tsx
vendored
16
src/view/LanguageModel/index.tsx
vendored
@@ -3,9 +3,9 @@ import { Table, Button, Modal, message } from 'antd';
|
|||||||
import { invoke } from '@tauri-apps/api';
|
import { invoke } from '@tauri-apps/api';
|
||||||
|
|
||||||
import useInit from '@/hooks/useInit';
|
import useInit from '@/hooks/useInit';
|
||||||
|
import useData from '@/hooks/useData';
|
||||||
import useChatModel from '@/hooks/useChatModel';
|
import useChatModel from '@/hooks/useChatModel';
|
||||||
import useColumns from '@/hooks/useColumns';
|
import useColumns from '@/hooks/useColumns';
|
||||||
import useData from '@/hooks/useData';
|
|
||||||
import { chatModelPath } from '@/utils';
|
import { chatModelPath } from '@/utils';
|
||||||
import { modelColumns } from './config';
|
import { modelColumns } from './config';
|
||||||
import LanguageModelForm from './Form';
|
import LanguageModelForm from './Form';
|
||||||
@@ -15,10 +15,15 @@ export default function LanguageModel() {
|
|||||||
const [isVisible, setVisible] = useState(false);
|
const [isVisible, setVisible] = useState(false);
|
||||||
const [modelPath, setChatModelPath] = useState('');
|
const [modelPath, setChatModelPath] = useState('');
|
||||||
const { modelData, modelSet } = useChatModel('user_custom');
|
const { modelData, modelSet } = useChatModel('user_custom');
|
||||||
const { opData, opAdd, opRemove, opReplace, opSafeKey } = useData(modelData);
|
const { opData, opInit, opAdd, opRemove, opReplace, opSafeKey } = useData([]);
|
||||||
const { columns, ...opInfo } = useColumns(modelColumns());
|
const { columns, ...opInfo } = useColumns(modelColumns());
|
||||||
const formRef = useRef<any>(null);
|
const formRef = useRef<any>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (modelData.length <= 0) return;
|
||||||
|
opInit(modelData);
|
||||||
|
}, [modelData])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!opInfo.opType) return;
|
if (!opInfo.opType) return;
|
||||||
if (['edit', 'new'].includes(opInfo.opType)) {
|
if (['edit', 'new'].includes(opInfo.opType)) {
|
||||||
@@ -31,6 +36,13 @@ export default function LanguageModel() {
|
|||||||
}
|
}
|
||||||
}, [opInfo.opType, formRef]);
|
}, [opInfo.opType, formRef]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (opInfo.opType === 'enable') {
|
||||||
|
const data = opReplace(opInfo?.opRecord?.[opSafeKey], opInfo?.opRecord);
|
||||||
|
modelSet(data);
|
||||||
|
}
|
||||||
|
}, [opInfo.opTime])
|
||||||
|
|
||||||
useInit(async () => {
|
useInit(async () => {
|
||||||
const path = await chatModelPath();
|
const path = await chatModelPath();
|
||||||
setChatModelPath(path);
|
setChatModelPath(path);
|
||||||
|
|||||||
24
src/view/SyncPrompts/config.tsx
vendored
24
src/view/SyncPrompts/config.tsx
vendored
@@ -1,4 +1,4 @@
|
|||||||
import { Tag } from 'antd';
|
import { Switch, Tag, Tooltip } from 'antd';
|
||||||
|
|
||||||
export const genCmd = (act: string) => act.replace(/\s+|\/+/g, '_').replace(/[^\d\w]/g, '').toLocaleLowerCase();
|
export const genCmd = (act: string) => act.replace(/\s+|\/+/g, '_').replace(/[^\d\w]/g, '').toLocaleLowerCase();
|
||||||
|
|
||||||
@@ -26,20 +26,22 @@ export const modelColumns = () => [
|
|||||||
// width: 150,
|
// width: 150,
|
||||||
render: () => <Tag>chatgpt-prompts</Tag>,
|
render: () => <Tag>chatgpt-prompts</Tag>,
|
||||||
},
|
},
|
||||||
// {
|
{
|
||||||
// title: 'Enable',
|
title: 'Enable',
|
||||||
// dataIndex: 'enable',
|
dataIndex: 'enable',
|
||||||
// key: 'enable',
|
key: 'enable',
|
||||||
// width: 80,
|
// width: 80,
|
||||||
// render: (v: boolean = false) => <Switch checked={v} disabled />,
|
render: (v: boolean = false, row: Record<string, any>, action: Record<string, any>) => (
|
||||||
// },
|
<Switch checked={v} onChange={(v) => action.setRecord({ ...row, enable: v }, 'enable')} />
|
||||||
|
),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: 'Prompt',
|
title: 'Prompt',
|
||||||
dataIndex: 'prompt',
|
dataIndex: 'prompt',
|
||||||
key: 'prompt',
|
key: 'prompt',
|
||||||
// width: 300,
|
// width: 300,
|
||||||
// render: (v: string) => (
|
render: (v: string) => (
|
||||||
// <Tooltip overlayInnerStyle={{ width: 350 }} title={v}><span className="chat-prompts-val">{v}</span></Tooltip>
|
<Tooltip overlayInnerStyle={{ width: 350 }} title={v}><span className="chat-prompts-val">{v}</span></Tooltip>
|
||||||
// ),
|
),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
60
src/view/SyncPrompts/index.tsx
vendored
60
src/view/SyncPrompts/index.tsx
vendored
@@ -1,33 +1,42 @@
|
|||||||
import { useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { Table, Button, message } from 'antd';
|
import { Table, Button, message } from 'antd';
|
||||||
import { invoke } from '@tauri-apps/api';
|
import { invoke } from '@tauri-apps/api';
|
||||||
import { fetch, ResponseType } from '@tauri-apps/api/http';
|
import { fetch, ResponseType } from '@tauri-apps/api/http';
|
||||||
import { writeTextFile, readTextFile } from '@tauri-apps/api/fs';
|
import { writeTextFile, readTextFile } from '@tauri-apps/api/fs';
|
||||||
|
|
||||||
|
import useInit from '@/hooks/useInit';
|
||||||
import useColumns from '@/hooks/useColumns';
|
import useColumns from '@/hooks/useColumns';
|
||||||
|
import useData from '@/hooks/useData';
|
||||||
import useChatModel from '@/hooks/useChatModel';
|
import useChatModel from '@/hooks/useChatModel';
|
||||||
import { fmtDate, chatPromptsPath, GITHUB_PROMPTS_CSV_URL } from '@/utils';
|
import { fmtDate, chatPromptsPath, GITHUB_PROMPTS_CSV_URL } from '@/utils';
|
||||||
import { modelColumns, genCmd } from './config';
|
import { modelColumns, genCmd } from './config';
|
||||||
import './index.scss';
|
import './index.scss';
|
||||||
import useInit from '@/hooks/useInit';
|
|
||||||
|
|
||||||
const promptsURL = 'https://github.com/f/awesome-chatgpt-prompts/blob/main/prompts.csv';
|
const promptsURL = 'https://github.com/f/awesome-chatgpt-prompts/blob/main/prompts.csv';
|
||||||
|
|
||||||
export default function LanguageModel() {
|
export default function LanguageModel() {
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [lastUpdated, setLastUpdated] = useState();
|
const [lastUpdated, setLastUpdated] = useState();
|
||||||
const { modelSet } = useChatModel('sys_sync_prompts');
|
const { modelJson, modelSet } = useChatModel('sys_sync_prompts');
|
||||||
const [tableData, setTableData] = useState<Record<string, string>[]>([]);
|
const { opData, opInit, opReplace, opSafeKey } = useData([]);
|
||||||
const { columns, ...opInfo } = useColumns(modelColumns());
|
const { columns, ...opInfo } = useColumns(modelColumns());
|
||||||
|
|
||||||
useInit(async () => {
|
// useInit(async () => {
|
||||||
const filename = await chatPromptsPath();
|
// // const filename = await chatPromptsPath();
|
||||||
const data = await readTextFile(filename);
|
// // const data = await readTextFile(filename);
|
||||||
const list: Record<string, string>[] = await invoke('parse_prompt', { data });
|
// // const list: Record<string, string>[] = await invoke('parse_prompt', { data });
|
||||||
const fileData: Record<string, any> = await invoke('metadata', { path: filename });
|
// // const fileData: Record<string, any> = await invoke('metadata', { path: filename });
|
||||||
setLastUpdated(fileData.accessedAtMs);
|
// // setLastUpdated(fileData.accessedAtMs);
|
||||||
setTableData(list);
|
// // opInit(list);
|
||||||
})
|
// console.log('«31» /view/SyncPrompts/index.tsx ~> ', modelJson);
|
||||||
|
|
||||||
|
// opInit([]);
|
||||||
|
// })
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!modelJson?.sys_sync_prompts) return;
|
||||||
|
opInit(modelJson?.sys_sync_prompts)
|
||||||
|
}, [modelJson?.sys_sync_prompts])
|
||||||
|
|
||||||
const handleSync = async () => {
|
const handleSync = async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
@@ -36,16 +45,27 @@ export default function LanguageModel() {
|
|||||||
responseType: ResponseType.Text,
|
responseType: ResponseType.Text,
|
||||||
});
|
});
|
||||||
const data = (res.data || '') as string;
|
const data = (res.data || '') as string;
|
||||||
// const content = data.replace(/"(\s+)?,(\s+)?"/g, '","');
|
if (res.ok) {
|
||||||
await writeTextFile(await chatPromptsPath(), data);
|
// const content = data.replace(/"(\s+)?,(\s+)?"/g, '","');
|
||||||
const list: Record<string, string>[] = await invoke('parse_prompt', { data });
|
await writeTextFile(await chatPromptsPath(), data);
|
||||||
setTableData(list);
|
const list: Record<string, string>[] = await invoke('parse_prompt', { data });
|
||||||
modelSet(list.map(i => ({ cmd: genCmd(i.act), enable: true, tags: ['chatgpt-prompts'], ...i })));
|
opInit(list);
|
||||||
|
modelSet(list.map(i => ({ cmd: genCmd(i.act), enable: true, tags: ['chatgpt-prompts'], ...i })));
|
||||||
|
setLastUpdated(fmtDate(Date.now()) as any);
|
||||||
|
message.success('ChatGPT Prompts data has been synchronized!');
|
||||||
|
} else {
|
||||||
|
message.error('ChatGPT Prompts data sync failed, please try again!');
|
||||||
|
}
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
setLastUpdated(fmtDate(Date.now()) as any);
|
|
||||||
message.success('ChatGPT Prompts data synchronization completed!');
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (opInfo.opType === 'enable') {
|
||||||
|
const data = opReplace(opInfo?.opRecord?.[opSafeKey], opInfo?.opRecord);
|
||||||
|
modelSet(data);
|
||||||
|
}
|
||||||
|
}, [opInfo.opTime]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Button type="primary" loading={loading} onClick={handleSync}>Sync</Button>
|
<Button type="primary" loading={loading} onClick={handleSync}>Sync</Button>
|
||||||
@@ -56,7 +76,7 @@ export default function LanguageModel() {
|
|||||||
rowKey="act"
|
rowKey="act"
|
||||||
columns={columns}
|
columns={columns}
|
||||||
scroll={{ x: 'auto' }}
|
scroll={{ x: 'auto' }}
|
||||||
dataSource={tableData}
|
dataSource={opData}
|
||||||
pagination={{
|
pagination={{
|
||||||
hideOnSinglePage: true,
|
hideOnSinglePage: true,
|
||||||
showSizeChanger: true,
|
showSizeChanger: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user