获取项目配置接口频繁调用调整
This commit is contained in:
parent
8c5f4b3cdf
commit
8a89c93603
@ -9,6 +9,7 @@ import { handlerUrl } from '@/utils/baseUrl';
|
|||||||
import { getFrontProjectConfigByLogin} from '@/api/projectConfig';
|
import { getFrontProjectConfigByLogin} from '@/api/projectConfig';
|
||||||
|
|
||||||
const whiteList = ['/login', '/design/login', '/loginNew', '/gzzbxy/relay', '/authorization', '/AUSline', '/AUStool', '/demo', '/thirdLogin']; // 不重定向白名单
|
const whiteList = ['/login', '/design/login', '/loginNew', '/gzzbxy/relay', '/authorization', '/AUSline', '/AUStool', '/demo', '/thirdLogin']; // 不重定向白名单
|
||||||
|
let frontConfigMark = '';
|
||||||
|
|
||||||
// 登录路径判断获取
|
// 登录路径判断获取
|
||||||
function getRouteInfo(to, markKey) {
|
function getRouteInfo(to, markKey) {
|
||||||
@ -81,8 +82,8 @@ router.beforeEach( async (to, from, next) => {
|
|||||||
// 登陆成功页面
|
// 登陆成功页面
|
||||||
project = getSessionStorage('project') || 'login';
|
project = getSessionStorage('project') || 'login';
|
||||||
}
|
}
|
||||||
const response = await getFrontProjectConfigByLogin(project);
|
if (frontConfigMark !== project) {
|
||||||
if (response.data) {
|
const response = await getFrontProjectConfigByLogin(project);
|
||||||
const {browserTitle, loginProLogo, baseApiUrl, baseSite, caseShow, helpShow, ossUrl, homeTitle, homeProLogoWidth} = response.data.viewSetting;
|
const {browserTitle, loginProLogo, baseApiUrl, baseSite, caseShow, helpShow, ossUrl, homeTitle, homeProLogoWidth} = response.data.viewSetting;
|
||||||
if (!store.state.user.baseUrl && project) {
|
if (!store.state.user.baseUrl && project) {
|
||||||
const urlData = handlerUrl();
|
const urlData = handlerUrl();
|
||||||
@ -91,6 +92,7 @@ router.beforeEach( async (to, from, next) => {
|
|||||||
store.dispatch('setOssUrl', ossUrl || urlData.OSS_URL);
|
store.dispatch('setOssUrl', ossUrl || urlData.OSS_URL);
|
||||||
subscribe();
|
subscribe();
|
||||||
}
|
}
|
||||||
|
frontConfigMark = response.data.markKey;
|
||||||
document.title = browserTitle;
|
document.title = browserTitle;
|
||||||
const url = loginProLogo ? store.state.user.ossUrl + '/logo/' + loginProLogo : '';
|
const url = loginProLogo ? store.state.user.ossUrl + '/logo/' + loginProLogo : '';
|
||||||
document.querySelector("link[rel*='icon']").href = url;
|
document.querySelector("link[rel*='icon']").href = url;
|
||||||
@ -100,32 +102,32 @@ router.beforeEach( async (to, from, next) => {
|
|||||||
store.dispatch('setLoginProLogo', url);
|
store.dispatch('setLoginProLogo', url);
|
||||||
store.dispatch('setHomeTitle', homeTitle);
|
store.dispatch('setHomeTitle', homeTitle);
|
||||||
NProgress.start();
|
NProgress.start();
|
||||||
const loginPath = getRouteInfo(to, response.data.markKey);
|
}
|
||||||
const token = to.query.token;
|
const loginPath = getRouteInfo(to, frontConfigMark);
|
||||||
if (/demoTraining/.test(to.path) && token) {
|
const token = to.query.token;
|
||||||
const header = { group: to.query.group, 'X-Token': token };
|
if (/demoTraining/.test(to.path) && token) {
|
||||||
setToken(token);
|
const header = { group: to.query.group, 'X-Token': token };
|
||||||
store.commit('SET_TOKEN', token);
|
setToken(token);
|
||||||
store.commit('SUBSCRIBE', { header, type: '' });
|
store.commit('SET_TOKEN', token);
|
||||||
|
store.commit('SUBSCRIBE', { header, type: '' });
|
||||||
|
next();
|
||||||
|
} else if (getToken()) {
|
||||||
|
if (to.path === loginPath) {
|
||||||
|
// 登录页面不拦截
|
||||||
next();
|
next();
|
||||||
} else if (getToken()) {
|
|
||||||
if (to.path === loginPath) {
|
|
||||||
// 登录页面不拦截
|
|
||||||
next();
|
|
||||||
} else {
|
|
||||||
// 进入系统重新计算路由
|
|
||||||
handleRoute(to, next, loginPath);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (whiteList.indexOf(to.path) !== -1) {
|
// 进入系统重新计算路由
|
||||||
// 在免登录白名单,直接进入
|
handleRoute(to, next, loginPath);
|
||||||
next();
|
}
|
||||||
} else if (to.path.substr(0, 13) == whiteList[2]) {
|
} else {
|
||||||
next();
|
if (whiteList.indexOf(to.path) !== -1) {
|
||||||
} else {
|
// 在免登录白名单,直接进入
|
||||||
// 否则全部重定向到登录页
|
next();
|
||||||
next(loginPath);
|
} else if (to.path.substr(0, 13) == whiteList[2]) {
|
||||||
}
|
next();
|
||||||
|
} else {
|
||||||
|
// 否则全部重定向到登录页
|
||||||
|
next(loginPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user