import App from './App'
|
|
|
|
// #ifndef VUE3
|
|
import Vue from 'vue'
|
|
|
|
import './uni.promisify.adaptor'
|
|
|
|
Vue.config.productionTip = false
|
|
|
|
App.mpType = 'app'
|
|
|
|
import store from '@/store/store'
|
|
|
|
import './config'
|
|
import './utils/index.js'
|
|
|
|
import mixinConfigList from '@/mixins/configList.js'
|
|
|
|
Vue.mixin(mixinConfigList)
|
|
|
|
//组件注册
|
|
import configPopup from '@/components/config/configPopup.vue'
|
|
import navbar from '@/components/base/navbar.vue'
|
|
|
|
Vue.component('configPopup',configPopup)
|
|
Vue.component('navbar',navbar)
|
|
|
|
|
|
// #ifdef H5
|
|
import { fixH5Router } from '@/utils/h5-router-fix.js'
|
|
import { fixUrlParams } from '@/utils/h5-fix.js'
|
|
|
|
// 立即执行 H5 修复
|
|
fixH5Router();
|
|
fixUrlParams();
|
|
|
|
// 设置 Vue 全局错误处理器
|
|
Vue.config.errorHandler = function (err, vm, info) {
|
|
// 忽略已知的 H5 兼容性错误
|
|
if (err.message && (
|
|
err.message.includes("Cannot read property 'meta'") ||
|
|
err.message.includes('replaceState') ||
|
|
err.message.includes('showTabBar') ||
|
|
err.message.includes('History')
|
|
)) {
|
|
console.warn('H5兼容性错误已忽略:', err.message);
|
|
return;
|
|
}
|
|
// 其他错误正常输出
|
|
console.error('Vue Error:', err, vm, info);
|
|
};
|
|
|
|
import share from '@/utils/share.js'
|
|
share()
|
|
// #endif
|
|
|
|
|
|
// H5 环境下的特殊处理
|
|
// #ifdef H5
|
|
Vue.config.silent = false;
|
|
|
|
// 在创建 Vue 实例前添加额外的错误处理
|
|
const originalConsoleError = console.error;
|
|
console.error = function(...args) {
|
|
// 过滤掉一些已知的 H5 兼容性错误
|
|
const message = args.join(' ');
|
|
if (message.includes("Cannot read property 'meta'") ||
|
|
message.includes('replaceState') ||
|
|
message.includes('showTabBar')) {
|
|
console.warn('H5兼容性警告:', message);
|
|
return;
|
|
}
|
|
originalConsoleError.apply(console, args);
|
|
};
|
|
// #endif
|
|
|
|
try {
|
|
const app = new Vue({
|
|
...App,
|
|
store,
|
|
})
|
|
app.$mount()
|
|
} catch(e) {
|
|
console.error('Vue 应用启动失败:', e);
|
|
// #ifdef H5
|
|
// H5 环境下的降级处理
|
|
setTimeout(() => {
|
|
try {
|
|
const app = new Vue({
|
|
...App,
|
|
store,
|
|
})
|
|
app.$mount()
|
|
} catch(retryError) {
|
|
console.error('Vue 应用重试启动失败:', retryError);
|
|
}
|
|
}, 100);
|
|
// #endif
|
|
}
|
|
// #endif
|
|
|
|
// #ifdef VUE3
|
|
import {
|
|
createSSRApp
|
|
} from 'vue'
|
|
export function createApp() {
|
|
const app = createSSRApp(App)
|
|
return {
|
|
app
|
|
}
|
|
}
|
|
// #endif
|