main.js 773 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import App from './App'
  2. // #ifndef VUE3
  3. import Vue from 'vue'
  4. import './uni.promisify.adaptor'
  5. Vue.config.productionTip = false
  6. App.mpType = 'app'
  7. const app = new Vue({
  8. ...App
  9. })
  10. app.$mount()
  11. // #endif
  12. // #ifdef VUE3
  13. import { createSSRApp } from 'vue'
  14. import { createPinia } from 'pinia'
  15. import { createPersistedState } from 'pinia-plugin-persistedstate'
  16. export function createApp() {
  17. const app = createSSRApp(App)
  18. // 创建pinia实例
  19. const pinia = createPinia()
  20. // 配置持久化插件
  21. pinia.use(createPersistedState({
  22. storage: {
  23. getItem(key) {
  24. return uni.getStorageSync(key)
  25. },
  26. setItem(key, value) {
  27. uni.setStorageSync(key, value)
  28. }
  29. }
  30. }))
  31. app.use(pinia)
  32. return {
  33. app
  34. }
  35. }
  36. // #endif