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')