修改封装删除路由并重新push
This commit is contained in:
@@ -121,7 +121,7 @@
|
|||||||
import 'moment/locale/zh-cn'
|
import 'moment/locale/zh-cn'
|
||||||
import { generateIndexRouter } from '@/utils/util'
|
import { generateIndexRouter } from '@/utils/util'
|
||||||
import store from '../../store'
|
import store from '../../store'
|
||||||
import router from '../../router'
|
import router,{resetRouter} from '../../router'
|
||||||
|
|
||||||
moment.locale('zh-cn')
|
moment.locale('zh-cn')
|
||||||
const EN = 'en-us'
|
const EN = 'en-us'
|
||||||
@@ -303,6 +303,11 @@
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
store.dispatch('GetPermissionList').then(res => {
|
store.dispatch('GetPermissionList').then(res => {
|
||||||
|
const menuData = res.result.menu;
|
||||||
|
resetRouter()
|
||||||
|
let constRoutes = [];
|
||||||
|
constRoutes = generateIndexRouter(menuData);
|
||||||
|
router.addRoutes(constRoutes)
|
||||||
this.$root.Bus.$emit('switchLanguage', localeval)
|
this.$root.Bus.$emit('switchLanguage', localeval)
|
||||||
this.isLoading = false
|
this.isLoading = false
|
||||||
this.localeval = localeval
|
this.localeval = localeval
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import App from './App.vue'
|
|||||||
import Storage from 'vue-ls'
|
import Storage from 'vue-ls'
|
||||||
import router from './router'
|
import router from './router'
|
||||||
import store from './store/'
|
import store from './store/'
|
||||||
|
|
||||||
import $ from 'jquery'
|
import $ from 'jquery'
|
||||||
import {
|
import {
|
||||||
VueAxios
|
VueAxios
|
||||||
|
|||||||
@@ -10,9 +10,15 @@ Router.prototype.push = function push(location, onResolve, onReject) {
|
|||||||
return originalPush.call(this, location).catch(err => err)
|
return originalPush.call(this, location).catch(err => err)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default new Router({
|
const createRouter = ()=> new Router({
|
||||||
mode: 'history',
|
mode: 'history',
|
||||||
base: process.env.BASE_URL,
|
base: process.env.BASE_URL,
|
||||||
scrollBehavior: () => ({ y: 0 }),
|
scrollBehavior: () => ({ y: 0 }),
|
||||||
routes: constantRouterMap
|
routes: constantRouterMap
|
||||||
})
|
})
|
||||||
|
const router = createRouter()
|
||||||
|
export function resetRouter () {
|
||||||
|
const newRouter = createRouter()
|
||||||
|
router.matcher = newRouter.matcher // reset router
|
||||||
|
}
|
||||||
|
export default router
|
||||||
Reference in New Issue
Block a user