zhongshujie
2025-08-07 098bfef89592c282dca1394fe68c9e92b6cee50b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import './assets/style/main.css'
 
import { createApp } from 'vue'
import { createPinia } from 'pinia'
 
import App from './App.vue'
import { createI18n } from 'vue-i18n'
import router from './router'
 
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import locale from 'element-plus/es/locale/lang/zh-cn'
 
// 自定义配置
import config from '@/assets/js/config'
 
// 请求处理
import MG from './assets/js/middleGround/WebMiddleGroundApi.js'
import toolClass from '@/assets/js/toolClass.js'
 
// 引入语言文件
import en from './locales/en.json'
import zh from './locales/zh.json'
 
const messages = {
  en: en,
  zh: zh,
}
 
// 创建i18n实例
const i18n = createI18n({
  locale: 'en', // 设置默认语言环境为中文
  fallbackLocale: 'zh',
  messages, // 设置资源
})
 
const app = createApp(App)
app.use(i18n) // 使用i18n插件
app.provide('config', config)
app.provide('MG', MG)
app.provide('toolClass', toolClass)
app.use(createPinia())
app.use(router)
app.use(ElementPlus, { locale })
app.use(ElementPlus, { locale })
// 全局注册element icon
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}
 
app.mount('#app')
 
router.beforeEach((to, from, next) => {
  window.scrollTo({ top: 0 }) // 将滚动条位置设为0
  next()
})