perf: 修复router为null

This commit is contained in:
rd
2025-07-28 12:04:04 +08:00
parent 077d45e58b
commit deea250557
2 changed files with 3 additions and 5 deletions

View File

@ -8,7 +8,7 @@ import { useSidebarStore } from '@/stores/modules/side-bar';
export default function useMenuTree() {
const router = useRouter();
const appRoutes = router.options.routes;
const appRoutes = router.options?.routes ?? [];
const sidebarStore = useSidebarStore();
const appRoute = computed(() => {

View File

@ -1,4 +1,4 @@
import { useRouter } from 'vue-router';
import router from '@/router';
import { defineStore } from 'pinia';
import { fetchProfileInfo } from '@/api/all/login';
import { useSidebarStore } from '@/stores/modules/side-bar';
@ -78,10 +78,8 @@ export const useUserStore = defineStore('user', {
},
getUserAllowAccessRoutes() {
const sidebarStore = useSidebarStore();
const router = useRouter();
const menuList = sidebarStore.menuList;
const appRoutes = router.options.routes;
const appRoutes = router.options?.routes ?? [];
appRoutes.forEach((route: any) => {
if (!route.meta?.requiresAuth) {