main.js 1019 B

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