-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
68 lines (53 loc) · 1.11 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
62
63
64
65
66
67
68
// #ifndef VUE3
import Vue from 'vue'
import App from './App'
// 导入请求插件
import {$http} from "@escook/request-miniprogram"
import store from "./store/store.js"
// 挂载到全局对象uni上面
uni.$http=$http
// 配置跟地址baseurl
// $http.baseUrl="https://www.uinav.com"
$http.baseUrl="https://api-hmugo-web.itheima.net"
// 请求拦截器
$http.beforeRequest= function (option) {
uni.showLoading({
title:"数据正在加载…"
})
// console.log(option);
if(option.url.indexOf('/my/') !== -1) {
option.header={
Authorization:store.state.user.token
}
}
}
// 响应拦截器
$http.afterRequest=function(option) {
uni.hideLoading()
}
// 封装一个全局提示方法
uni.$showMsg=function(title="数据加载中……" , duration=2000){
uni.showToast({
title,
duration,
icon:"none"
})
}
Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({
...App,
store
})
app.$mount()
// #endif
// #ifdef VUE3
import { createSSRApp } from 'vue'
import App from './App.vue'
export function createApp() {
const app = createSSRApp(App)
return {
app
}
}
// #endif