You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.0 KiB

9 months ago
9 months ago
9 months ago
6 months ago
9 months ago
9 months ago
9 months ago
  1. import {createApp} from 'vue'
  2. import App from './App.vue'
  3. import router from './router'
  4. import ElementPlus from 'element-plus'
  5. // import zhCn from 'element-plus/es/locale/lang/zh-cn'
  6. // import en from 'element-plus/es/locale/lang/en'
  7. // import th from 'element-plus/es/locale/lang/th'
  8. import 'element-plus/dist/index.css'
  9. import * as ElementPlusIconsVue from '@element-plus/icons-vue'
  10. import './assets/css/common.css' // 引入公共CSS文件
  11. import JsonExcel from 'vue-json-excel'
  12. import {createPinia} from 'pinia'
  13. import VxeUI from 'vxe-pc-ui'
  14. import 'vxe-pc-ui/lib/style.css'
  15. import VxeUITable from 'vxe-table'
  16. import 'vxe-table/lib/style.css'
  17. // 修正导入路径
  18. import {useAdminStore} from './store'
  19. import request from "@/util/request";
  20. import "./global.css";
  21. import '@/assets/css/btn.css';
  22. import {useMessageStore} from "@/store";
  23. import i18n from './components/locales'
  24. const app = createApp(App)
  25. const pinia = createPinia()
  26. // 全局注册 ElementPlus 图标
  27. for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  28. app.component(key, component)
  29. }
  30. // 先注册组件再挂载
  31. app.component('downloadExcel', JsonExcel)
  32. app.config.globalProperties.$http = request
  33. // // 动态设置 Element Plus 的语言
  34. // const getElementPlusLocale = () => {
  35. // const lang = localStorage.getItem('lang') || 'zh-CN'
  36. // switch (lang) {
  37. // case 'en':
  38. // return en
  39. // case 'th':
  40. // return th
  41. // case 'zh-CN':
  42. // default:
  43. // return zhCn
  44. // }
  45. // }
  46. // 使用各种插件
  47. app.use(ElementPlus)
  48. .use(router)
  49. .use(VxeUI)
  50. .use(VxeUITable)
  51. .use(pinia)
  52. .use(i18n)
  53. .mount('#app')
  54. // 在 app 挂载之后再使用 store
  55. const adminStore = useAdminStore()
  56. const messageStore = useMessageStore()
  57. adminStore.initFromLocalStorage()
  58. messageStore.initFromLocalStorage()
  59. // 初始化语言设置
  60. const initLanguage = () => {
  61. const lang = localStorage.getItem('lang')
  62. if (!lang) {
  63. // 如果没有设置语言,默认使用中文
  64. localStorage.setItem('lang', 'zh-CN')
  65. }
  66. }
  67. initLanguage()