Commit d519fa32 authored by Star970321's avatar Star970321

修改

parent 077f62f4
......@@ -3,18 +3,27 @@ import store from './store';
import { Message } from 'element-ui';
import NProgress from 'nprogress';
import 'nprogress/nprogress.css';
import { getToken, getThirdPlatform } from '@/utils/auth';
import { getToken, getThirdPlatform, checkThirdPlatformChange, removeThirdPlatform, setThirdPlatform } from '@/utils/auth';
import { isRelogin } from '@/utils/request';
NProgress.configure({ showSpinner: false });
const whiteList = ['/login', "/404", "/401"];
router.beforeEach((to, from, next) => {
router.beforeEach(async (to, from, next) => {
// 存在platFormkey但是 已经更换 或本地session不存在 已经存在其它token 重写拉取所有信息
const onlyUrlKey = getThirdPlatform(true);
if (onlyUrlKey && checkThirdPlatformChange(onlyUrlKey)) {
// 前端退出登录
await store.dispatch("FedLogOut");
removeThirdPlatform();
setThirdPlatform(onlyUrlKey);
}
// 默认跳转路径 本系统跳转首页,第三方跳转宏观市场
const platFormKey = getThirdPlatform();
let defaultRedirectPath = platFormKey ? "/macro/nationalEconomies" : "/";
NProgress.start();
// 正常登录 不带第三方
if (getToken()) {
// tab页签title
const { tabTitle, url } = to.query;
......@@ -29,7 +38,10 @@ router.beforeEach((to, from, next) => {
if (!store.state?.user?.userId && !store.state?.user?.roles?.length) {
isRelogin.show = true;
// 判断当前用户是否已拉取完user_info信息
store.dispatch('GetInfo').then(() => {
store.dispatch('GetInfo').then(async (res) => {
if (res?.data?.isThirdPlatformLogin && !platFormKey) {
throw new Error("第三方登录重置,请重新使用platFormKey进入");
}
isRelogin.show = false;
store.dispatch('GenerateRoutes').then(accessRoutes => {
// 根据roles权限生成可访问的路由表
......
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