From 6c1b0f6fc81a4c10015c5e96e680327c4462dbb5 Mon Sep 17 00:00:00 2001 From: bingryan <41174435+bingryan@users.noreply.github.com> Date: Tue, 25 Jul 2023 11:27:13 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20add=20copy=20sidebar=20m?= =?UTF-8?q?enu=20(#55)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/chat.ts | 9 +++++++++ src/views/siderbar/List.vue | 11 +++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/store/chat.ts b/src/store/chat.ts index 6d6f1e3..6fe3744 100644 --- a/src/store/chat.ts +++ b/src/store/chat.ts @@ -184,6 +184,15 @@ export const useChatStore = defineStore(ID, { this.reloadRoute(id); }, + async copyChatSetting(id: number) { + const index = this.getChatSettingIndex(id); + const chatSetting = this.chatSetting[index]; + const newChatSetting = { ...chatSetting, id: new Date().getTime() }; + this.chatSetting.unshift(newChatSetting); + this.current = newChatSetting.id; + this.reloadRoute(newChatSetting.id); + }, + async reloadRoute(id?: number | null) { setState(this.$state); await router.push({ name: 'chat', params: { id } }); diff --git a/src/views/siderbar/List.vue b/src/views/siderbar/List.vue index 8fbc366..cf1e1d4 100644 --- a/src/views/siderbar/List.vue +++ b/src/views/siderbar/List.vue @@ -75,6 +75,10 @@ }); } + async function copySelect(id: number) { + await chatStore.copyChatSetting(id); + } + async function clearSelect(id: number) { await chatStore.clearCache(id); } @@ -109,6 +113,13 @@ }), onClick: () => clearSelect(id), }, + { + label: t('common.copy'), + icon: h('i', { + class: 'fa-solid fa-copy', + }), + onClick: () => copySelect(id), + }, ], zIndex: 60, minWidth: 100,