diff --git a/src/App.vue b/src/App.vue index 401ae335..1400d811 100644 --- a/src/App.vue +++ b/src/App.vue @@ -3,6 +3,7 @@ import { RouterView, useRoute } from 'vue-router'; import { NGlobalStyle, NMessageProvider, NNotificationProvider, darkTheme } from 'naive-ui'; import { get } from '@vueuse/core'; import { darkThemeOverrides, lightThemeOverrides } from './themes'; +import BaseLayout from './layouts/base.layout.vue'; import { layouts } from './layouts'; import { useStyleStore } from './stores/style.store'; import { useAppTheme } from './ui/theme/themes'; @@ -52,9 +53,13 @@ syncRef(locale, useStorage('locale', locale));
- - - + + + + + +
diff --git a/src/components/CollapsibleToolMenu.vue b/src/components/CollapsibleToolMenu.vue index 66e9f208..045b36f6 100644 --- a/src/components/CollapsibleToolMenu.vue +++ b/src/components/CollapsibleToolMenu.vue @@ -47,6 +47,17 @@ watchEffect(() => { const isToggling = ref(false); const menuContainerRefs = ref>({}); +// Every category starts coMount a category's items when it first opens, then keep themllapsed, so mounting all ~460 items up front built a +// menu nobody can see. Mount a category's items when it first opens, then keep them. +const openedCategories = ref>({}); +watchEffect(() => { + toolsByCategory.value.forEach(({ name }) => { + if (collapsedCategories.value[name] === false) { + openedCategories.value[name] = true; + } + }); +}); + function toggleCategoryCollapse({ name }: { name: string }) { collapsedCategories.value[name] = !collapsedCategories.value[name]; } @@ -88,11 +99,12 @@ function isCategoryActive(components: Tool[]): boolean { return components.some((tool) => tool.path === route.path); } +// Depends on the tool list only: holding the collapsed/active flags in here rebuilt +// every category's `tools` array, re-rendering all ~460 items on each navigation. const menuOptions = computed(() => toolsByCategory.value.map(({ name, components }) => ({ name, - isCollapsed: collapsedCategories.value[name], - isActive: isCategoryActive(components), + components, animationDuration: getAnimationDuration(components.length), tools: components.map((tool) => ({ label: makeLabel(tool), @@ -155,14 +167,10 @@ const themeVars = useThemeVars(); -
+