请求服务器域名调整

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

View File

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