From 19740e7788954b313282ab7b8ef186cdc274c1ca Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Thu, 2 May 2024 11:48:51 +0800 Subject: [PATCH 1/2] feat(ui): sort items by file name --- packages/ui/client/composables/client/index.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/ui/client/composables/client/index.ts b/packages/ui/client/composables/client/index.ts index c484711bc532..9bde50766993 100644 --- a/packages/ui/client/composables/client/index.ts +++ b/packages/ui/client/composables/client/index.ts @@ -40,9 +40,19 @@ export const client = (function createVitestClient() { } })() +function sort(a: File, b: File) { + if (a.name < b.name) + return -1 + + if (a.name > b.name) + return 1 + + return 0 +} + export const config = shallowRef({} as any) export const status = ref('CONNECTING') -export const files = computed(() => client.state.getFiles()) +export const files = computed(() => client.state.getFiles().sort(sort)) export const current = computed(() => files.value.find(file => file.id === activeFileId.value)) export const currentLogs = computed(() => getTasks(current.value).map(i => i?.logs || []).flat() || []) From 24e379cb18bc2d82eb45a25d6f3f099c3c752323 Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Thu, 2 May 2024 21:50:37 +0800 Subject: [PATCH 2/2] feat: use localeCompare --- packages/ui/client/composables/client/index.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/packages/ui/client/composables/client/index.ts b/packages/ui/client/composables/client/index.ts index 9bde50766993..e05ee437b0e1 100644 --- a/packages/ui/client/composables/client/index.ts +++ b/packages/ui/client/composables/client/index.ts @@ -41,13 +41,7 @@ export const client = (function createVitestClient() { })() function sort(a: File, b: File) { - if (a.name < b.name) - return -1 - - if (a.name > b.name) - return 1 - - return 0 + return a.name.localeCompare(b.name) } export const config = shallowRef({} as any)