You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
1.8 KiB
65 lines
1.8 KiB
11 months ago
|
import App from './App'
|
||
|
|
||
|
// #ifndef VUE3
|
||
|
import Vue from 'vue'
|
||
|
Vue.config.productionTip = false
|
||
|
// 全局方法
|
||
|
import $ from './common/globalJs/globalJs.js'
|
||
|
Vue.prototype.$ = $
|
||
|
// // 拦截器
|
||
|
import request from './common/globalJs/request.js'
|
||
|
// // 全局配置
|
||
|
request.setConfig({
|
||
|
baseUrl: $.getBaseUrl(),
|
||
|
})
|
||
|
//
|
||
|
// // 设置请求拦截器
|
||
|
request.interceptors.request(config => {
|
||
|
// 配置参数和全局配置相同,此优先级最高,会覆盖在其他地方的相同配置参数
|
||
|
|
||
|
// 追加请求头,推荐
|
||
|
// config.header['content-type'] = 'application/json';
|
||
|
// config.header.token = 'token from interceptors';
|
||
|
|
||
|
// 覆盖请求头
|
||
|
// config.header = {
|
||
|
// 'content-type': 'application/json',
|
||
|
// 'token': 'token from interceptors'
|
||
|
// }
|
||
|
|
||
|
// return false; // 终止请求
|
||
|
// return Promise.reject('error from request interceptors'); // 向外层抛出错误,用catch捕获
|
||
|
return config; // 返回修改后的配置,如未修改也需添加这行
|
||
|
})
|
||
|
|
||
|
// // 设置响应拦截器
|
||
|
request.interceptors.response(res => {
|
||
|
return res; // 原样返回
|
||
|
// 接收请求,执行响应操作
|
||
|
// 您的逻辑......
|
||
|
|
||
|
// return false; // 阻止返回,页面不会接收返回值
|
||
|
// return {message: '自定义值,来自拦截器'}; // 返回您自定义的值,将覆盖原始返回值
|
||
|
// return Promise.reject('error from response interceptors') // 向外层抛出错误,用catch捕获
|
||
|
})
|
||
|
Vue.prototype.$request = request;
|
||
|
// 引入全局uView
|
||
|
import uView from '@/uni_modules/uview-ui'
|
||
|
Vue.use(uView)
|
||
|
App.mpType = 'app'
|
||
|
const app = new Vue({
|
||
|
...App
|
||
|
})
|
||
|
app.$mount()
|
||
|
// #endif
|
||
|
|
||
|
// #ifdef VUE3
|
||
|
import { createSSRApp } from 'vue'
|
||
|
export function createApp() {
|
||
|
const app = createSSRApp(App)
|
||
|
return {
|
||
|
app
|
||
|
}
|
||
|
}
|
||
|
// #endif
|