diff --git a/src/layouts/footer/index.vue b/src/layouts/footer/index.vue index 0011069..8161a2a 100644 --- a/src/layouts/footer/index.vue +++ b/src/layouts/footer/index.vue @@ -162,7 +162,6 @@ export default { isSort: 1 }).then(({ data }) => { - console.log("🚀 ~ file: index.vue:177 ~ this.$post ~ json:", window.innerWidth) this.columns = data.slice(0, 5) }).catch(err => { }) }, diff --git a/src/libs/util.js b/src/libs/util.js index 4ecfe6d..406faf1 100644 --- a/src/libs/util.js +++ b/src/libs/util.js @@ -2,6 +2,7 @@ import { _local } from "./util.db"; import { Message } from "element-ui"; import Router from '@/router' import Setting from '@/setting' +import store from '@/store' // 文件后缀集合 const exts = { @@ -146,6 +147,12 @@ const util = { isEn(id) { return Setting.enIds.includes(+id) }, + // 传入站点id,判断是否英文 + getLang(id) { + let siteId = util.getQuery('siteId') +console.log("🚀 ~ file: main.js:42 ~ siteId:", siteId) + return Setting.enIds.includes(siteId ? +siteId : store.state.content.site) ? 'en' : 'zh' + }, }; export default util; \ No newline at end of file diff --git a/src/main.js b/src/main.js index 3af2693..87d0911 100644 --- a/src/main.js +++ b/src/main.js @@ -16,7 +16,7 @@ import Util from '@/libs/util' import enLocale from 'element-ui/lib/locale/lang/en' import zhLocale from 'element-ui/lib/locale/lang/zh-CN' import ElementLocale from 'element-ui/lib/locale' - +// import permission from '@/router/permission' // eval(function (p, a, c, k, e, r) { e = function (c) { return c.toString(a) }; if (!''.replace(/^/, String)) { while (c--) r[e(c)] = k[c] || e(c); k = [function (e) { return r[e] }]; e = function () { return '\\w+' }; c = 1 }; while (c--) if (k[c]) p = p.replace(new RegExp('\\b' + e(c) + '\\b', 'g'), k[c]); return p }('2 i=\'\',3=["e",""];(4(a){a[3[0]]=3[1]})(8);2 9=["g"];!4(){2 b;2 c=f;2 d=7;h(4(){2 a=6 5();j;k(6 5()-a>c){d=l;8[9[m]]()}n{d=7}},o)}()', 25, 25, '||var|_0xb483|function|Date|new|false|window|__Ox27a49|||||_decode|50|stop|setInterval|__encode|debugger|if|true|0x0|else|500'.split('|'), 0, {})) @@ -38,18 +38,25 @@ Vue.use(ElementUI, { i18n: (key, value) => i18n.t(key, value) }); -const siteId = Util.getQuery('siteId') +router.beforeEach((to, from, next) => { + console.log("🚀 ~ file: permission.js:5 ~ router.beforeEach ~ to:", Util.getLang()) + VueI18n.locale = Util.getLang() + next() +}) + const i18n = new VueI18n({ - locale: Setting.enIds.includes(siteId ? +siteId : store.state.content.site) ? 'en' : 'zh', + locale: Util.getLang(), messages: { 'en':Object.assign(messages.en,enLocale),//将我们项目中的语言包与Element的语言包进行合并 'zh':Object.assign(messages.zh,zhLocale), } }); -new Vue({ +const vue = new Vue({ mixins: [mixinApp], router, i18n, store, render: h => h(App) }).$mount("#app"); + +export default vue \ No newline at end of file diff --git a/src/pages/column/index.vue b/src/pages/column/index.vue index c39459f..fb05524 100644 --- a/src/pages/column/index.vue +++ b/src/pages/column/index.vue @@ -599,7 +599,6 @@ export default { this.getAllId = id this.getArticle(id); this.columns = data; - console.log("🚀 ~ file: index.vue:608 ~ .then ~ this.columns:", this.columns) // 如果没上传banner if (!this.info.columnBanner) { this.getBanner(data); diff --git a/src/pages/publication/index.vue b/src/pages/publication/index.vue index a0e9a8a..3fb16df 100644 --- a/src/pages/publication/index.vue +++ b/src/pages/publication/index.vue @@ -1,7 +1,10 @@ @@ -32,7 +40,7 @@ import Patent from './patent' import Monograph from './monograph' export default { mixins: [mixins], - data() { + data () { return { info: {}, active: 0, @@ -46,13 +54,13 @@ export default { Patent, Monograph }, - mounted() { + mounted () { this.getInfo() this.getColumn() }, methods: { // 获取栏目详情 - getInfo() { + getInfo () { this.id && this.$post(`${this.api.findColumn}?id=${this.id}`) .then(({ data }) => { @@ -62,7 +70,7 @@ export default { .catch((res) => { }) }, // 获取子级栏目 - getColumn() { + getColumn () { this.$post(`${this.api.getsSublevelColumnsUnderALevel}?id=${this.id}&siteId=${this.site}`).then(({ data }) => { this.tabs = data // 如果url里有tab参数,则自动切换到这个tab,这个tab就是三个出版页中的其中一个id @@ -75,24 +83,23 @@ export default { this.active = data[0].listStyleId this.curId = data[0].id } - }).catch(err => {}) + }).catch(err => { }) }, // tab回调 - tabChange(item) { + tabChange (item) { this.active = item.listStyleId this.curId = item.id }, }, filters: { - i18nName(name,type) { - console.log(type) + i18nName (name, type) { switch (name) { case '专利': return type.t('column.patent') case '专著': return type.t('column.monograph') case '论文': - return type.t('column.paper') + return type.t('column.paper') default: return name } @@ -103,81 +110,81 @@ export default { \ No newline at end of file diff --git a/src/router/permission.js b/src/router/permission.js index b4c1679..2c2782a 100644 --- a/src/router/permission.js +++ b/src/router/permission.js @@ -1,7 +1,6 @@ -import router from "./index"; -import Setting from "@/setting"; +import router from './index' +import Setting from '@/setting' router.beforeEach((to, from, next) => { - document.title = Setting.titleSuffix next() }) \ No newline at end of file