-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
53 lines (46 loc) · 1012 Bytes
/
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
// #ifndef VUE3
import Vue from 'vue'
import App from './App'
Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({
...App
})
app.$mount()
// #endif
// #ifdef VUE3
import store from '@/store/store.js'
import {
createSSRApp
} from 'vue'
import App from './App.vue'
import {
$http
} from '@escook/request-miniprogram'
export function createApp() {
uni.$http = $http
uni.$showMsg = function(title = '数据请求失败', duration = 1500) {
uni.showToast({
title: title,
duration: duration,
icon: 'none'
})
}
// 配置请求根路径
$http.baseUrl = 'https://api-hmugo-web.itheima.net'
$http.beforeRequest = function(options) {
// 判断当前请求的接口是否为有权限的接口
if (options.url.indexOf('/my') !== -1) {
options.header = {
// 从store中获取token
Authorization: store.state.m_user.token,
}
}
}
const app = createSSRApp(App)
app.use(store)
return {
app
}
}
// #endif