fix: menu label key value was undefined

This commit is contained in:
Corentin Thomasset 2022-06-02 00:57:17 +02:00
parent 5ab4dd3d4a
commit f48cd058cf
No known key found for this signature in database
GPG key ID: DBD997E935996158

View file

@ -1,5 +1,5 @@
<script lang="ts" setup> <script lang="ts" setup>
import { NIcon, useThemeVars } from 'naive-ui'; import { NIcon, useThemeVars, type MenuGroupOption } from 'naive-ui';
import { h } from 'vue'; import { h } from 'vue';
import { RouterLink, useRoute } from 'vue-router'; import { RouterLink, useRoute } from 'vue-router';
import { Heart, Menu2, Home2 } from '@vicons/tabler'; import { Heart, Menu2, Home2 } from '@vicons/tabler';
@ -19,17 +19,17 @@ const styleStore = useStyleStore();
const version = config.app.version; const version = config.app.version;
const commitSha = config.app.lastCommitSha.slice(0, 7); const commitSha = config.app.lastCommitSha.slice(0, 7);
const makeLabel = (text: string, to: string) => () => h(RouterLink, { to }, { default: () => text }); const makeLabel = (tool: ITool) => () => h(RouterLink, { to: tool.path }, { default: () => tool.name });
const makeIcon = (tool: ITool) => () => h(MenuIconItem, { tool }); const makeIcon = (tool: ITool) => () => h(MenuIconItem, { tool });
const menuOptions = toolsByCategory.map((category) => ({ const menuOptions: MenuGroupOption[] = toolsByCategory.map((category) => ({
label: category.name, label: category.name,
key: category.name, key: category.name,
type: 'group', type: 'group',
children: category.components.map((tool) => ({ children: category.components.map((tool) => ({
label: makeLabel(tool.name, tool.path), label: makeLabel(tool),
icon: makeIcon(tool), icon: makeIcon(tool),
key: name, key: tool.name,
})), })),
})); }));
</script> </script>