Commit b011dfcc authored by 张伯涛's avatar 张伯涛

修改

parent 0488b90c
...@@ -14,6 +14,7 @@ NProgress.configure({ showSpinner: false }) // NProgress Configuration ...@@ -14,6 +14,7 @@ NProgress.configure({ showSpinner: false }) // NProgress Configuration
const whiteList = ['/auth-redirect', '/bind', '/register', '/login', '/forgetPwd'] const whiteList = ['/auth-redirect', '/bind', '/register', '/login', '/forgetPwd']
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
console.log('beforeEach', to)
NProgress.start() NProgress.start()
if (getToken()) { if (getToken()) {
/* has token*/ /* has token*/
...@@ -33,14 +34,13 @@ router.beforeEach((to, from, next) => { ...@@ -33,14 +34,13 @@ router.beforeEach((to, from, next) => {
// 判断用户是否有路由 // 判断用户是否有路由
if (routers.accessedRoutes && routers.accessedRoutes.length > 0 && routers.getRouters && routers.getRouters.length > 0) { if (routers.accessedRoutes && routers.accessedRoutes.length > 0 && routers.getRouters && routers.getRouters.length > 0) {
console.log('routers.accessedRoutes', routers.accessedRoutes) console.log('routers.accessedRoutes', routers.accessedRoutes)
router.addRoutes(routers.accessedRoutes) // 动态添加可访问路由表
console.log('routers.accessedRoutes[0].children[0].path', routers.accessedRoutes[0].children[0].path) console.log('routers.accessedRoutes[0].children[0].path', routers.accessedRoutes[0].children[0].path)
router.push({ path: routers.accessedRoutes[0].children[0].path }) // router.push({ path: routers.accessedRoutes[0].children[0].path })
next() // next()
// next({ path: routers.accessedRoutes[0].children[0].path, replace: true }) console.log('tototo', to)
// router.addRoutes(routers.accessedRoutes) // 动态添加可访问路由表 router.addRoutes(routers.accessedRoutes) // 动态添加可访问路由表
// next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 // next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
next({ path: routers.accessedRoutes[0].children[0].path, replace: true })
// 测试 默认静态页面 // 测试 默认静态页面
// store.dispatch('permission/generateRoutes', { roles }).then(accessRoutes => { // store.dispatch('permission/generateRoutes', { roles }).then(accessRoutes => {
// 根据roles权限生成可访问的路由表 // 根据roles权限生成可访问的路由表
......
...@@ -33,6 +33,7 @@ const permission = { ...@@ -33,6 +33,7 @@ const permission = {
} }
if (accessedRoutes[0]) { if (accessedRoutes[0]) {
const firstChild = getFirstChild(accessedRoutes[0]) const firstChild = getFirstChild(accessedRoutes[0])
console.log('firstChild', firstChild)
accessedRoutes.push({ path: '*', redirect: '/404', hidden: true }) accessedRoutes.push({ path: '*', redirect: '/404', hidden: true })
accessedRoutes.push({ path: '/', redirect: firstChild, hidden: true }) accessedRoutes.push({ path: '/', redirect: firstChild, hidden: true })
commit('SET_ROUTES', accessedRoutes) commit('SET_ROUTES', accessedRoutes)
......
...@@ -149,7 +149,7 @@ export default { ...@@ -149,7 +149,7 @@ export default {
// this.$router.push({ path: `http://main.court.com${this.redirect || "/"}` }); // this.$router.push({ path: `http://main.court.com${this.redirect || "/"}` });
this.loading = false this.loading = false
// this.$router.push('/welcome') // this.$router.push('/welcome')
this.$router.push('/Home') this.$router.push('/test')
this.$store.commit('SET_NAME', res.data.user.username) this.$store.commit('SET_NAME', res.data.user.username)
}) })
.catch(() => { .catch(() => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment