fix: 左侧菜单有时点击无反应
- 根因: 菜单项 RouterLink <a> 仅覆盖文字(~60px), 点图标/内边距/箭头时 naive-ui 只抛 update:value 未绑定导航→无反应 - 修复: n-menu 绑定 @update:value 统一 router.push, 任意位置可跳转 - 验证: 点外层区域修复前不跳、修复后跳转/video-tools CHANGELOG记录
This commit is contained in:
1 parent
4efc442977
commit
2ba520ca95
2 files changed
+17
-1
No files matched your search
@@ -1,7 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { useStorage } from '@vueuse/core';
|
||||
import { useThemeVars } from 'naive-ui';
|
||||
import { RouterLink, useRoute } from 'vue-router';
|
||||
import { RouterLink, useRoute, useRouter } from 'vue-router';
|
||||
import MenuIconItem from './MenuIconItem.vue';
|
||||
import type { Tool, ToolCategory } from '@/tools/tools.types';
|
||||
import { PROTECTED_TOOLS } from '@/tools/license/license';
|
||||
@@ -9,6 +9,15 @@ import { PROTECTED_TOOLS } from '@/tools/license/license';
|
||||
const props = withDefaults(defineProps<{ toolsByCategory?: ToolCategory[]; favoriteCategory?: ToolCategory | null }>(), { toolsByCategory: () => [], favoriteCategory: null });
|
||||
const { toolsByCategory } = toRefs(props);
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
|
||||
/** 点击菜单项任意位置(图标/内边距/箭头)都跳转,避免只有点到文字才生效 */
|
||||
function goTo(key: string | number) {
|
||||
const path = String(key);
|
||||
if (path && path !== route.path) {
|
||||
router.push(path);
|
||||
}
|
||||
}
|
||||
|
||||
const makeLabel = (tool: Tool) => () => h(RouterLink, { to: tool.path }, { default: () => tool.name });
|
||||
const makeIcon = (tool: Tool) => () => h(MenuIconItem, { tool });
|
||||
@@ -126,6 +135,7 @@ const themeVars = useThemeVars();
|
||||
:options="tools"
|
||||
:indent="10"
|
||||
:default-expand-all="true"
|
||||
@update:value="goTo"
|
||||
/>
|
||||
</div>
|
||||
</n-collapse-transition>
|
||||
|
||||
Reference in new issue
Block a user