perf: 修复router为null
This commit is contained in:
@ -8,7 +8,7 @@ import { useSidebarStore } from '@/stores/modules/side-bar';
|
|||||||
|
|
||||||
export default function useMenuTree() {
|
export default function useMenuTree() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const appRoutes = router.options.routes;
|
const appRoutes = router.options?.routes ?? [];
|
||||||
|
|
||||||
const sidebarStore = useSidebarStore();
|
const sidebarStore = useSidebarStore();
|
||||||
const appRoute = computed(() => {
|
const appRoute = computed(() => {
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { useRouter } from 'vue-router';
|
import router from '@/router';
|
||||||
import { defineStore } from 'pinia';
|
import { defineStore } from 'pinia';
|
||||||
import { fetchProfileInfo } from '@/api/all/login';
|
import { fetchProfileInfo } from '@/api/all/login';
|
||||||
import { useSidebarStore } from '@/stores/modules/side-bar';
|
import { useSidebarStore } from '@/stores/modules/side-bar';
|
||||||
@ -78,10 +78,8 @@ export const useUserStore = defineStore('user', {
|
|||||||
},
|
},
|
||||||
getUserAllowAccessRoutes() {
|
getUserAllowAccessRoutes() {
|
||||||
const sidebarStore = useSidebarStore();
|
const sidebarStore = useSidebarStore();
|
||||||
const router = useRouter();
|
|
||||||
|
|
||||||
const menuList = sidebarStore.menuList;
|
const menuList = sidebarStore.menuList;
|
||||||
const appRoutes = router.options.routes;
|
const appRoutes = router.options?.routes ?? [];
|
||||||
|
|
||||||
appRoutes.forEach((route: any) => {
|
appRoutes.forEach((route: any) => {
|
||||||
if (!route.meta?.requiresAuth) {
|
if (!route.meta?.requiresAuth) {
|
||||||
|
|||||||
Reference in New Issue
Block a user