From 936a045c884db2a68c98ac16efa952bf7e2dfaae Mon Sep 17 00:00:00 2001 From: godo Date: Fri, 10 Jan 2025 11:13:42 +0800 Subject: [PATCH] add copy files --- README.md | 1 + frontend/src/components/builtin/FileList.vue | 24 +++++- frontend/src/components/computer/Computer.vue | 9 ++- .../src/components/localchat/AiChatMain.vue | 81 ++++++++++--------- frontend/src/hook/useContextMenu.ts | 11 ++- godo/ai/server/chat.go | 48 +++++++++-- godo/ai/vector/vector.go | 5 +- godo/model/vec_doc.go | 4 + 8 files changed, 135 insertions(+), 48 deletions(-) diff --git a/README.md b/README.md index 42224f2..bfa52ba 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ - 修改锁屏机制,确保外网访问安全。 - 支持本地聊天ai对话文件和联网搜索。 - 支持知识库根据文件智能生成,一键生成知识库索引,一键搜索知识库。 +- 新增复制/粘贴快捷键 ## 🏭 第三阶段目标(一月底发布) 1. **文档处理与Markdown智能升级**:(已完成) diff --git a/frontend/src/components/builtin/FileList.vue b/frontend/src/components/builtin/FileList.vue index c793ba3..66196f3 100644 --- a/frontend/src/components/builtin/FileList.vue +++ b/frontend/src/components/builtin/FileList.vue @@ -252,7 +252,28 @@ function startDragApp(mouse: DragEvent, item: OsFileWithoutContent) { }); } } +document.addEventListener('copy', function () { + const files = chosenIndexs.value.map( + (index) => props.fileList[index] + ) + if (files.length > 0) { + copyFile(files); + chosenIndexs.value = []; + } +}); +// document.addEventListener('keydown', function (event) { +// // 检测 Control + C +// if (event.ctrlKey && event.key === 'c') { +// //console.log('Control + C 被按下'); +// copyFile( +// chosenIndexs.value.map( +// (index) => props.fileList[index] +// ) +// ); +// chosenIndexs.value = []; +// } +// }); function handleRightClick( mouse: MouseEvent, item: OsFileWithoutContent, @@ -361,11 +382,12 @@ function handleRightClick( title: t("tips"), content: "添加成功", }); + props.onRefresh(); } }) }, }); - }else{ + } else { menuArr.push({ label: "对话知识库", click: () => { diff --git a/frontend/src/components/computer/Computer.vue b/frontend/src/components/computer/Computer.vue index 0fc3a44..699a5c9 100644 --- a/frontend/src/components/computer/Computer.vue +++ b/frontend/src/components/computer/Computer.vue @@ -92,7 +92,7 @@ const currentList = ref>([]); const system = useSystem(); const { dragFileToDrop } = useFileDrag(system); -const { createDesktopContextMenu } = useContextMenu(); +const { createDesktopContextMenu,pasteFile } = useContextMenu(); // 选择保存文件路径时,传递选择路径 const props = defineProps({ translateSavePath: { @@ -312,6 +312,7 @@ let chosenCallback: (rect: Rect) => void = () => { // }; function onChosen(callback: (rect: Rect) => void) { + console.log(callback) chosenCallback = callback; } @@ -380,6 +381,12 @@ async function handleNavSearch(path: string) { setRouter("search:" + path); refersh(); } +document.addEventListener('paste', function() { + if(router_url.value !== "/" && !router_url.value.startsWith("/B")){ + pasteFile(router_url.value) + refersh(); + } +}); /* ------------ 路径输入框end ---------*/