Skip to content

Commit

Permalink
修复启动项目后白屏的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
zhigang.li@tendcloud.com committed Oct 18, 2018
1 parent 8c2548f commit c2d3969
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/components/main/components/side-menu/side-menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export default {
return this.$route.matched.map(item => item.name).filter(item => item !== name)
},
updateOpenName (name) {
if (name === 'home') this.openedNames = []
if (name === this.$config.homeName) this.openedNames = []
else this.openedNames = this.getOpenedNamesByActiveName(name)
}
},
Expand Down
5 changes: 2 additions & 3 deletions src/components/main/main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,9 @@ export default {
},
handleCloseTag (res, type, route) {
if (type === 'all') {
this.turnToPage('home')
this.turnToPage(this.$config.homeName)
} else if (routeEqual(this.$route, route)) {
if (type === 'others') {
} else {
if (type !== 'others') {
const nextRoute = getNextRoute(this.tagNavList, route)
this.$router.push(nextRoute)
}
Expand Down
4 changes: 3 additions & 1 deletion src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Router from 'vue-router'
import routes from './routers'
import store from '@/store'
import iView from 'iview'
import { getToken, canTurnTo } from '@/libs/util'
import { setToken, getToken, canTurnTo } from '@/libs/util'
import config from '@/config'
const { homeName } = config

Expand Down Expand Up @@ -36,13 +36,15 @@ router.beforeEach((to, from, next) => {
name: homeName // 跳转到homeName页
})
} else {
console.log(store.state.user.hasGetInfo)
if (store.state.user.hasGetInfo) {
turnTo(to, store.state.user.access, next)
} else {
store.dispatch('getUserInfo').then(user => {
// 拉取用户信息,通过用户权限和跳转的页面的name来判断是否有权限访问;access必须是一个数组,如:['super_admin'] ['super_admin', 'admin']
turnTo(to, user.access, next)
}).catch(() => {
setToken('')
next({
name: 'login'
})
Expand Down

0 comments on commit c2d3969

Please sign in to comment.