中英文切换修复

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. 155
      src/pages/publication/index.vue
  6. 5
      src/router/permission.js

@ -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 => { })
},

@ -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;

@ -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

@ -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);

@ -1,7 +1,10 @@
<template>
<div class="wrap">
<div class="banner">
<img width="100%" height="280" :src="info.columnBanner" alt="" />
<img width="100%"
height="280"
:src="info.columnBanner"
alt="" />
<div class="texts">
<p class="text">{{ info.columnName }}</p>
</div>
@ -9,18 +12,23 @@
<ul class="tabs wow fadeInLeft">
<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>
</ul>
<div class="tab-content">
<!-- 根据栏目的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>
</template>
@ -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
// urltabtabtabid
@ -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 {
<style lang="scss" scoped>
.wrap {
background-color: #f9f9f9;
background-color: #f9f9f9;
}
.banner {
position: relative;
height: 280px;
color: #fff;
.texts {
position: absolute;
top: 123px;
left: 243px;
}
position: relative;
height: 280px;
color: #fff;
.texts {
position: absolute;
top: 123px;
left: 243px;
}
.text {
font-size: 3.42rem;
font-weight: 600;
@include ellipsis;
}
.text {
font-size: 3.42rem;
font-weight: 600;
@include ellipsis;
}
.sub {
margin-top: 10px;
font-size: 2rem;
}
.sub {
margin-top: 10px;
font-size: 2rem;
}
}
.tabs {
display: flex;
justify-content: center;
box-shadow: 0px 2px 10px 0px rgba(223,223,223,0.28);
li {
padding: 25px 19px;
margin: 0 70px;
font-size: 1.1rem;
color: #333;
white-space: nowrap;
border-bottom: 4px solid transparent;
text-shadow: 0px 2px 14px rgba(167,167,167,0.26);
cursor: pointer;
&.active {
color: #1583FF;
border-bottom-color: #1583FF;
display: flex;
justify-content: center;
box-shadow: 0px 2px 10px 0px rgba(223, 223, 223, 0.28);
li {
padding: 25px 19px;
margin: 0 70px;
font-size: 1.1rem;
color: #333;
white-space: nowrap;
border-bottom: 4px solid transparent;
text-shadow: 0px 2px 14px rgba(167, 167, 167, 0.26);
cursor: pointer;
&.active {
color: #1583ff;
border-bottom-color: #1583ff;
}
}
}
}
.tab-content {
width: 1000px;
padding: 20px 0;
margin: 0 auto;
width: 1000px;
padding: 20px 0;
margin: 0 auto;
}
@media (max-width: 1200px) {
.banner {
.texts {
.text {
font-size: 1.5rem;
}
.banner {
.texts {
.text {
font-size: 1.5rem;
}
}
}
}
.tabs {
// flex-direction: column;
width: 100%;
overflow-x: scroll;
li {
padding: 1.25rem 0;
margin: 0 1.25rem;
.tabs {
// flex-direction: column;
width: 100%;
overflow-x: scroll;
li {
padding: 1.25rem 0;
margin: 0 1.25rem;
}
}
.tab-content {
width: 90%;
margin: 0 auto;
}
}
.tab-content{
width: 90%;
margin: 0 auto;
}
}
@media (max-width: 320px) {
.banner {
.texts {
left: 6rem;
top: 6rem;
.banner {
.texts {
left: 6rem;
top: 6rem;
}
}
}
}
</style>

@ -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()
})
Loading…
Cancel
Save