提交 2f519bf9 编写于 作者: zcdtk's avatar zcdtk

拦截器处理

上级 efb12ebe
import { Store } from 'vuex';
import axios from 'axios';
import Router from 'vue-router';
import i18n from '@/locale';
import ignoreProxyMap from './ignore-proxy';
......@@ -77,17 +78,15 @@ export class Interceptors {
*/
private intercept(): void {
axios.interceptors.request.use((config: any) => {
let appdata: string | null = null;
if (this.router) {
appdata = this.store.getters.getAppData();
}
if (!Object.is(appdata, '')) {
config.headers.srfappdata = appdata;
let appdata: any = this.store.getters.getAppData();;
if (appdata && appdata.context) {
config.headers['srforgsectorid'] = appdata.context.srforgsectorid;
}
if (window.localStorage.getItem('token')) {
const token = window.localStorage.getItem('token');
config.headers.Authorization = `Bearer ${token}`;
}
config.headers['Accept-Language'] = i18n.locale;
// 混合 app 代理处理
if (Object.is(process.env.VUE_APP_CURRENTMODE, 'hybridapp') && !config.url.startsWith('https://') && !config.url.startsWith('http://')) {
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册