main.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import App from "./App";
  2. // main.js
  3. import uView from "uview-ui";
  4. import api from "@/libs/http/index.js";
  5. import store from "./store";
  6. import VueI18n from "vue-i18n";
  7. Vue.use(VueI18n);
  8. Vue.prototype.$store = store;
  9. Vue.prototype.api = api; //(2)
  10. Vue.use(uView);
  11. import { throttle } from "@/libs/util/utils.js"; //防抖
  12. Vue.prototype.socketTask = null;
  13. Vue.prototype.isClose = false;
  14. const i18n = new VueI18n({
  15. locale: "en-US",
  16. messages: {
  17. "en-US": {
  18. index: {
  19. invite: "Invite",
  20. game: "Game",
  21. },
  22. },
  23. "zh-CN": {
  24. index: {
  25. invite: "邀请",
  26. game: "游戏",
  27. },
  28. },
  29. },
  30. });
  31. Vue.prototype._i18n = i18n;
  32. Vue.directive("throttle", throttle);
  33. // #ifndef VUE3
  34. import Vue from "vue";
  35. import { broadcastScan } from "@/utils/scanCode";
  36. // main.js
  37. // import "amfe-flexible";
  38. import inputSearch from "@/components/p-inputSearch/inputSearch.vue";
  39. Vue.component("inputSearch", inputSearch);
  40. Vue.prototype.apiServer = "http://192.168.1.45/dev-api";
  41. Vue.prototype.$broadcastScan = broadcastScan;
  42. Vue.prototype.ip = "192.168.1.45";
  43. Vue.config.productionTip = false;
  44. App.mpType = "app";
  45. uni.setStorage({
  46. key: "storage_token",
  47. data: "eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjdjZWVjNGI2LWE2NGYtNDI3OS05MWEzLTAxMzdkNmEyNDdkNiJ9.7e2lVcZ0b3Y8ofwDCvrETpEZQETrp1Ik-MYfsufiMSoR7oqvI5XiXgbe2bVk4jOJGt7ns0ryKbp5XXE71hoXcA",
  48. success: function () {
  49. console.log("success");
  50. },
  51. });
  52. const app = new Vue({
  53. ...App,
  54. i18n,
  55. store,
  56. });
  57. app.$mount();
  58. // #endif
  59. // #ifdef VUE3
  60. import { createSSRApp } from "vue";
  61. export function createApp() {
  62. const app = createSSRApp(App);
  63. return {
  64. app,
  65. };
  66. }
  67. // #endif