mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-uniapp.git
synced 2026-08-06 02:47:25 +08:00
将 lilishop-uniapp 从 Vue2/uView 1.6 迁移到 Vue3/uview-plus,优先支持 H5/微商城与微信小程序;移除 vendored uview-ui,改用 npm 依赖、Vuex4 与迁移脚本/补丁,并补充 VUE3_MIGRATION.md 回归清单。 Co-authored-by: Cursor <cursoragent@cursor.com>
68 lines
2.0 KiB
JavaScript
68 lines
2.0 KiB
JavaScript
import { createSSRApp } from 'vue'
|
||
import App from './App'
|
||
import uviewPlus, { setConfig } from 'uview-plus'
|
||
import store from './store'
|
||
import config from '@/config/config'
|
||
import airBtn from '@/components/m-airbtn/index.vue'
|
||
import mpShare from '@/utils/mpShare.js'
|
||
import * as filterUtils from './utils/filters.js'
|
||
|
||
export function createApp() {
|
||
const app = createSSRApp(App)
|
||
|
||
// #ifdef MP-WEIXIN
|
||
// 微信开发者工具部分版本在输出 Vue warn 时会触发
|
||
// TypeError: Cannot read property '__global' of null,自定义 handler 绕过默认路径
|
||
app.config.warnHandler = (msg, _instance, trace) => {
|
||
if (
|
||
typeof msg === 'string' &&
|
||
msg.includes('enumerating keys on a component instance')
|
||
) {
|
||
return
|
||
}
|
||
try {
|
||
console.warn(`[Vue warn]: ${msg}${trace || ''}`)
|
||
} catch (e) {
|
||
// 忽略开发者工具 console 代理异常
|
||
}
|
||
}
|
||
// #endif
|
||
|
||
app.use(store)
|
||
app.use(uviewPlus)
|
||
|
||
// uview-plus 的图标字体默认每个 u-icon 实例都会触发 uni.loadFontFace,
|
||
// 导致进入页面时同一字体被反复请求。开启 loadFontOnce 后全局只加载一次。
|
||
setConfig({
|
||
config: {
|
||
loadFontOnce: true,
|
||
},
|
||
})
|
||
|
||
app.config.globalProperties.$store = store
|
||
app.config.globalProperties.$mainColor = config.mainColor
|
||
app.config.globalProperties.$lightColor = config.lightColor
|
||
app.config.globalProperties.$aiderLightColor = config.aiderLightColor
|
||
|
||
const filterMethods = {}
|
||
Object.keys(filterUtils).forEach((key) => {
|
||
if (typeof filterUtils[key] === 'function') {
|
||
filterMethods[key] = filterUtils[key]
|
||
}
|
||
})
|
||
app.mixin({ methods: filterMethods })
|
||
app.mixin(mpShare)
|
||
|
||
// #ifdef H5
|
||
if (config.enableMiniBarStartUpApp) {
|
||
const mountPoint = document.createElement('div')
|
||
document.body.appendChild(mountPoint)
|
||
createSSRApp(airBtn).mount(mountPoint)
|
||
}
|
||
// #endif
|
||
|
||
return {
|
||
app
|
||
}
|
||
}
|