123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- import App from './App'
- import vueComposition from "@vue/composition-api"
- Vue.use(vueComposition)
- // #ifndef VUE3
- import Vue from 'vue'
- import {
- router,
- RouterMount
- } from "@/common/router";
- import store from "@/common/store";
- import common from "@/common";
- import uView from '@/uni_modules/uview-ui'
- // 引入uView对小程序分享的mixin封装
- let mpShare = require('@/uni_modules/uview-ui/libs/mixin/mpShare.js');
- Vue.mixin(mpShare)
- Vue.config.productionTip = false
- App.mpType = 'app'
- // store处理
- Vue.prototype.$store = store
- //引入路由
- Vue.use(router);
- // 引入全局uView
- Vue.use(uView);
- // 加载common
- Vue.use(common);
- 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
- })
- // 去除console
- if (process.env.NODE_ENV !== "development") {
- console.log = () => {}
- }
- // http拦截器,将此部分放在new Vue()和app.$mount()之间,才能App.vue中正常使用
- require('@/common/request/index.js')(app)
- // 引入公共方法
- import { downloadFile, goChat, openFile, setCache, exportWord, filterSize, countChar, textFormat, accMul, accDiv, accAdd, accSub, parseDate } from '@/common/js/public.js'
- // #ifdef APP
- // app文件分享
- import {anyShareFile} from '@/common/js/appFileShare.js'
- Vue.prototype.$anyShareFile = anyShareFile
- // #endif
- Vue.prototype.$downloadFile = downloadFile
- Vue.prototype.$openFile = openFile
- Vue.prototype.$filterSize = filterSize
- Vue.prototype.$goChat = goChat
- Vue.prototype.$setCache = setCache
- Vue.prototype.$exportWord = exportWord
- Vue.prototype.$countChar = countChar
- Vue.prototype.$textFormat = textFormat
- Vue.prototype.$accMul = accMul
- Vue.prototype.$accDiv = accDiv
- Vue.prototype.$accAdd = accAdd
- Vue.prototype.$accSub = accSub
- Vue.prototype.$parseDate = parseDate
- // #ifdef H5
- RouterMount(app, router, "#app");
- // #endif
- // #ifndef H5
- app.$mount();
- // #endif
- // #endif
- // #ifdef VUE3
- import {
- createSSRApp
- } from 'vue'
- export function createApp() {
- const app = createSSRApp(App)
- return {
- app
- }
- }
- // #endif
|