fix: slash command does not work (#207)

This commit is contained in:
lencx
2023-01-15 16:14:37 +08:00
parent 6d950c09e6
commit f0c635bd3b
7 changed files with 184 additions and 166 deletions

View File

@@ -53,25 +53,25 @@ interface EditRowProps {
}
export const EditRow: FC<EditRowProps> = ({ rowKey, row, actions }) => {
const [isEdit, setEdit] = useState(false);
const [val, setVal] = useState(row[rowKey]);
const [val, setVal] = useState(row[rowKey] || '');
const handleEdit = () => {
setEdit(true);
};
const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
setVal(e.target.value)
};
const handleSave = () => {
setEdit(false);
row[rowKey] = val;
row[rowKey] = val?.trim();
actions?.setRecord(row, 'rowedit')
};
return isEdit
? (
<Input.TextArea
<Input
value={val}
rows={1}
autoFocus
onChange={handleChange}
{...DISABLE_AUTO_COMPLETE}
onPressEnter={handleSave}

View File

@@ -69,7 +69,6 @@ export default function Download() {
const downloadDir = await path.join(await chatRoot(), 'download');
await fs.removeDir(downloadDir, { recursive: true });
await handleRefresh();
rowReset();
message.success('All files have been cleared!');
return;
}
@@ -88,6 +87,7 @@ export default function Download() {
const handleRefresh = async () => {
await invoke('download_list', { pathname: CHAT_DOWNLOAD_JSON, dir: 'download' });
rowReset();
const data = await refreshJson();
opInit(data);
};

View File

@@ -65,7 +65,6 @@ export default function Notes() {
const notesDir = await path.join(await chatRoot(), 'notes');
await fs.removeDir(notesDir, { recursive: true });
await handleRefresh();
rowReset();
message.success('All files have been cleared!');
return;
}
@@ -83,6 +82,7 @@ export default function Notes() {
const handleRefresh = async () => {
await invoke('download_list', { pathname: CHAT_NOTES_JSON, dir: 'notes' });
rowReset();
const data = await refreshJson();
opInit(data);
};
@@ -135,6 +135,7 @@ export default function Notes() {
>
<ReactMarkdown
children={source}
linkTarget="_blank"
components={{
code({node, inline, className, children, ...props}) {
const match = /language-(\w+)/.exec(className || '')