You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1009 B
34 lines
1009 B
// 引入路由 |
|
import router from '@/router/index' |
|
import pinia from './store' |
|
import { constRouter } from '@/router/module/constRouter' |
|
import userStore from '@/store/module/user' |
|
|
|
import useSettingStore from '@/store/module/setting' |
|
const settingStore = useSettingStore(pinia) //重新指向pinia仓储 |
|
const useUserStore = userStore(pinia) |
|
router.beforeEach((to, _from, next) => { |
|
console.log(to.query) |
|
// 判断是否登录 |
|
if (!useUserStore.token) { |
|
// http://10.121.2.26:8866/portal#/home?code=abcdef |
|
if (Object.keys(to.query).length) { |
|
console.log('有参数') |
|
// 传入token |
|
useUserStore.verifyToken('1111111') |
|
} else { |
|
// window.location.replace('http://39.106.16.162/') |
|
} |
|
} |
|
|
|
let index = constRouter[0].children.findIndex((item: any) => { |
|
// console.log(to.path,item.path); |
|
|
|
return to.path.includes(item.path) |
|
}) |
|
// console.log(index); |
|
|
|
settingStore.setuseIndex(index) |
|
document.title = `教学一体化-${to.meta.title}` |
|
next() |
|
})
|
|
|