中英文切换修复

master
yujialong 1 year ago
parent 1826aa3ce5
commit 2bbbe94bad
  1. 1
      src/layouts/footer/index.vue
  2. 7
      src/libs/util.js
  3. 15
      src/main.js
  4. 1
      src/pages/column/index.vue
  5. 43
      src/pages/publication/index.vue
  6. 5
      src/router/permission.js

@ -162,7 +162,6 @@ export default {
isSort: 1 isSort: 1
}).then(({ data }) => { }).then(({ data }) => {
console.log("🚀 ~ file: index.vue:177 ~ this.$post ~ json:", window.innerWidth)
this.columns = data.slice(0, 5) this.columns = data.slice(0, 5)
}).catch(err => { }) }).catch(err => { })
}, },

@ -2,6 +2,7 @@ import { _local } from "./util.db";
import { Message } from "element-ui"; import { Message } from "element-ui";
import Router from '@/router' import Router from '@/router'
import Setting from '@/setting' import Setting from '@/setting'
import store from '@/store'
// 文件后缀集合 // 文件后缀集合
const exts = { const exts = {
@ -146,6 +147,12 @@ const util = {
isEn(id) { isEn(id) {
return Setting.enIds.includes(+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; export default util;

@ -16,7 +16,7 @@ import Util from '@/libs/util'
import enLocale from 'element-ui/lib/locale/lang/en' import enLocale from 'element-ui/lib/locale/lang/en'
import zhLocale from 'element-ui/lib/locale/lang/zh-CN' import zhLocale from 'element-ui/lib/locale/lang/zh-CN'
import ElementLocale from 'element-ui/lib/locale' 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, {})) // 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) 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({ const i18n = new VueI18n({
locale: Setting.enIds.includes(siteId ? +siteId : store.state.content.site) ? 'en' : 'zh', locale: Util.getLang(),
messages: { messages: {
'en':Object.assign(messages.en,enLocale),//将我们项目中的语言包与Element的语言包进行合并 'en':Object.assign(messages.en,enLocale),//将我们项目中的语言包与Element的语言包进行合并
'zh':Object.assign(messages.zh,zhLocale), 'zh':Object.assign(messages.zh,zhLocale),
} }
}); });
new Vue({ const vue = new Vue({
mixins: [mixinApp], mixins: [mixinApp],
router, router,
i18n, i18n,
store, store,
render: h => h(App) render: h => h(App)
}).$mount("#app"); }).$mount("#app");
export default vue

