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

混合 app 代理设置

上级 92e35a0e
......@@ -5,17 +5,6 @@
"npmClient": "yarn",
"webDir": "www",
"cordova": {},
"server": {
"url": "127.0.0.1:8080",
"hostname": "app",
"iosScheme": "vue",
"androidScheme": "vue",
"allowNavigation": [
"example.org",
"*.example.org",
"192.0.2.1"
]
},
"overrideUserAgent": "my custom user agent",
"appendUserAgent": "string to append",
"backgroundColor": "#ffffffff",
......
......@@ -6,7 +6,7 @@
"serve": "node --max_old_space_size=8102 ./node_modules/@vue/cli-service/bin/vue-cli-service serve --mode test",
"dev-serve": "node --max_old_space_size=8102 ./node_modules/@vue/cli-service/bin/vue-cli-service serve --mode development",
"build": "node --max_old_space_size=8102 ./node_modules/@vue/cli-service/bin/vue-cli-service build",
"build-native-app": "node --max_old_space_size=8102 ./node_modules/@vue/cli-service/bin/vue-cli-service build --mode nativeapp",
"build-hybrid-app": "node --max_old_space_size=8102 ./node_modules/@vue/cli-service/bin/vue-cli-service build --mode hybridapp",
"dev-build": "node --max_old_space_size=8102 ./node_modules/@vue/cli-service/bin/vue-cli-service build --mode development",
"lint": "vue-cli-service lint"
},
......
const ignoreProxyMap: Map<string, string> = new Map();
ignoreProxyMap.set('./assets/json/data-dictionary.json', './assets/json/data-dictionary.json')
export default ignoreProxyMap;
\ No newline at end of file
import { Store } from 'vuex';
import axios from 'axios';
import Router from 'vue-router';
import ignoreProxyMap from './ignore-proxy';
/**
......@@ -87,9 +88,13 @@ export class Interceptors {
const token = window.localStorage.getItem('token');
config.headers.Authorization = `Bearer ${token}`;
}
// if (!config.url.startsWith('https://') && !config.url.startsWith('http://')) {
// config.url = Environment.BaseUrl + config.url;
// }
// 混合 app 代理处理
if (Object.is(process.env.VUE_APP_CURRENTMODE, 'hybridapp') && !config.url.startsWith('https://') && !config.url.startsWith('http://')) {
if (!ignoreProxyMap.has(config.url)) {
config.url = process.env.proxy + config.url;
}
}
return config;
}, (error: any) => {
return Promise.reject(error);
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册