mirror of
https://github.com/FranP-code/ChatGPT.git
synced 2025-10-13 00:13:25 +00:00
chore: sync
This commit is contained in:
22
src/view/SyncMore/config.tsx
vendored
22
src/view/SyncMore/config.tsx
vendored
@@ -1,22 +0,0 @@
|
||||
// import { Switch, Tag, Tooltip } from 'antd';
|
||||
|
||||
export const genCmd = (act: string) => act.replace(/\s+|\/+/g, '_').replace(/[^\d\w]/g, '').toLocaleLowerCase();
|
||||
|
||||
export const recordColumns = () => [
|
||||
{
|
||||
title: 'URL',
|
||||
dataIndex: 'url',
|
||||
// fixed: 'left',
|
||||
// width: 120,
|
||||
key: 'url',
|
||||
},
|
||||
{
|
||||
title: 'File Type',
|
||||
dataIndex: 'file_type',
|
||||
key: 'file_type',
|
||||
// width: 200,
|
||||
},
|
||||
{
|
||||
title: 'Action',
|
||||
}
|
||||
];
|
||||
15
src/view/model/SyncMore/config.tsx
vendored
Normal file
15
src/view/model/SyncMore/config.tsx
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
export const recordColumns = () => [
|
||||
{
|
||||
title: 'URL',
|
||||
dataIndex: 'url',
|
||||
key: 'url',
|
||||
},
|
||||
{
|
||||
title: 'File Type',
|
||||
dataIndex: 'file_type',
|
||||
key: 'file_type',
|
||||
},
|
||||
{
|
||||
title: 'Action',
|
||||
}
|
||||
];
|
||||
@@ -9,7 +9,7 @@ export default function SyncMore() {
|
||||
<Button className="add-btn" type="primary">Add URL</Button>
|
||||
<Table
|
||||
key="id"
|
||||
rowKey="act"
|
||||
rowKey="url"
|
||||
columns={[]}
|
||||
scroll={{ x: 'auto' }}
|
||||
dataSource={[]}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Switch, Tag, Tooltip } from 'antd';
|
||||
|
||||
export const genCmd = (act: string) => act.replace(/\s+|\/+/g, '_').replace(/[^\d\w]/g, '').toLocaleLowerCase();
|
||||
import { genCmd } from '@/utils';
|
||||
|
||||
export const modelColumns = () => [
|
||||
{
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { Table, Button, message } from 'antd';
|
||||
import { Table, Button, message, Popconfirm } from 'antd';
|
||||
import { invoke } from '@tauri-apps/api';
|
||||
import { fetch, ResponseType } from '@tauri-apps/api/http';
|
||||
import { writeTextFile } from '@tauri-apps/api/fs';
|
||||
@@ -8,15 +8,14 @@ import useColumns from '@/hooks/useColumns';
|
||||
import useData from '@/hooks/useData';
|
||||
import useChatModel from '@/hooks/useChatModel';
|
||||
import useTable, { TABLE_PAGINATION } from '@/hooks/useTable';
|
||||
import { fmtDate, chatPromptsPath, GITHUB_PROMPTS_CSV_URL } from '@/utils';
|
||||
import { modelColumns, genCmd } from './config';
|
||||
import { fmtDate, chatPromptsPath, GITHUB_PROMPTS_CSV_URL, genCmd } from '@/utils';
|
||||
import { modelColumns } from './config';
|
||||
import './index.scss';
|
||||
|
||||
const promptsURL = 'https://github.com/f/awesome-chatgpt-prompts/blob/main/prompts.csv';
|
||||
|
||||
export default function LanguageModel() {
|
||||
const { rowSelection, selectedRowIDs } = useTable();
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [lastUpdated, setLastUpdated] = useState();
|
||||
const { modelJson, modelSet } = useChatModel('sys_sync_prompts');
|
||||
const { opData, opInit, opReplace, opReplaceItems, opSafeKey } = useData([]);
|
||||
@@ -35,7 +34,6 @@ export default function LanguageModel() {
|
||||
}, [modelJson?.sys_sync_prompts])
|
||||
|
||||
const handleSync = async () => {
|
||||
setLoading(true);
|
||||
const res = await fetch(GITHUB_PROMPTS_CSV_URL, {
|
||||
method: 'GET',
|
||||
responseType: ResponseType.Text,
|
||||
@@ -52,7 +50,6 @@ export default function LanguageModel() {
|
||||
} else {
|
||||
message.error('ChatGPT Prompts data sync failed, please try again!');
|
||||
}
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
@@ -79,7 +76,15 @@ export default function LanguageModel() {
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
<Button type="primary" loading={loading} onClick={handleSync}>Sync</Button>
|
||||
<Popconfirm
|
||||
title={<span>Data sync will enable all prompts,<br/>are you sure you want to sync?</span>}
|
||||
placement="topLeft"
|
||||
onConfirm={handleSync}
|
||||
okText="Yes"
|
||||
cancelText="No"
|
||||
>
|
||||
<Button type="primary">Sync</Button>
|
||||
</Popconfirm>
|
||||
</div>
|
||||
<div className="chat-table-tip">
|
||||
<span className="chat-model-path">URL: <a href={promptsURL} target="_blank" title={promptsURL}>f/awesome-chatgpt-prompts/prompts.csv</a></span>
|
||||
@@ -7,7 +7,7 @@ import useData from '@/hooks/useData';
|
||||
import useChatModel from '@/hooks/useChatModel';
|
||||
import useColumns from '@/hooks/useColumns';
|
||||
import { TABLE_PAGINATION } from '@/hooks/useTable';
|
||||
import { chatModelPath } from '@/utils';
|
||||
import { chatModelPath, genCmd } from '@/utils';
|
||||
import { modelColumns } from './config';
|
||||
import LanguageModelForm from './Form';
|
||||
import './index.scss';
|
||||
Reference in New Issue
Block a user