@ -599,7 +599,6 @@ export default {
this.getAllId = id this.getAllId = id
this.getArticle(id); this.getArticle(id);
this.columns = data; this.columns = data;
console.log("🚀 ~ file: index.vue:608 ~ .then ~ this.columns:", this.columns)
// banner // banner
if (!this.info.columnBanner) { if (!this.info.columnBanner) {
this.getBanner(data); this.getBanner(data);

@ -1,7 +1,10 @@
<template> <template>
<div class="wrap"> <div class="wrap">
<div class="banner"> <div class="banner">
<img width="100%" height="280" :src="info.columnBanner" alt="" /> <img width="100%"
height="280"
:src="info.columnBanner"
alt="" />
<div class="texts"> <div class="texts">
<p class="text">{{ info.columnName }}</p> <p class="text">{{ info.columnName }}</p>
</div> </div>
@ -9,18 +12,23 @@
<ul class="tabs wow fadeInLeft"> <ul class="tabs wow fadeInLeft">
<template v-for="(item, i) in tabs"> <template v-for="(item, i) in tabs">
<li :class="{active: item.listStyleId == active}" :key="i" @click="tabChange(item, i)">{{ item.columnName | i18nName($i18n) }}</li> <li :class="{active: item.listStyleId == active}"
:key="i"
@click="tabChange(item, i)">{{ item.columnName | i18nName($i18n) }}</li>
</template> </template>
</ul> </ul>
<div class="tab-content"> <div class="tab-content">
<!-- 根据栏目的listStyleId判断是哪个列表样式这个出版物页面只显示下面三个列表样式 --> <!-- 根据栏目的listStyleId判断是哪个列表样式这个出版物页面只显示下面三个列表样式 -->
<!-- 论文 --> <!-- 论文 -->
<Thesis v-if="active === 46" :id.sync="curId" /> <Thesis v-if="active === 46"
:id.sync="curId" />
<!-- 专利 --> <!-- 专利 -->
<Patent v-if="active === 44" :id.sync="curId" /> <Patent v-if="active === 44"
:id.sync="curId" />
<!-- 专著 --> <!-- 专著 -->
<Monograph v-if="active === 45" :id.sync="curId" /> <Monograph v-if="active === 45"
:id.sync="curId" />
</div> </div>
</div> </div>
</template> </template>
@ -32,7 +40,7 @@ import Patent from './patent'
import Monograph from './monograph' import Monograph from './monograph'
export default { export default {
mixins: [mixins], mixins: [mixins],
data() { data () {
return { return {
info: {}, info: {},
active: 0, active: 0,
@ -46,13 +54,13 @@ export default {
Patent, Patent,
Monograph Monograph
}, },
mounted() { mounted () {
this.getInfo() this.getInfo()
this.getColumn() this.getColumn()
}, },
methods: { methods: {
// //
getInfo() { getInfo () {
this.id && this.id &&
this.$post(`${this.api.findColumn}?id=${this.id}`) this.$post(`${this.api.findColumn}?id=${this.id}`)
.then(({ data }) => { .then(({ data }) => {
@ -62,7 +70,7 @@ export default {
.catch((res) => { }) .catch((res) => { })
}, },
// //
getColumn() { getColumn () {
this.$post(`${this.api.getsSublevelColumnsUnderALevel}?id=${this.id}&siteId=${this.site}`).then(({ data }) => { this.$post(`${this.api.getsSublevelColumnsUnderALevel}?id=${this.id}&siteId=${this.site}`).then(({ data }) => {
this.tabs = data this.tabs = data
// urltabtabtabid // urltabtabtabid
@ -75,17 +83,16 @@ export default {
this.active = data[0].listStyleId this.active = data[0].listStyleId
this.curId = data[0].id this.curId = data[0].id
} }
}).catch(err => {}) }).catch(err => { })
}, },
// tab // tab
tabChange(item) { tabChange (item) {
this.active = item.listStyleId this.active = item.listStyleId
this.curId = item.id this.curId = item.id
}, },
}, },
filters: { filters: {
i18nName(name,type) { i18nName (name, type) {
console.log(type)
switch (name) { switch (name) {
case '专利': case '专利':
return type.t('column.patent') return type.t('column.patent')
@ -129,7 +136,7 @@ export default {
.tabs { .tabs {
display: flex; display: flex;
justify-content: center; justify-content: center;
box-shadow: 0px 2px 10px 0px rgba(223,223,223,0.28); box-shadow: 0px 2px 10px 0px rgba(223, 223, 223, 0.28);
li { li {
padding: 25px 19px; padding: 25px 19px;
margin: 0 70px; margin: 0 70px;
@ -137,11 +144,11 @@ export default {
color: #333; color: #333;
white-space: nowrap; white-space: nowrap;
border-bottom: 4px solid transparent; border-bottom: 4px solid transparent;
text-shadow: 0px 2px 14px rgba(167,167,167,0.26); text-shadow: 0px 2px 14px rgba(167, 167, 167, 0.26);
cursor: pointer; cursor: pointer;
&.active { &.active {
color: #1583FF; color: #1583ff;
border-bottom-color: #1583FF; border-bottom-color: #1583ff;
} }
} }
} }
@ -167,7 +174,7 @@ export default {
margin: 0 1.25rem; margin: 0 1.25rem;
} }
} }
.tab-content{ .tab-content {
width: 90%; width: 90%;
margin: 0 auto; margin: 0 auto;
} }

@ -1,7 +1,6 @@
import router from "./index"; import router from './index'
import Setting from "@/setting"; import Setting from '@/setting'
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
document.title = Setting.titleSuffix
next() next()
}) })
Loading…
Cancel
Save