|
@@ -10,6 +10,21 @@ import { filterAsyncRouter } from '@/store/modules/permission'
|
|
|
NProgress.configure({ showSpinner: false })
|
|
|
|
|
|
const whiteList = ['/login']
|
|
|
+export const loadMenus = (next, to) => {
|
|
|
+ buildMenus().then(res => {
|
|
|
+ const sdata = JSON.parse(JSON.stringify(res))
|
|
|
+ const rdata = JSON.parse(JSON.stringify(res))
|
|
|
+ const sidebarRoutes = filterAsyncRouter(sdata)
|
|
|
+ const rewriteRoutes = filterAsyncRouter(rdata, false, true)
|
|
|
+ rewriteRoutes.push({ path: '*', redirect: '/404', hidden: true })
|
|
|
+
|
|
|
+ store.dispatch('GenerateRoutes', rewriteRoutes).then(() => {
|
|
|
+ router.addRoutes(rewriteRoutes)
|
|
|
+ next({ ...to, replace: true })
|
|
|
+ })
|
|
|
+ store.dispatch('SetSidebarRouters', sidebarRoutes)
|
|
|
+ })
|
|
|
+}
|
|
|
|
|
|
router.beforeEach((to, from, next) => {
|
|
|
if (to.meta.title) {
|