| 1234567891011121314151617181920212223 |
- import App from './App'
- import { createSSRApp } from 'vue'
- import * as Pinia from 'pinia'
- import './uni.promisify.adaptor'
- export function createApp() {
- const app = createSSRApp(App)
- app.use(Pinia.createPinia())
- // 全局错误捕获,将错误写入 localStorage 以便调试
- app.config.errorHandler = (err, vm, info) => {
- const msg = `[Vue Error] ${info}: ${err && err.message ? err.message : String(err)}`
- console.error(msg)
- try {
- const logs = JSON.parse(uni.getStorageSync('__debug_logs') || '[]')
- logs.unshift({ t: new Date().toISOString(), msg })
- uni.setStorageSync('__debug_logs', JSON.stringify(logs.slice(0, 20)))
- } catch(e) {}
- }
- return {
- app,
- Pinia
- }
- }
|