初始化项目模板
This commit is contained in:
1 parent
80fd6a1d4b
commit
b3a69a1f27
69 files changed
+11088
No files matched your search
@@ -0,0 +1,83 @@
|
||||
import App from './App'
|
||||
import {
|
||||
nextTick
|
||||
} from "vue"
|
||||
// 全局注册layout组件
|
||||
import Layout from '@/components/layout.vue'
|
||||
// 引入pinia
|
||||
import pinia from "@/store/store.js"
|
||||
// 引入uvie-plus
|
||||
import uviewPlus from 'uview-plus'
|
||||
// 引入封装好的request
|
||||
import {
|
||||
request
|
||||
} from '@/utils/request.js';
|
||||
// 引入vue-i18n多语言翻译
|
||||
import i18n from '@/lang/index.js'
|
||||
// 引入animate.css 具体查看 https://www.dowebok.com/demo/2014/98/
|
||||
import 'animate.css';
|
||||
/* 非app断网提示 */
|
||||
// #ifndef APP-PLUS
|
||||
uni.onNetworkStatusChange((res) => {
|
||||
if (res.networkType === null || res.networkType === "unknown" || (!res.isConnected)) {
|
||||
uni.showModal({
|
||||
cancelText: i18n.global.t('modal.reStart'),
|
||||
confirmText: i18n.global.t('modal.reLoad'),
|
||||
content: i18n.global.t('modal.offNet'),
|
||||
title: i18n.global.t('modal.title'),
|
||||
success(res) {
|
||||
if (res.confirm) {
|
||||
uni.navigateBack(0)
|
||||
} else {
|
||||
uni.reLaunch({
|
||||
url: '/pages/index/index'
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
// #endif
|
||||
|
||||
// Vue2
|
||||
// #ifndef VUE3
|
||||
import Vue from 'vue'
|
||||
import './uni.promisify.adaptor'
|
||||
Vue.config.productionTip = false
|
||||
App.mpType = 'app'
|
||||
const app = new Vue({
|
||||
...App
|
||||
})
|
||||
app.$mount()
|
||||
// #endif
|
||||
|
||||
|
||||
// Vue3
|
||||
// #ifdef VUE3
|
||||
import {
|
||||
createSSRApp
|
||||
} from 'vue'
|
||||
|
||||
export function createApp() {
|
||||
const app = createSSRApp(App)
|
||||
app.component('Layout', Layout).use(uviewPlus).use(i18n).use(pinia)
|
||||
// 必须使用 nextTick,不然会有加载顺序问题,导致绑定失败
|
||||
nextTick(() => {
|
||||
// 代替 Vue.prototype.$xxx 绑定
|
||||
app.config.globalProperties.$request = request; // 自定义添加request
|
||||
// 全局异常拦截
|
||||
app.config.errorHandler = (err, instance, info) => {
|
||||
console.log(err, instance, info);
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '❌ ' + err.message,
|
||||
duration: 3000
|
||||
})
|
||||
}
|
||||
})
|
||||
return {
|
||||
app
|
||||
}
|
||||
}
|
||||
// #endif
|
||||
Reference in new issue
Block a user