diff --git a/src/common/lang/en-us.js b/src/common/lang/en-us.js index 4312647..037a01b 100644 --- a/src/common/lang/en-us.js +++ b/src/common/lang/en-us.js @@ -208,6 +208,15 @@ module.exports = { support: 'You can upload files in ', formatUpload: ' formats. ', theSizeIs: 'The size is ', + loginExpired: 'Login has expired', + loginExpiredMessage: 'Sorry, the login has expired. Please log in again', + logInAgain: 'Log in again', + loggingBackIn: 'Login has expired, logging in again', + prompted: 'prompted', + noAccess: 'no access', + resourceNotFound: 'Sorry, the resource was not found!', + networkTimeout: 'Network Timeout', + unauthorized: 'Unauthorized, please log in again', // 树右键 treeRight: { addFolder: 'Create New Folder', diff --git a/src/common/lang/index.js b/src/common/lang/index.js new file mode 100644 index 0000000..7df88ef --- /dev/null +++ b/src/common/lang/index.js @@ -0,0 +1,16 @@ +import VueI18n from 'vue-i18n' +import LangENUS from '@/common/lang/en-us' +import LangZHCN from '@/common/lang/zh-cn' +import Vue from 'vue' + +Vue.use(VueI18n) + +const i18n = new VueI18n({ + locale: 'zh-cn', + messages: { + 'en-us': LangENUS, + 'zh-cn': LangZHCN + } +}) + +export default i18n diff --git a/src/common/lang/zh-cn.js b/src/common/lang/zh-cn.js index 1ce5616..a814b88 100644 --- a/src/common/lang/zh-cn.js +++ b/src/common/lang/zh-cn.js @@ -225,6 +225,15 @@ module.exports = { support: '支持', formatUpload: '格式上传,', theSizeIs: '大小为', + loginExpired: '登录已过期', + loginExpiredMessage: '很抱歉,登录已过期,请重新登录', + logInAgain: '重新登录', + loggingBackIn: '登录已过期,正在重新登陆', + prompted: '系统提示', + noAccess: '拒绝访问', + resourceNotFound: '很抱歉,资源未找到!', + networkTimeout: '网络超时', + unauthorized: '未授权,请重新登录', // 标准字段 standardField: { standardEnglishName: '标准英文名称', diff --git a/src/main.js b/src/main.js index 0859639..5009e3c 100644 --- a/src/main.js +++ b/src/main.js @@ -15,16 +15,13 @@ import Antd, { version } from 'ant-design-vue' // import Viser from 'viser-vue' import 'ant-design-vue/dist/antd.less' // or 'ant-design-vue/dist/antd.less' -import VueI18n from 'vue-i18n' -import LangENUS from './common/lang/en-us' -import LangZHCN from './common/lang/zh-cn' - import '@/permission' // permission control // import '@/utils/filter' // base filtermybatis-plus // TODO 为什么要用2个图片预览的工具? // import preview from 'vue-photo-preview' // import 'vue-photo-preview/dist/skin.css' +// import 'vue-photo-preview/dist/skin.css' import Viewer from 'v-viewer' import 'viewerjs/dist/viewer.css' @@ -51,6 +48,8 @@ import JeroComponents from '@/components/jero/index' import JDictComponenets from '@comp/dict/index.js' import JTable from '@comp/jero/JTable.vue' +import i18n from '@/common/lang' + // Vue.prototype.rules = rules Vue.config.productionTip = false Vue.use(Storage, config.storageOptions) @@ -58,7 +57,6 @@ Vue.use(Antd) Vue.use(VueAxios, router) Vue.use(hasPermission) -Vue.use(VueI18n) Vue.use(Viewer) Vue.use(JeroComponents) Vue.use(JDictComponenets) @@ -69,14 +67,6 @@ Viewer.setDefaults({ toolbar: false }) -const i18n = new VueI18n({ - locale: 'zh-cn', - messages: { - 'en-us': LangENUS, - 'zh-cn': LangZHCN - } -}) - SSO.init(() => { main() }) diff --git a/src/mixins/ConfigurableTableMixin.js b/src/mixins/ConfigurableTableMixin.js index e45f271..d50b4db 100644 --- a/src/mixins/ConfigurableTableMixin.js +++ b/src/mixins/ConfigurableTableMixin.js @@ -172,7 +172,7 @@ export const ConfigurableTableMixin = { if (this.operationList && this.operationList.length > this.operateMaxNum + 1) { width += this.getTextWith(this.operationList[0].text) + this.getTextWith(this.$t('more')) } else if (this.operationList && this.operationList.length > 1) { - width += this.getTextWith(this.operationList[0].text) + this.getTextWith(this.operationList[1].text) + width += this.getTextWith(this.operationList[0].text) + this.getTextWith(this.operationList[1].text) console.log(width) } const operateColumn = JSON.parse(JSON.stringify(this.operateColumn)) @@ -322,9 +322,9 @@ export const ConfigurableTableMixin = { const token = Vue.ls.get(ACCESS_TOKEN) if (token && data.message.includes('Token失效')) { this.error({ - title: '登录已过期', - content: '很抱歉,登录已过期,请重新登录', - okText: '重新登录', + title: this.$t('loginExpired'), + content: this.$t('loginExpiredMessage'), + okText: this.$t('logInAgain'), mask: false, onOk: () => { store.dispatch('Logout').then(() => { diff --git a/src/mixins/JeroListMixin.js b/src/mixins/JeroListMixin.js index d75a486..f870f27 100644 --- a/src/mixins/JeroListMixin.js +++ b/src/mixins/JeroListMixin.js @@ -456,9 +456,9 @@ export const JeroListMixin = { const token = Vue.ls.get(ACCESS_TOKEN) if (token && data.message.includes('Token失效')) { this.error({ - title: '登录已过期', - content: '很抱歉,登录已过期,请重新登录', - okText: '重新登录', + title: this.$t('loginExpired'), + content: this.$t('loginExpiredMessage'), + okText: this.$t('logInAgain'), mask: false, onOk: () => { store.dispatch('Logout').then(() => { diff --git a/src/utils/request.js b/src/utils/request.js index 66b4799..369bd39 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -5,6 +5,7 @@ import { VueAxios } from './axios' import router from '@/router/index' import { ACCESS_TOKEN, TENANT_ID } from '@/store/mutation-types' import { Modal } from 'ant-design-vue' +import i18n from '@/common/lang' /** * 【指定 axios的 baseURL】 @@ -29,7 +30,7 @@ const err = (error) => { console.log('------异常响应------', error.response.status) switch (error.response.status) { case 403: - Vue.prototype.$Jnotification.error({ message: '系统提示', description: '拒绝访问', duration: 4 }) + Vue.prototype.$Jnotification.error({ message: i18n.t('prompted'), description: i18n.t('noAccess'), duration: 4 }) break case 500: console.log('------error.response------', error.response) @@ -42,12 +43,12 @@ const err = (error) => { if (typeof data === 'string' ? data.includes('Token失效') : data.message.includes('Token失效')) { // update-begin- --- author:scott ------ date:20190225 ---- for:Token失效采用弹框模式,不直接跳转---- if (/wxwork|dingtalk/i.test(navigator.userAgent)) { - Vue.prototype.$Jmessage.loading('登录已过期,正在重新登陆', 0) + Vue.prototype.$Jmessage.loading(i18n.t('loggingBackIn'), 0) } else { Vue.prototype.$Jmodal.error({ - title: '登录已过期', - content: '很抱歉,登录已过期,请重新登录', - okText: '重新登录', + title: i18n.t('loginExpired'), + content: i18n.t('loginExpiredMessage'), + okText: i18n.t('logInAgain'), mask: false, onOk: () => { store.dispatch('Logout') @@ -58,13 +59,13 @@ const err = (error) => { } break case 404: - Vue.prototype.$Jnotification.error({ message: '系统提示', description: '很抱歉,资源未找到!', duration: 4 }) + Vue.prototype.$Jnotification.error({ message: i18n.t('prompted'), description: i18n.t('resourceNotFound'), duration: 4 }) break case 504: - Vue.prototype.$Jnotification.error({ message: '系统提示', description: '网络超时' }) + Vue.prototype.$Jnotification.error({ message: i18n.t('prompted'), description: i18n.t('networkTimeout') }) break case 401: - Vue.prototype.$Jnotification.error({ message: '系统提示', description: '未授权,请重新登录', duration: 4 }) + Vue.prototype.$Jnotification.error({ message: i18n.t('prompted'), description: i18n.t('unauthorized'), duration: 4 }) if (token) { store.dispatch('Logout').then(() => { setTimeout(() => { @@ -75,7 +76,7 @@ const err = (error) => { break default: Vue.prototype.$Jnotification.error({ - message: '系统提示', + message: i18n.t('prompted'), description: data.message, duration: 4 }) @@ -83,9 +84,9 @@ const err = (error) => { } } else if (error.message) { if (error.message.includes('timeout')) { - Vue.prototype.$Jnotification.error({ message: '系统提示', description: '网络超时' }) + Vue.prototype.$Jnotification.error({ message: i18n.t('prompted'), description: i18n.t('networkTimeout') }) } else { - Vue.prototype.$Jnotification.error({ message: '系统提示', description: error.message }) + Vue.prototype.$Jnotification.error({ message: i18n.t('prompted'), description: error.message }) } } return Promise.reject(error) @@ -157,9 +158,9 @@ function blobToJson (data) { console.log('token----------》', token) if (token && jsonData.message.includes('Token失效')) { Modal.error({ - title: '登录已过期', - content: '很抱歉,登录已过期,请重新登录', - okText: '重新登录', + title: i18n.t('loginExpired'), + content: i18n.t('loginExpiredMessage'), + okText: i18n.t('logInAgain'), mask: false, onOk: () => { store.dispatch('Logout').then(() => { diff --git a/src/views/workCenter/regulatoryComplianceCheckProcess/modules/MainFinderDistributesBaseInfo.vue b/src/views/workCenter/regulatoryComplianceCheckProcess/modules/MainFinderDistributesBaseInfo.vue index 22e6c74..6f31ac3 100644 --- a/src/views/workCenter/regulatoryComplianceCheckProcess/modules/MainFinderDistributesBaseInfo.vue +++ b/src/views/workCenter/regulatoryComplianceCheckProcess/modules/MainFinderDistributesBaseInfo.vue @@ -637,9 +637,9 @@ export default { const token = Vue.ls.get(ACCESS_TOKEN) if (token && data.message.includes('Token失效')) { this.error({ - title: '登录已过期', - content: '很抱歉,登录已过期,请重新登录', - okText: '重新登录', + title: this.$t('loginExpired'), + content: this.$t('loginExpiredMessage'), + okText: this.$t('logInAgain'), mask: false, onOk: () => { store.dispatch('Logout').then(() => {