请求服务器域名调整

This commit is contained in:
fan 2021-11-30 11:13:25 +08:00
parent e3da721faf
commit 068e0df43c
2 changed files with 22 additions and 7 deletions

View File

@ -1,6 +1,6 @@
<template> <template>
<div id="app"> <div id="app">
<router-view /> <router-view v-if="$store.state.user.baseUrl" />
<deomon-topic ref="deomonTopic" /> <deomon-topic ref="deomonTopic" />
<img v-show="loading" :src="loadingImg" class="AppAll"> <img v-show="loading" :src="loadingImg" class="AppAll">
</div> </div>
@ -15,6 +15,7 @@ import WindowResizeHandler from '@/mixin/WindowResizeHandler';
import LoadingImg from '@/assets/loading.gif'; import LoadingImg from '@/assets/loading.gif';
import { openIndexedDB } from '@/utils/indexedDb'; import { openIndexedDB } from '@/utils/indexedDb';
import { getBaseUrlByProject } from '@/api/projectServer'; import { getBaseUrlByProject } from '@/api/projectServer';
import { localPackageProject } from '@/scripts/ProjectConfig';
export default { export default {
name: 'App', name: 'App',
@ -63,11 +64,25 @@ export default {
this.loading = false; this.loading = false;
} }
}, },
created() { async created() {
const project = getSessionStorage('project'); let project = '';
getBaseUrlByProject(ProjectCode[project]).then(resp => { if (this.$route.query.project && this.$route.path.includes('login')) {
this.$store.dispatch('setBaseUrl', resp.data.domainName); project = this.$route.query.project;
}); const split = this.$route.path.split('/')[1];
if (process.env.VUE_APP_PRO) {
project = localPackageProject[process.env.VUE_APP_PRO + split];
} else if (split == 'design') {
project = project ? split + project : split;
} else if (split == 'login') {
project = project || 'login';
} else {
project = split;
}
} else {
project = getSessionStorage('project');
}
const resp = await getBaseUrlByProject(ProjectCode[project]);
resp && resp.data && this.$store.dispatch('setBaseUrl', resp.data.domainName);
if (project) { if (project) {
document.querySelector("link[rel*='icon']").href = loginInfo[project].linkIcon || ProjectIcon[project]; document.querySelector("link[rel*='icon']").href = loginInfo[project].linkIcon || ProjectIcon[project];
} }

View File

@ -19,7 +19,7 @@ const service = axios.create({
timeout: 600000 // 请求超时时间 timeout: 600000 // 请求超时时间
}); });
// request拦截器 // request拦截器108
service.interceptors.request.use(config => { service.interceptors.request.use(config => {
if (getToken()) { if (getToken()) {
config.headers['X-Token'] = getToken(); // 让每个请求携带自定义token 请根据实际情况自行修改 config.headers['X-Token'] = getToken(); // 让每个请求携带自定义token 请根据实际情况自行修改