main.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import App from "./App";
  2. // #ifndef VUE3
  3. import Vue from "vue";
  4. import "./uni.promisify.adaptor";
  5. import uView from "@/uview-ui";
  6. import VueI18n from "vue-i18n";
  7. import messages from "./commont/messages.js";
  8. // import uView from '/uview-ui/uview-ui'
  9. Vue.use(VueI18n);
  10. Vue.config.productionTip = false;
  11. //获取当前选择语言
  12. let language = "";
  13. uni.getStorage({
  14. key: "language", // 这里替换成你要获取的数据的key
  15. success: function (res) {
  16. language = res.data; // 输出获取到的数据
  17. },
  18. fail: function () {
  19. // 获取失败的处理逻辑
  20. },
  21. });
  22. // 多国语言包配置
  23. const i18n = new VueI18n({
  24. locale: language,
  25. // locale: "en-US",
  26. messages,
  27. });
  28. Vue.prototype._i18n = i18n;
  29. Vue.use(uView);
  30. App.mpType = "app";
  31. const app = new Vue({
  32. i18n,
  33. ...App,
  34. });
  35. // import WebIM from "./utils/WebIM.js"
  36. // Vue.use(WebIM,app)
  37. // 引入请求封装,将app参数传递到配置中
  38. // require('./commont/http.interceptor.js')(app)
  39. import httpInterceptor from "@/commont/http.interceptor.js";
  40. // 这里需要写在最后,是为了等Vue创建对象完成,引入"app"对象(也即页面的"this"实例)
  41. Vue.use(httpInterceptor, app);
  42. app.$mount();
  43. // #endif
  44. // #ifdef VUE3
  45. import { createSSRApp } from "vue";
  46. export function createApp() {
  47. const app = createSSRApp(App);
  48. return {
  49. app,
  50. };
  51. }
  52. // #endif