fix: 我的收藏分组独立保留 — 收藏的受控工具不再被抽进授权应用组, favorites置顶原样显示, 授权组仅从原始分类抽取

This commit is contained in:
personal82555 committed 2026-10-12 21:01:58 +08:00
1 parent 214a4486d3
commit 08fcce6517
2 files changed
+11 -5

No files matched your search

+6 -3
View File
@@ -6,7 +6,7 @@ import MenuIconItem from './MenuIconItem.vue';
import type { Tool, ToolCategory } from '@/tools/tools.types';
import { PROTECTED_TOOLS } from '@/tools/license/license';
const props = withDefaults(defineProps<{ toolsByCategory?: ToolCategory[] }>(), { toolsByCategory: () => [] });
const props = withDefaults(defineProps<{ toolsByCategory?: ToolCategory[]; favoriteCategory?: ToolCategory | null }>(), { toolsByCategory: () => [], favoriteCategory: null });
const { toolsByCategory } = toRefs(props);
const route = useRoute();
@@ -49,8 +49,7 @@ function collapseAll() {
const PAID_GROUP_NAME = '授权应用';
const menuOptions = computed(() => {
// pull licensed tools out of their original categories (dedupe by path:
// a paid tool may appear in both the favorites category and its own category)
// pull licensed tools out of their original categories (favorites stay intact)
const paidTools: Tool[] = [];
const paidPaths = new Set<string>();
const remaining = toolsByCategory.value
@@ -80,6 +79,10 @@ const menuOptions = computed(() => {
});
const options = [];
// favorites first, shown as-is (user shortcuts must stay visible)
if (props.favoriteCategory && props.favoriteCategory.components.length > 0) {
options.push(toOption(props.favoriteCategory.name, props.favoriteCategory.components));
}
if (paidTools.length > 0) {
options.push(toOption(PAID_GROUP_NAME, paidTools));
}
+5 -2
View File
@@ -31,8 +31,11 @@ const { favoriteTools, toolsByCategory } = storeToRefs(toolStore);
const NO_SIDEBAR = new Set(['/user-center', '/admin']);
const fullBleed = computed(() => NO_SIDEBAR.has(route.path));
const favoriteCategory = computed<ToolCategory | null>(() =>
favoriteTools.value.length > 0 ? { name: t('tools.categories.favorite-tools'), components: favoriteTools.value } : null,
);
const tools = computed<ToolCategory[]>(() => [
...(favoriteTools.value.length > 0 ? [{ name: t('tools.categories.favorite-tools'), components: favoriteTools.value }] : []),
...toolsByCategory.value,
]);
</script>
@@ -62,7 +65,7 @@ const tools = computed<ToolCategory[]>(() => [
</div>
</div>
<CollapsibleToolMenu :tools-by-category="tools" />
<CollapsibleToolMenu :tools-by-category="tools" :favorite-category="favoriteCategory" />
<div class="footer">
<div>