From 5edb89ebb5a0cf46d0d104842359c841ba6e1e16 Mon Sep 17 00:00:00 2001 From: Baobhan Sith <80159437+Heavrnl@users.noreply.github.com> Date: Tue, 13 May 2025 00:53:20 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=B8=BA=E5=BF=AB=E6=8D=B7=E5=91=BD?= =?UTF-8?q?=E4=BB=A4=E5=88=97=E8=A1=A8=E6=B7=BB=E5=8A=A0=E5=A4=8D=E5=88=B6?= =?UTF-8?q?=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs #28 --- .../src/stores/quickCommands.store.ts | 6 ++++- .../frontend/src/views/QuickCommandsView.vue | 25 +++++++++++++++---- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/packages/frontend/src/stores/quickCommands.store.ts b/packages/frontend/src/stores/quickCommands.store.ts index 1e1c321..44a5524 100644 --- a/packages/frontend/src/stores/quickCommands.store.ts +++ b/packages/frontend/src/stores/quickCommands.store.ts @@ -19,7 +19,7 @@ export interface QuickCommandFE { // Renamed from QuickCommand if necessary } // 定义排序类型 -export type QuickCommandSortByType = 'name' | 'usage_count'; +export type QuickCommandSortByType = 'name' | 'usage_count' | 'last_used'; // 定义分组后的数据结构 export interface GroupedQuickCommands { @@ -118,6 +118,8 @@ export const useQuickCommandsStore = defineStore('quickCommands', () => { groupData.commands.sort((a, b) => { if (sortBy.value === 'usage_count') { if (b.usage_count !== a.usage_count) return b.usage_count - a.usage_count; + } else if (sortBy.value === 'last_used') { + if (b.updated_at !== a.updated_at) return b.updated_at - a.updated_at; } const nameA = a.name ?? a.command; // Fallback to command if name is null const nameB = b.name ?? b.command; @@ -140,6 +142,8 @@ export const useQuickCommandsStore = defineStore('quickCommands', () => { untaggedCommands.sort((a, b) => { if (sortBy.value === 'usage_count') { if (b.usage_count !== a.usage_count) return b.usage_count - a.usage_count; + } else if (sortBy.value === 'last_used') { + if (b.updated_at !== a.updated_at) return b.updated_at - a.updated_at; } const nameA = a.name ?? a.command; const nameB = b.name ?? b.command; diff --git a/packages/frontend/src/views/QuickCommandsView.vue b/packages/frontend/src/views/QuickCommandsView.vue index a9bafb1..8a193e3 100644 --- a/packages/frontend/src/views/QuickCommandsView.vue +++ b/packages/frontend/src/views/QuickCommandsView.vue @@ -105,7 +105,9 @@