feat: 统一获取app-routes方法
This commit is contained in:
@ -3,13 +3,13 @@
|
|||||||
* @Date: 2025-06-19 01:45:53
|
* @Date: 2025-06-19 01:45:53
|
||||||
*/
|
*/
|
||||||
import type { RouteRecordRaw, RouteRecordNormalized } from 'vue-router';
|
import type { RouteRecordRaw, RouteRecordNormalized } from 'vue-router';
|
||||||
|
import { useRouter } from 'vue-router';
|
||||||
// import { useAppStore } from '@/stores';
|
|
||||||
import { appRoutes } from '@/router/routes';
|
|
||||||
import { useSidebarStore } from '@/stores/modules/side-bar';
|
import { useSidebarStore } from '@/stores/modules/side-bar';
|
||||||
|
|
||||||
export default function useMenuTree() {
|
export default function useMenuTree() {
|
||||||
// const appStore = useAppStore();
|
const router = useRouter();
|
||||||
|
const appRoutes = router.options.routes;
|
||||||
|
|
||||||
const sidebarStore = useSidebarStore();
|
const sidebarStore = useSidebarStore();
|
||||||
const appRoute = computed(() => {
|
const appRoute = computed(() => {
|
||||||
const _filterRoutes = appRoutes.filter((v) => v.meta?.id === sidebarStore.activeMenuId);
|
const _filterRoutes = appRoutes.filter((v) => v.meta?.id === sidebarStore.activeMenuId);
|
||||||
|
|||||||
@ -1,9 +1,7 @@
|
|||||||
import type { RouteRecordNormalized } from 'vue-router';
|
import { useRouter } from 'vue-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';
|
||||||
import router from '@/router';
|
|
||||||
import { glsWithCatch, slsWithCatch, rlsWithCatch } from '@/utils/stroage';
|
import { glsWithCatch, slsWithCatch, rlsWithCatch } from '@/utils/stroage';
|
||||||
|
|
||||||
interface UserInfo {
|
interface UserInfo {
|
||||||
@ -80,8 +78,10 @@ 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.getRoutes();
|
const appRoutes = router.options.routes;
|
||||||
|
|
||||||
appRoutes.forEach((route: any) => {
|
appRoutes.forEach((route: any) => {
|
||||||
if (!route.meta?.requiresAuth) {
|
if (!route.meta?.requiresAuth) {
|
||||||
|
|||||||
@ -69,7 +69,6 @@ import { now } from '@vueuse/core';
|
|||||||
import { trialProduct } from '@/api/all';
|
import { trialProduct } from '@/api/all';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
import CustomerServiceModal from '@/components/customer-service-modal.vue';
|
import CustomerServiceModal from '@/components/customer-service-modal.vue';
|
||||||
import { appRoutes } from '@/router/routes';
|
|
||||||
|
|
||||||
import { useSidebarStore } from '@/stores/modules/side-bar';
|
import { useSidebarStore } from '@/stores/modules/side-bar';
|
||||||
import { useEnterpriseStore } from '@/stores/modules/enterprise';
|
import { useEnterpriseStore } from '@/stores/modules/enterprise';
|
||||||
@ -119,7 +118,6 @@ const gotoModule = (menuId: number) => {
|
|||||||
'1': 'DataEngineHotTranslation',
|
'1': 'DataEngineHotTranslation',
|
||||||
'2': 'RepositoryBrandMaterials',
|
'2': 'RepositoryBrandMaterials',
|
||||||
};
|
};
|
||||||
console.log(routeMap[menuId]);
|
|
||||||
router.push({ name: routeMap[menuId] });
|
router.push({ name: routeMap[menuId] });
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user