Files
phone-app------test1-/main.js
2026-06-02 10:42:33 +08:00

60 lines
1.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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