请求头
parent
30251f5035
commit
8743495495
|
|
@ -4,14 +4,14 @@ import { useUserStoreWithOut } from '@/store/modules/user';
|
|||
const { apiUrl } = useGlobSetting();
|
||||
const systemInfo = uni.getSystemInfoSync();
|
||||
const http = new Request();
|
||||
|
||||
console.log(systemInfo);
|
||||
http.setConfig((config) => {
|
||||
config.baseURL = apiUrl;
|
||||
config.timeout = 10000;
|
||||
config.header = Object.assign({
|
||||
Accept: 'application/json',
|
||||
// 'app-cli-os': android/ios,
|
||||
// 'app-cli-version': 100
|
||||
'app-cli-os': systemInfo.platform,
|
||||
'app-cli-version': systemInfo.appVersionCode
|
||||
}, config.header);
|
||||
/* 设置全局配置 */
|
||||
config.validateStatus = (statusCode) => {
|
||||
|
|
@ -51,7 +51,7 @@ http.interceptors.response.use(async (response) => {
|
|||
// 处理响应结果
|
||||
const { statusCode, data } = response
|
||||
if (statusCode >= 400) {
|
||||
if(statusCode === 401) {
|
||||
if (statusCode === 401) {
|
||||
const userStore = useUserStoreWithOut();
|
||||
userStore.logout();
|
||||
uni.navigateTo({
|
||||
|
|
|
|||
Loading…
Reference in New Issue