chore: path

This commit is contained in:
lencx
2023-01-18 00:03:45 +08:00
parent f38d683f4e
commit a7d12bafc0
16 changed files with 144 additions and 56 deletions

View File

@@ -1,18 +1,17 @@
import { useEffect, useState } from 'react';
import { Table, Modal, Popconfirm, Button, message } from 'antd';
import { invoke, path, shell, fs } from '@tauri-apps/api';
import { invoke, path, fs } from '@tauri-apps/api';
import useInit from '@/hooks/useInit';
import useJson from '@/hooks/useJson';
import useData from '@/hooks/useData';
import useColumns from '@/hooks/useColumns';
import Markdown from '@/components/Markdown';
import FilePath from '@/components/FilePath';
import { useTableRowSelection, TABLE_PAGINATION } from '@/hooks/useTable';
import { chatRoot, CHAT_NOTES_JSON } from '@/utils';
import { notesColumns } from './config';
export default function Notes() {
const [notesPath, setNotesPath] = useState('');
const [source, setSource] = useState('');
const [isVisible, setVisible] = useState(false);
const { opData, opInit, opReplace, opSafeKey } = useData([]);
@@ -21,11 +20,6 @@ export default function Notes() {
const { json, refreshJson, updateJson } = useJson<any[]>(CHAT_NOTES_JSON);
const selectedItems = rowSelection.selectedRowKeys || [];
useInit(async () => {
const file = await path.join(await chatRoot(), CHAT_NOTES_JSON);
setNotesPath(file);
});
useEffect(() => {
if (!json || json.length <= 0) return;
opInit(json);
@@ -42,9 +36,6 @@ export default function Notes() {
setVisible(true);
return;
}
if (opInfo.opType === 'edit') {
alert('TODO');
}
if (opInfo.opType === 'delete') {
await fs.removeFile(file);
await handleRefresh();
@@ -111,11 +102,7 @@ export default function Notes() {
)}
</div>
</div>
<div className="chat-table-tip">
<div className="chat-file-path">
<div>PATH: <a onClick={() => shell.open(notesPath)} title={notesPath}>{notesPath}</a></div>
</div>
</div>
<FilePath paths={CHAT_NOTES_JSON} />
<Table
rowKey="id"
columns={columns}