-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.js
61 lines (54 loc) · 1.36 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import App from './App';
import http from './components/firstui/fui-request'
// 全局mixins,用于实现setData等功能,请勿删除!';
import Mixin from './polyfill/mixins';
// #ifndef VUE3
import Vue from 'vue';
Vue.mixin(Mixin);
Vue.config.productionTip = false;
App.mpType = 'app';
const app = new Vue({
...App
});
app.$mount();
// #endif
//初始化请求配置项
http.create({
//接口域名
// host: 'http://zzsqwq.cn:12080/api/v1',
// host: 'http://127.0.0.1:8080/api/v1',
// host: 'http://192.168.31.249:8080/api/v1',
// host: 'http://192.168.1.244:8080/api/v1',
host: "https://api.zzsqwq.cn:8443/api/v1",
// host: "https://127.0.0.1:8443/api/v1",
header: {
'content-type': 'application/json',
}
})
//请求拦截
http.interceptors.request.use(config => {
//请求之前可在请求头中加入token等信息
let token = uni.getStorageSync('token');
if (config.header) {
config.header['Authorization'] = token
} else {
config.header = {
'Authorization': token
}
}
return config
})
// #ifndef VUE3
Vue.prototype.http = http
// #endif
// #ifdef VUE3
import { createSSRApp } from 'vue';
export function createApp() {
const app = createSSRApp(App);
app.config.globalProperties.http = http
app.mixin(Mixin);
return {
app
};
}
// #endif