first commit
This commit is contained in:
60
main.js
Normal file
60
main.js
Normal file
@@ -0,0 +1,60 @@
|
||||
import App from './App'
|
||||
|
||||
// #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
|
||||
|
||||
// #ifdef VUE3
|
||||
import {
|
||||
createSSRApp
|
||||
} from 'vue'
|
||||
import { createPinia } from 'pinia'
|
||||
|
||||
// // 在不支持 \p 的环境下,用普通正则替换
|
||||
// if (typeof RegExp !== 'undefined') {
|
||||
// const originalRegExp = window.RegExp
|
||||
|
||||
// // 检测是否支持 Unicode 属性
|
||||
// let supportsUnicodeProperty = false
|
||||
// try {
|
||||
// new RegExp('\\p{L}', 'u')
|
||||
// supportsUnicodeProperty = true
|
||||
// } catch (e) {
|
||||
// supportsUnicodeProperty = false
|
||||
// }
|
||||
|
||||
// // 如果不支持,创建一个安全的 RegExp 包装器
|
||||
// if (!supportsUnicodeProperty) {
|
||||
// window.RegExp = function(pattern, flags) {
|
||||
// if (typeof pattern === 'string') {
|
||||
// // 移除正则中的 \p{L} 和 \p{N}
|
||||
// pattern = pattern.replace(/\\p\{L\}/g, '[A-Za-z\\u00C0-\\u00FF]')
|
||||
// pattern = pattern.replace(/\\p\{N\}/g, '[0-9]')
|
||||
// pattern = pattern.replace(/\\p\{L\}|\\p\{N\}/g, '[A-Za-z0-9\\u00C0-\\u00FF]')
|
||||
// }
|
||||
// return new originalRegExp(pattern, flags)
|
||||
// }
|
||||
// window.RegExp.prototype = originalRegExp.prototype
|
||||
// }
|
||||
// }
|
||||
|
||||
export function createApp() {
|
||||
// 1. 创建Vue实例
|
||||
const app = createSSRApp(App)
|
||||
// 2. 创建Pinia实例并挂载(必须在mount前)
|
||||
const pinia = createPinia()
|
||||
// 使用 Pinia
|
||||
app.use(pinia)
|
||||
return {
|
||||
app,
|
||||
pinia // 暴露pinia,避免后续调用时丢失上下文
|
||||
}
|
||||
}
|
||||
// #endif
|
||||
Reference in New Issue
Block a user