import Vue from 'vue'; import App from './App'; import store from '@/store'; App.mpType = 'app'; // global mixin import GlobalMixin from '@/mixin/index.js'; Vue.mixin(GlobalMixin); // router import { router, RouterMount } from '@/router'; Vue.use(router); // uView import uView from 'uview-ui'; Vue.use(uView); // cache import cache from '@/mixin/cache'; Vue.mixin(cache); 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({ store, ...App, }); // #ifdef H5 RouterMount(app, router, '#app'); // #endif app.$mount();