Skip to content

Commit

Permalink
feat: 🎸 add copy sidebar menu
Browse files Browse the repository at this point in the history
  • Loading branch information
bingryan committed Jul 25, 2023
1 parent 2441253 commit f9b58a1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/store/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 } });
Expand Down
11 changes: 11 additions & 0 deletions src/views/siderbar/List.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
});
}
async function copySelect(id: number) {
await chatStore.copyChatSetting(id);
}
async function clearSelect(id: number) {
await chatStore.clearCache(id);
}
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit f9b58a1

Please sign in to comment.