代码推送
This commit is contained in:
129
yq/src/main.js
Normal file
129
yq/src/main.js
Normal file
@@ -0,0 +1,129 @@
|
||||
import Vue from 'vue'
|
||||
import 'element-ui/lib/theme-chalk/index.css';
|
||||
import App from './App.vue'
|
||||
import router from './router'
|
||||
import store from './store'
|
||||
import "./assets/icon/iconfont.css"
|
||||
import ElementUI from 'element-ui';
|
||||
import axios from "axios";
|
||||
// 引入VueI18n
|
||||
import i18n from './lang/index'
|
||||
import API from "./api/api"
|
||||
import VueQuillEditor from 'vue-quill-editor'
|
||||
import 'quill/dist/quill.core.css'
|
||||
|
||||
import 'quill/dist/quill.snow.css'
|
||||
|
||||
import 'quill/dist/quill.bubble.css'
|
||||
import './assets/style.css' //全局单词首字母大写
|
||||
import Dropdown from './components/dropdownBox.vue';
|
||||
import MetaInfo from 'vue-meta-info'
|
||||
|
||||
Vue.use(MetaInfo)
|
||||
|
||||
Vue.component('Dropdown', Dropdown);
|
||||
|
||||
Vue.use(VueQuillEditor) // 注册富文本编辑器
|
||||
|
||||
|
||||
|
||||
// Vue.config.productionTip =false
|
||||
|
||||
//el-tabel 使用千分位格式
|
||||
import {stateFormat,handleScopeFormat,stateFormat2} from './util/thousands'
|
||||
import {$addStorageEvent} from '../src/util/processingData'
|
||||
Vue.prototype.stateFormat = stateFormat
|
||||
Vue.prototype.stateFormat2 = stateFormat2
|
||||
Vue.prototype.handleScopeFormat = handleScopeFormat
|
||||
|
||||
|
||||
// element-ui 为了兼容vue-i18n@6.x
|
||||
Vue.use(ElementUI, {
|
||||
i18n: (key, value) => i18n.t(key, value)
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Vue.prototype.$axios = axios
|
||||
Vue.prototype.$API = API
|
||||
Vue.use(ElementUI);
|
||||
|
||||
Vue.config.productionTip = false
|
||||
|
||||
// //监听localstorage
|
||||
Vue.prototype.$addStorageEvent = $addStorageEvent
|
||||
|
||||
|
||||
console.log = ()=>{} //全局关闭打印
|
||||
|
||||
|
||||
|
||||
|
||||
window.a = Vue
|
||||
window.vm = new Vue({
|
||||
router,
|
||||
store,
|
||||
i18n,
|
||||
render: h => h(App),
|
||||
created() {
|
||||
this.$watch(
|
||||
() => this.$i18n.locale,
|
||||
(newLocale) => {
|
||||
this.updateMetaAndTitle();
|
||||
}
|
||||
);
|
||||
this.updateMetaAndTitle();
|
||||
this.updateCanonicalUrl(); // 添加这行
|
||||
},
|
||||
mounted () {
|
||||
document.dispatchEvent(new Event('render-event'))
|
||||
},
|
||||
methods: {
|
||||
updateMetaAndTitle() {
|
||||
document.title = this.$i18n.t('seo.appTitle');
|
||||
const descriptionMeta = document.querySelector('meta[name="description"]');
|
||||
const keywordsMeta = document.querySelector('meta[name="keywords"]');
|
||||
|
||||
if (descriptionMeta) {
|
||||
descriptionMeta.content = this.$i18n.t('seo.metaDescription');
|
||||
}
|
||||
if (keywordsMeta) {
|
||||
keywordsMeta.content = this.$i18n.t('seo.metaKeywords');
|
||||
}
|
||||
},
|
||||
|
||||
updateCanonicalUrl() {//更新index。html的canonical 确保每个页面都有正确的规范链接
|
||||
const canonicalLink = document.querySelector('link[rel="canonical"]');
|
||||
if (canonicalLink) {
|
||||
// 根据当前路由更新 canonical URL
|
||||
const path = this.$route.path;
|
||||
const baseUrl = 'https://coinbus.cc';
|
||||
|
||||
// 如果是首页,使用基础URL
|
||||
if (path === '/') {
|
||||
canonicalLink.href = baseUrl;
|
||||
} else {
|
||||
// 其他页面添加路径
|
||||
canonicalLink.href = `${baseUrl}${path}`;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
},
|
||||
watch: {
|
||||
// 监听路由变化
|
||||
'$route'() {
|
||||
this.updateCanonicalUrl();
|
||||
}
|
||||
}
|
||||
}).$mount('#app')
|
||||
|
||||
// 初次加载和DOM加载完成时更新
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
window.vm.updateMetaAndTitle();
|
||||
});
|
||||
Reference in New Issue
Block a user