Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

main.js 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. import App from './App'
  2. import Store from './store'
  3. // #ifndef VUE3
  4. import Vue from 'vue'
  5. import './uni.promisify.adaptor'
  6. Vue.config.productionTip = false
  7. App.mpType = 'app'
  8. const app = new Vue({
  9. ...App
  10. })
  11. app.$mount()
  12. // #endif
  13. // #ifdef VUE3
  14. import { createSSRApp } from 'vue'
  15. // 导入你的语言文件
  16. import en from './en.json'
  17. import zhHans from './zh-Hans.json'
  18. import zhHant from './zh-Hant.json'
  19. const messages = {
  20. en,
  21. 'zh-Hans': zhHans,
  22. 'zh-Hant': zhHant
  23. }
  24. let i18nConfig = {
  25. locale: uni.getStorageSync('userLanguage') || 'zh-Hans',// 获取已设置的语言
  26. messages
  27. }
  28. import { createI18n } from 'vue-i18n'// v9.x
  29. const i18n = createI18n(i18nConfig)
  30. export function createApp() {
  31. const app = createSSRApp(App)
  32. app.use(i18n)
  33. app.use(Store) //新增的一行
  34. return {
  35. app
  36. }
  37. }
  38. // #endif
  39. import { $http } from './api/http.js'
  40. // import { login } from './api/api'
  41. uni.$http = $http
  42. $http.baseUrl = ''
  43. // uni.$apiKey = 'xxxxxxxxx'
  44. // 请求开始之前
  45. $http.beforeRequest = function (options) {
  46. // uni.showLoading({
  47. // title: '数据加载中...',
  48. // })
  49. // if(options.url!="http://10.168.4.100:80/api/v1/login"){
  50. // console.log(options);
  51. // if (!uni.getStorageSync('token')) {
  52. // login().then(data => {
  53. // // console.log(data);
  54. // if (data.status == 'ok') {
  55. // uni.setStorage({
  56. // key: 'token',
  57. // data: data.data.token,
  58. // success: function(res) {
  59. // console.log(res);
  60. // }
  61. // });
  62. // }else{
  63. // uni.showToast({
  64. // title:data.msg,
  65. // icon: 'none',
  66. // duration: 2000, // 显示时长,单位为毫秒
  67. // });
  68. // }
  69. // });
  70. // }
  71. // }
  72. }
  73. // 请求完成之后
  74. $http.afterRequest = function () {
  75. // uni.hideLoading()
  76. }