main.js 908 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import App from './App'
  2. // #ifndef VUE3
  3. import Vue from 'vue'
  4. Vue.config.productionTip = false
  5. App.mpType = 'app'
  6. try {
  7. function isPromise(obj) {
  8. return (
  9. !!obj &&
  10. (typeof obj === "object" || typeof obj === "function") &&
  11. typeof obj.then === "function"
  12. );
  13. }
  14. // 统一 vue2 API Promise 化返回格式与 vue3 保持一致
  15. uni.addInterceptor({
  16. returnValue(res) {
  17. if (!isPromise(res)) {
  18. return res;
  19. }
  20. return new Promise((resolve, reject) => {
  21. res.then((res) => {
  22. if (res[0]) {
  23. reject(res[0]);
  24. } else {
  25. resolve(res[1]);
  26. }
  27. });
  28. });
  29. },
  30. });
  31. } catch (error) { }
  32. const app = new Vue({
  33. ...App
  34. })
  35. app.$mount()
  36. // #endif
  37. // #ifdef VUE3
  38. import { createSSRApp } from 'vue'
  39. export function createApp() {
  40. const app = createSSRApp(App)
  41. return {
  42. app
  43. }
  44. }
  45. // #endif