|
@@ -6,10 +6,10 @@ import { query } from '@/utils/query'
|
|
Vue.use(VueRouter)
|
|
Vue.use(VueRouter)
|
|
const routes = [
|
|
const routes = [
|
|
// 登陆页面
|
|
// 登陆页面
|
|
- {
|
|
|
|
- path: '/',
|
|
|
|
- redirect: '/home/overview', // 只有区域,及区域以上用户才能进入总部首页这一套
|
|
|
|
- },
|
|
|
|
|
|
+ // {
|
|
|
|
+ // path: '/',
|
|
|
|
+ // redirect: '/home/overview', // 只有区域,及区域以上用户才能进入总部首页这一套
|
|
|
|
+ // },
|
|
{
|
|
{
|
|
path: '/404',
|
|
path: '/404',
|
|
component: () => import('../components/404'),
|
|
component: () => import('../components/404'),
|
|
@@ -73,28 +73,23 @@ const router = new VueRouter({
|
|
routes,
|
|
routes,
|
|
})
|
|
})
|
|
//不需要token的路由
|
|
//不需要token的路由
|
|
-const ignore = ['/404', '/legendLibrary', '/legendRules']
|
|
|
|
|
|
+const ignore = ['/404', '/home/legendLibrary', '/home/legendRules']
|
|
router.beforeEach(async (to, from, next) => {
|
|
router.beforeEach(async (to, from, next) => {
|
|
if (!ignore.includes(to.path)) {
|
|
if (!ignore.includes(to.path)) {
|
|
console.log('vuex', store.state.accessLevel)
|
|
console.log('vuex', store.state.accessLevel)
|
|
- const token = query().token
|
|
|
|
- const ssoToken = store.getters['ssoToken']
|
|
|
|
- if (ssoToken) {
|
|
|
|
- store.commit('SETSSOTOKEN', ssoToken)
|
|
|
|
- await store.dispatch('getUserInfo', router)
|
|
|
|
|
|
+ const token = store.getters['ssoToken'] || query().token
|
|
|
|
+ if (token) {
|
|
|
|
+ store.commit('SETSSOTOKEN', token)
|
|
|
|
+ if (to.path == '/') {
|
|
|
|
+ next('/group')
|
|
|
|
+ }
|
|
|
|
+ if (to.path == '/group' || to.path == '/home/homepage') {
|
|
|
|
+ if (store.state.accessLevel == -1) {
|
|
|
|
+ await store.dispatch('getUserInfo', router)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
await store.dispatch('getFloors')
|
|
await store.dispatch('getFloors')
|
|
await store.dispatch('getBrand')
|
|
await store.dispatch('getBrand')
|
|
- let level = store.state.accessLevel
|
|
|
|
- console.log(level)
|
|
|
|
- // if (level ===0) {
|
|
|
|
- // next('/group')
|
|
|
|
- // } else {
|
|
|
|
- // next('/home/homepage')
|
|
|
|
- // }
|
|
|
|
- next()
|
|
|
|
- } else if (token) {
|
|
|
|
- store.commit('SETSSOTOKEN', token)
|
|
|
|
- await store.dispatch('getUserInfo', router)
|
|
|
|
next()
|
|
next()
|
|
} else {
|
|
} else {
|
|
let lastRoute = {
|
|
let lastRoute = {
|