2025-04-11 02:31:26 +00:00
|
|
|
import Vue from 'vue'
|
|
|
|
import App from './App.vue'
|
|
|
|
import router from './router'
|
|
|
|
import store from './store'
|
|
|
|
import ElementUI from 'element-ui';
|
|
|
|
import 'element-ui/lib/theme-chalk/index.css';
|
|
|
|
import '@/assets/styles/index.scss'
|
|
|
|
import i18n from './i18n/index'
|
|
|
|
import axios from "axios";
|
|
|
|
import './assets/icons/iconfont/iconfont.css'
|
|
|
|
import {$addStorageEvent} from '../src/utils/publicMethods'
|
|
|
|
import MetaInfo from 'vue-meta-info'
|
|
|
|
import loadingStateMixin from './utils/loadingStateMixin';
|
2025-04-18 06:45:39 +00:00
|
|
|
import networkRecoveryMixin from './mixins/networkRecoveryMixin';
|
|
|
|
import './utils/loadingRecovery';
|
|
|
|
import errorNotificationManager from '../src/utils/errorNotificationManager';
|
2025-04-11 02:31:26 +00:00
|
|
|
|
|
|
|
Vue.use(MetaInfo)
|
|
|
|
Vue.prototype.$addStorageEvent = $addStorageEvent // 添加storage事件
|
|
|
|
Vue.config.productionTip = false
|
|
|
|
Vue.use(ElementUI, {
|
|
|
|
i18n: (key, value) => i18n.t(key, value)
|
|
|
|
});
|
|
|
|
Vue.prototype.$axios = axios
|
|
|
|
|
2025-04-25 06:09:32 +00:00
|
|
|
// console.log = ()=>{} //全局关闭打印
|
2025-04-18 06:45:39 +00:00
|
|
|
// 全局注册混入
|
2025-04-11 02:31:26 +00:00
|
|
|
Vue.mixin(loadingStateMixin);
|
2025-04-18 06:45:39 +00:00
|
|
|
Vue.mixin(networkRecoveryMixin);
|
2025-04-11 02:31:26 +00:00
|
|
|
|
|
|
|
Vue.prototype.$baseApi = process.env.VUE_APP_BASE_URL //图片base路径
|
|
|
|
const screenWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
|
|
|
|
const isNarrowScreen = screenWidth < 1280;
|
|
|
|
Vue.prototype.$isMobile = isNarrowScreen
|
|
|
|
|
|
|
|
// 在路由守卫中设置
|
|
|
|
router.beforeEach((to, from, next) => {
|
|
|
|
// 从路由中获取语言参数
|
|
|
|
const lang = to.params.lang || (localStorage.getItem('lang') || 'en');
|
|
|
|
|
|
|
|
// 设置 HTML 的 lang 属性
|
|
|
|
document.documentElement.lang = lang;
|
|
|
|
|
|
|
|
// 设置i18n语言
|
|
|
|
if (i18n.locale !== lang) {
|
|
|
|
i18n.locale = lang;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
next();
|
|
|
|
});
|
|
|
|
|
2025-04-18 06:45:39 +00:00
|
|
|
// 定期清理过期的错误记录
|
|
|
|
setInterval(() => {
|
|
|
|
errorNotificationManager.cleanup();
|
|
|
|
}, 60000); // 每分钟清理一次
|
|
|
|
|
2025-04-11 02:31:26 +00:00
|
|
|
window.vm = new Vue({
|
|
|
|
router,
|
|
|
|
store,
|
|
|
|
i18n,
|
|
|
|
render: h => h(App),
|
|
|
|
created() {
|
|
|
|
this.$watch(
|
|
|
|
() => this.$i18n.locale,
|
|
|
|
(newLocale) => {
|
|
|
|
this.updateMetaAndTitle();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
this.updateMetaAndTitle();
|
|
|
|
},
|
|
|
|
mounted () {
|
|
|
|
document.dispatchEvent(new Event('render-event'))
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
updateMetaAndTitle() {
|
|
|
|
document.title = this.$i18n.t('home.appTitle');
|
|
|
|
const descriptionMeta = document.querySelector('meta[name="description"]');
|
|
|
|
// const keywordsMeta = document.querySelector('meta[name="keywords"]');
|
|
|
|
|
|
|
|
if (descriptionMeta) {
|
|
|
|
descriptionMeta.content = this.$i18n.t('home.metaDescription');
|
|
|
|
}
|
|
|
|
// if (keywordsMeta) {
|
|
|
|
// keywordsMeta.content = this.$i18n.t('home.metaKeywords');
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}).$mount('#app')
|
|
|
|
|
|
|
|
// 初次加载和DOM加载完成时更新
|
|
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
|
|
window.vm.updateMetaAndTitle();
|
|
|
|
});
|