main.js 1.5 KB

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