main.js 721 B

1234567891011121314151617181920212223
  1. import App from './App'
  2. import { createSSRApp } from 'vue'
  3. import * as Pinia from 'pinia'
  4. import './uni.promisify.adaptor'
  5. export function createApp() {
  6. const app = createSSRApp(App)
  7. app.use(Pinia.createPinia())
  8. // 全局错误捕获,将错误写入 localStorage 以便调试
  9. app.config.errorHandler = (err, vm, info) => {
  10. const msg = `[Vue Error] ${info}: ${err && err.message ? err.message : String(err)}`
  11. console.error(msg)
  12. try {
  13. const logs = JSON.parse(uni.getStorageSync('__debug_logs') || '[]')
  14. logs.unshift({ t: new Date().toISOString(), msg })
  15. uni.setStorageSync('__debug_logs', JSON.stringify(logs.slice(0, 20)))
  16. } catch(e) {}
  17. }
  18. return {
  19. app,
  20. Pinia
  21. }
  22. }