49 lines
1.0 KiB
JavaScript
49 lines
1.0 KiB
JavaScript
import App from './App'
|
|
import Vue from 'vue'
|
|
import uView from 'uview-ui'
|
|
import store from './store/index.js'
|
|
import common from './common/index.js'
|
|
import api from '@/http/'
|
|
Vue.use(uView)
|
|
Vue.prototype.$common = common;
|
|
Vue.prototype.$api = api;
|
|
Vue.prototype.$baseUrl = "http://172.16.100.93:8015"; // "http://114.218.158.24:9022", "http://58.210.42.242:9085"
|
|
Vue.config.productionTip = false
|
|
App.mpType = 'app'
|
|
|
|
try {
|
|
function isPromise(obj) {
|
|
return (
|
|
!!obj &&
|
|
(typeof obj === "object" || typeof obj === "function") &&
|
|
typeof obj.then === "function"
|
|
);
|
|
}
|
|
|
|
// 统一 vue2 API Promise 化返回格式与 vue3 保持一致
|
|
uni.addInterceptor({
|
|
returnValue(res) {
|
|
if (!isPromise(res)) {
|
|
return res;
|
|
}
|
|
return new Promise((resolve, reject) => {
|
|
res.then((res) => {
|
|
if (res[0]) {
|
|
reject(res[0]);
|
|
} else {
|
|
resolve(res[1]);
|
|
}
|
|
});
|
|
});
|
|
},
|
|
});
|
|
} catch (error) { }
|
|
|
|
const app = new Vue({
|
|
...App,
|
|
store
|
|
})
|
|
app.$mount()
|
|
|
|
|