SmartSubstationPlatform/riis-web/src/router/index.ts
2025-04-24 14:53:21 +08:00

98 lines
2.4 KiB
TypeScript

import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router';
import { usePermissionStoreHook } from '@/store/modules/permission';
export const Layout = () => import('/src/layout/index.vue');
// 静态路由
export const constantRoutes: RouteRecordRaw[] = [
{
path: '/redirect',
component: Layout,
meta: { hidden: true },
children: [
{
path: '/redirect/:path(.*)',
component: () => import('/src/views/redirect/index.vue')
}
]
},
{
path: '/login',
component: () => import('/src/views/login/index.vue'),
meta: { hidden: true }
},
{
path: '/areaboard',
component: () => import('/src/views/monitorsystem/areaboard/index.vue'),
meta: { hidden: true }
},
{
path: '/monitorsystem',
component: () => import('/src/views/monitorsystem/index.vue'),
redirect: '/stationboard',
children: [
{
path: '/stationboard',
component: () => import('/src/views/monitorsystem/stationboard/index.vue'),
name: '大屏首页',
meta: { hidden: true }
}
]
},
{
path: '/404',
component: () => import('/src/views/error-page/404.vue'),
meta: { hidden: true }
},
{
path: '/',
component: Layout,
redirect: '/dashboard',
children: [
{
path: 'dashboard',
component: () => import('/src/views/dashboard/index.vue'),
name: '首页',
meta: { title: 'dashboard', icon: 'homepage', affix: true }
},
{
path: 'personalCenter',
component: () => import('/src/views/system/user/personalCenter.vue'),
name: '个人中心',
meta: { title: 'personalCenter',hidden: true, icon: 'personalCenter' }
},
{
path: '401',
component: () => import('/src/views/error-page/401.vue'),
meta: { hidden: true }
},
]
}
];
// 创建路由
const router = createRouter({
history: createWebHashHistory(),
routes: constantRoutes as RouteRecordRaw[],
// 刷新时,滚动条位置还原
scrollBehavior: () => ({ left: 0, top: 0 })
});
// 重置路由
export function resetRouter() {
const permissionStore = usePermissionStoreHook();
permissionStore.routes.forEach(route => {
const name = route.name;
if (name && router.hasRoute(name)) {
router.hasRoute(name) && router.removeRoute(name);
}
});
}
export default router;