mirror of
https://gitee.com/dcloud/uni-preset-vue
synced 2025-04-30 17:00:12 +08:00
37 lines
634 B
JavaScript
Executable File
37 lines
634 B
JavaScript
Executable File
import Vue from 'vue'
|
|
import App from './App'
|
|
|
|
Vue.config.productionTip = false
|
|
|
|
App.mpType = 'app'
|
|
|
|
function isPromise(obj) {
|
|
return (
|
|
!!obj &&
|
|
(typeof obj === "object" || typeof obj === "function") &&
|
|
typeof obj.then === "function"
|
|
);
|
|
}
|
|
|
|
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]);
|
|
}
|
|
});
|
|
});
|
|
},
|
|
});
|
|
|
|
const app = new Vue({
|
|
...App
|
|
})
|
|
app.$mount()
|