From 2034aec6f767ec612caff3038146cdf2486beb59 Mon Sep 17 00:00:00 2001 From: douboer Date: Sat, 7 Feb 2026 14:47:38 +0800 Subject: [PATCH] update at 2026-02-07 14:47:38 --- frontend/src/App.vue | 42 +++++++++++++++++++++++++++- frontend/src/components/FontTree.vue | 6 +++- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/frontend/src/App.vue b/frontend/src/App.vue index e1a0ebd..a57d856 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -36,6 +36,17 @@ const isAllPreviewSelected = computed(() => { return previewIds.every(id => selectedIds.has(id)) }) +const isAllFavoriteSelected = computed(() => { + const favoriteIds = fontStore.favoriteFonts.map(font => font.id) + if (favoriteIds.length === 0) { + return false + } + + return favoriteIds.every(id => fontStore.previewFontIds.has(id)) +}) + +const favoriteFontCount = computed(() => fontStore.favoriteFonts.length) + // 加载字体列表 try { useFontLoader() @@ -186,6 +197,20 @@ function handleTogglePreviewSelectAll() { svgPreviewRef.value?.toggleSelectAllPreviewItems() } +function handleToggleFavoriteSelectAll() { + const favoriteIds = fontStore.favoriteFonts.map(font => font.id) + if (favoriteIds.length === 0) { + return + } + + if (isAllFavoriteSelected.value) { + favoriteIds.forEach(id => fontStore.removeFromPreview(id)) + return + } + + favoriteIds.forEach(id => fontStore.addToPreview(id)) +} + console.log('App.vue: script setup completed') @@ -304,7 +329,22 @@ console.log('App.vue: script setup completed')
-

已收藏字体

+
+

+ 已收藏字体({{ favoriteFontCount }}字体) +

+ +
diff --git a/frontend/src/components/FontTree.vue b/frontend/src/components/FontTree.vue index 12cf3bb..26be29c 100644 --- a/frontend/src/components/FontTree.vue +++ b/frontend/src/components/FontTree.vue @@ -48,6 +48,10 @@ function getCategoryFontIds(node: FontTreeNode): string[] { .map(child => child.fontInfo.id) } +function getCategoryFontCount(node: FontTreeNode): number { + return getCategoryFontIds(node).length +} + function isCategoryAllInPreview(node: FontTreeNode): boolean { const ids = getCategoryFontIds(node) return ids.length > 0 && ids.every(id => fontStore.previewFontIds.has(id)) @@ -101,7 +105,7 @@ function handleCategorySelectAll(node: FontTreeNode, event: Event) { @click="toggleExpand(node)" class="text-base font-medium text-black cursor-pointer flex-1 ml-2" > - {{ node.name }} + {{ node.name }}({{ getCategoryFontCount(node) }}字体)