Files
ClassContent/历届学生/吴欣阳/项目开发/上课项目/vue管理后台/src/utils/index.js
2024-09-27 02:06:13 +08:00

50 lines
1.2 KiB
JavaScript

class Utils {
createdRouterConfig (router) {
var menu = JSON.parse(localStorage.getItem("menu"));
var RouterConfig = []
menu.forEach(v => {
if (v.hasOwnProperty("children")) {
v.children.forEach(k => {
RouterConfig.push({
path: v.path + k.path,
name: k.path.split("/")[1],
component: () => import(`@/views${v.path}${k.path}.vue`),
meta: {
isLogin: true,
keepAlive: false
}
})
})
} else {
var fileName = v.path.replace(
v.path.substring(1,2),
v.path.substring(0,2).split("/")[1].toUpperCase()
)
RouterConfig.push({
path: v.path,
name: v.path.split("/")[1],
component: () => import(`@/views${fileName}.vue`),
meta: {
isLogin: true,
keepAlive: false
}
})
}
});
var fa = [
{
path: '/',
name: 'layout',
component: () => import(/* webpackChunkName: "Layout" */ '@/views/Layout.vue'),
children: RouterConfig
}
];
router.addRoutes(fa)
}
}
export default new Utils();