From 19c6009c640d29085a8cc00780a184cbea5bb792 Mon Sep 17 00:00:00 2001
From: wang-liang0615 <53748875+wang-liang0615@users.noreply.github.com>
Date: Wed, 3 Jan 2024 13:29:38 +0800
Subject: [PATCH] feat(ui):i18n (#352)
---
.../src/components/CustomCodeMirror/index.vue | 17 +-
.../src/components/CustomIconSelect/index.vue | 2 +-
cmdb-ui/src/components/Menu/menu.js | 22 +-
cmdb-ui/src/components/tools/UserMenu.vue | 4 +-
cmdb-ui/src/lang/en.js | 6 +-
cmdb-ui/src/lang/zh.js | 6 +-
.../cmdb/components/httpSnmpAD/index.vue | 6 +-
.../views/custom_dashboard/customLayout.vue | 2 +-
.../modules/cmdb/views/preference/index.vue | 4 +-
cmdb-ui/src/utils/request.js | 9 +-
.../setting/companyStructure/BatchModal.vue | 14 +-
.../setting/companyStructure/BatchUpload.vue | 53 +-
.../views/setting/companyStructure/index.vue | 2 -
.../setting/components/employeeTable.vue | 708 +-----------------
cmdb-ui/src/views/setting/lang/en.js | 2 +-
15 files changed, 62 insertions(+), 795 deletions(-)
diff --git a/cmdb-ui/src/components/CustomCodeMirror/index.vue b/cmdb-ui/src/components/CustomCodeMirror/index.vue
index 17b9635..4c41281 100644
--- a/cmdb-ui/src/components/CustomCodeMirror/index.vue
+++ b/cmdb-ui/src/components/CustomCodeMirror/index.vue
@@ -89,20 +89,23 @@ export default {
},
},
data() {
- const keyMapList = [
- { value: 'default', label: '默认' },
- { value: 'vim', label: 'vim' },
- { value: 'emacs', label: 'emacs' },
- { value: 'sublime', label: 'sublime' },
- ]
return {
- keyMapList,
coder: null,
fontSize: 14,
keyMap: 'default',
fullscreenExitVisible: false,
}
},
+ computed: {
+ keyMapList() {
+ return [
+ { value: 'default', label: this.$t('default') },
+ { value: 'vim', label: 'vim' },
+ { value: 'emacs', label: 'emacs' },
+ { value: 'sublime', label: 'sublime' },
+ ]
+ },
+ },
mounted() {},
methods: {
initCodeMirror(codeContent) {
diff --git a/cmdb-ui/src/components/CustomIconSelect/index.vue b/cmdb-ui/src/components/CustomIconSelect/index.vue
index b056614..292b5d2 100644
--- a/cmdb-ui/src/components/CustomIconSelect/index.vue
+++ b/cmdb-ui/src/components/CustomIconSelect/index.vue
@@ -92,7 +92,7 @@
:show-upload-list="false"
accept=".svg,.png,.jpg,.jpeg"
>
- 暂无自定义图标,点击此处上传
+ {{ $t('customIconSelect.nodata') }}
diff --git a/cmdb-ui/src/components/Menu/menu.js b/cmdb-ui/src/components/Menu/menu.js
index 2efc86b..5fd203a 100644
--- a/cmdb-ui/src/components/Menu/menu.js
+++ b/cmdb-ui/src/components/Menu/menu.js
@@ -81,25 +81,23 @@ export default {
},
inject: ['reload'],
methods: {
- // 取消订阅
cancelAttributes(e, menu) {
const that = this
e.preventDefault()
e.stopPropagation()
this.$confirm({
- title: '警告',
- content: `确认取消订阅 ${menu.meta.title}?`,
+ title: this.$t('alert'),
+ content: this.$t('cmdb.preference.confirmcancelSub2', { name: menu.meta.title }),
onOk() {
const citypeId = menu.meta.typeId
const unsubCIType = subscribeCIType(citypeId, '')
const unsubTree = subscribeTreeView(citypeId, '')
Promise.all([unsubCIType, unsubTree]).then(() => {
- that.$message.success('取消订阅成功')
+ that.$message.success(that.$t('cmdb.preference.cancelSubSuccess'))
const lastTypeId = window.localStorage.getItem('ops_ci_typeid') || undefined
if (Number(citypeId) === Number(lastTypeId)) {
localStorage.setItem('ops_ci_typeid', '')
}
- // 删除路由
const href = window.location.href
const hrefSplit = href.split('/')
if (Number(hrefSplit[hrefSplit.length - 1]) === Number(citypeId)) {
@@ -119,12 +117,10 @@ export default {
},
// select menu item
onOpenChange(openKeys) {
- // 在水平模式下时执行,并且不再执行后续
if (this.mode === 'horizontal') {
this.openKeys = openKeys
return
}
- // 非水平模式时
const latestOpenKey = openKeys.find(key => !this.openKeys.includes(key))
if (!this.rootSubmenuKeys.includes(latestOpenKey)) {
this.openKeys = openKeys
@@ -162,6 +158,9 @@ export default {
return null
},
renderI18n(title) {
+ if (Object.prototype.toString.call(this.$t(`${title}`)) === '[object Object]') {
+ return title
+ }
return this.$t(`${title}`)
},
renderMenuItem(menu) {
@@ -173,9 +172,6 @@ export default {
const attrs = { href: menu.meta.targetHref || menu.path, target: menu.meta.target }
if (menu.children && menu.hideChildrenInMenu) {
- // 把有子菜单的 并且 父菜单是要隐藏子菜单的
- // 都给子菜单增加一个 hidden 属性
- // 用来给刷新页面时, selectedKeys 做控制用
menu.children.forEach(item => {
item.meta = Object.assign(item.meta, { hidden: true })
})
@@ -196,8 +192,8 @@ export default {
getPopupContainer={(trigger) => trigger}
content={() =>
-
this.handlePerm(e, menu, 'CIType')} class="custom-menu-extra-submenu-item">
授权
-
this.cancelAttributes(e, menu)} class="custom-menu-extra-submenu-item">
取消订阅
+
this.handlePerm(e, menu, 'CIType')} class="custom-menu-extra-submenu-item">
{ this.renderI18n('grant') }
+
this.cancelAttributes(e, menu)} class="custom-menu-extra-submenu-item">
{ this.renderI18n('cmdb.preference.cancelSub') }
}
>
@@ -287,7 +283,7 @@ export default {
this.$refs.cmdbGrantRelationView.open({ name: menu.meta.name, cmdbGrantType: 'relation_view' })
}
} else {
- this.$message.error('权限不足!')
+ this.$message.error(this.$t('noPermission'))
}
})
}
diff --git a/cmdb-ui/src/components/tools/UserMenu.vue b/cmdb-ui/src/components/tools/UserMenu.vue
index 74bf2ec..ed7e6b4 100644
--- a/cmdb-ui/src/components/tools/UserMenu.vue
+++ b/cmdb-ui/src/components/tools/UserMenu.vue
@@ -68,8 +68,8 @@ export default {
const that = this
this.$confirm({
- title: '提示',
- content: '真的要注销登录吗 ?',
+ title: this.$t('tip'),
+ content: this.$t('topMenu.confirmLogout'),
onOk() {
// localStorage.removeItem('ops_cityps_currentId')
localStorage.clear()
diff --git a/cmdb-ui/src/lang/en.js b/cmdb-ui/src/lang/en.js
index 63e2f3f..feba7ea 100644
--- a/cmdb-ui/src/lang/en.js
+++ b/cmdb-ui/src/lang/en.js
@@ -104,12 +104,15 @@ export default {
max: 'Max',
min: 'Min',
visual: 'Visual',
+ default: 'default',
+ tip: 'Tip',
pagination: {
total: '{range0}-{range1} of {total} items'
},
topMenu: {
personalCenter: 'Personal Center',
logout: 'logout',
+ confirmLogout: 'Are you sure to log out?'
},
cmdbFilterComp: {
conditionFilter: 'Conditional filtering',
@@ -139,7 +142,8 @@ export default {
multicolor: 'Multicolor',
custom: 'Custom',
preview: 'Preview',
- sizeLimit: 'The image size cannot exceed 2MB!'
+ sizeLimit: 'The image size cannot exceed 2MB!',
+ nodata: 'There are currently no custom icons available. Click here to upload'
},
cmdb: cmdb_en,
cs: cs_en,
diff --git a/cmdb-ui/src/lang/zh.js b/cmdb-ui/src/lang/zh.js
index e0f722f..b31e555 100644
--- a/cmdb-ui/src/lang/zh.js
+++ b/cmdb-ui/src/lang/zh.js
@@ -104,12 +104,15 @@ export default {
max: '最大值',
min: '最小值',
visual: '虚拟',
+ default: '默认',
+ tip: '提示',
pagination: {
total: '当前展示 {range0}-{range1} 条数据, 共 {total} 条'
},
topMenu: {
personalCenter: '个人中心',
logout: '退出登录',
+ confirmLogout: '确认退出登录吗?'
},
cmdbFilterComp: {
conditionFilter: '条件过滤',
@@ -139,7 +142,8 @@ export default {
multicolor: '多色',
custom: '自定义',
preview: '预览',
- sizeLimit: '图片大小不可超过2MB!'
+ sizeLimit: '图片大小不可超过2MB!',
+ nodata: '暂无自定义图标,点击此处上传'
},
cmdb: cmdb_zh,
cs: cs_zh,
diff --git a/cmdb-ui/src/modules/cmdb/components/httpSnmpAD/index.vue b/cmdb-ui/src/modules/cmdb/components/httpSnmpAD/index.vue
index a369162..2e19fa4 100644
--- a/cmdb-ui/src/modules/cmdb/components/httpSnmpAD/index.vue
+++ b/cmdb-ui/src/modules/cmdb/components/httpSnmpAD/index.vue
@@ -103,9 +103,9 @@ export default {
},
httpMap() {
return {
- [this.$t('cmdb.components.aliyun')]: { name: 'aliyun' },
- [this.$t('cmdb.components.tencentcloud')]: { name: 'tencentcloud' },
- [this.$t('cmdb.components.huaweicloud')]: { name: 'huaweicloud' },
+ 阿里云: { name: 'aliyun' },
+ 腾讯云: { name: 'tencentcloud' },
+ 华为云: { name: 'huaweicloud' },
AWS: { name: 'aws' },
}
},
diff --git a/cmdb-ui/src/modules/cmdb/views/custom_dashboard/customLayout.vue b/cmdb-ui/src/modules/cmdb/views/custom_dashboard/customLayout.vue
index 63e75a2..58b2237 100644
--- a/cmdb-ui/src/modules/cmdb/views/custom_dashboard/customLayout.vue
+++ b/cmdb-ui/src/modules/cmdb/views/custom_dashboard/customLayout.vue
@@ -114,7 +114,7 @@
type="primary"
icon="plus"
>
- 定制仪表盘
+ {{ $t('cmdb.menu.customDashboard') }}
{{ $t('cmdb.custom_dashboard.noCustomDashboard') }}
diff --git a/cmdb-ui/src/modules/cmdb/views/preference/index.vue b/cmdb-ui/src/modules/cmdb/views/preference/index.vue
index 8fd2003..da08e2a 100644
--- a/cmdb-ui/src/modules/cmdb/views/preference/index.vue
+++ b/cmdb-ui/src/modules/cmdb/views/preference/index.vue
@@ -16,7 +16,7 @@
height: '23px',
fontSize: '14px',
}"
- />个
个
diff --git a/cmdb-ui/src/utils/request.js b/cmdb-ui/src/utils/request.js
index 3ac2dfb..ba09e46 100644
--- a/cmdb-ui/src/utils/request.js
+++ b/cmdb-ui/src/utils/request.js
@@ -1,4 +1,4 @@
-/* eslint-dsiable */
+ /* eslint-dsiable */
import Vue from 'vue'
import axios from 'axios'
import { VueAxios } from './axios'
@@ -6,20 +6,22 @@ import message from 'ant-design-vue/es/message'
import notification from 'ant-design-vue/es/notification'
import { ACCESS_TOKEN } from '@/store/global/mutation-types'
import router from '@/router'
+import store from '@/store'
// 创建 axios 实例
const service = axios.create({
baseURL: process.env.VUE_APP_API_BASE_URL, // api base_url
timeout: 6000, // 请求超时时间
withCredentials: true,
- crossDomain: true
+ crossDomain: true,
})
const err = (error) => {
console.log(error)
const reg = /5\d{2}/g
if (error.response && reg.test(error.response.status)) {
- message.error('服务端未知错误, 请联系管理员!')
+ const errorMsg = ((error.response || {}).data || {}).message || '服务端未知错误, 请联系管理员!'
+ message.error(errorMsg)
} else if (error.response.status === 412) {
let seconds = 5
notification.warning({
@@ -64,6 +66,7 @@ service.interceptors.request.use(config => {
if (token) {
config.headers['Access-Token'] = token // 让每个请求携带自定义 token 请根据实际情况自行修改
}
+ config.headers['Accept-Language'] = store?.state?.locale ?? 'zh'
return config
}, err)
diff --git a/cmdb-ui/src/views/setting/companyStructure/BatchModal.vue b/cmdb-ui/src/views/setting/companyStructure/BatchModal.vue
index 69b55f1..25d3f2d 100644
--- a/cmdb-ui/src/views/setting/companyStructure/BatchModal.vue
+++ b/cmdb-ui/src/views/setting/companyStructure/BatchModal.vue
@@ -25,18 +25,6 @@
-
-
-
-
-
@@ -75,7 +63,7 @@ export default {
const validatePass = (rule, value, callback) => {
console.log(this.batchForm)
if (this.batchForm.value === '') {
- callback(new Error(this.$t('cs.companyStructure.password_placeholder')))
+ callback(new Error(this.$t('cs.companyStructure.passwordPlaceholder')))
} else {
this.$refs.batchForm.validateField('repeatPassword')
callback()
diff --git a/cmdb-ui/src/views/setting/companyStructure/BatchUpload.vue b/cmdb-ui/src/views/setting/companyStructure/BatchUpload.vue
index ccff2c4..d0b938c 100644
--- a/cmdb-ui/src/views/setting/companyStructure/BatchUpload.vue
+++ b/cmdb-ui/src/views/setting/companyStructure/BatchUpload.vue
@@ -20,19 +20,24 @@
- 选择文件
+ {{ $t('cs.companyStructure.selectFile') }}
{{ $t('cs.companyStructure.clickDownloadImportTemplate') }}
- 导入总数据{{ allCount }}条, 导入成功 {{ allCount - errorCount }} 条,
- {{ $t('cs.companyStructure.importSuccess', {allCount: allCount}) }}{{ allCount - errorCount }}
- {{ $t('cs.companyStructure.count')}},
- {{ $t('cs.companyStructure.importError') }}{{ errorCount }}{{ $t('cs.companyStructure.count')}}
+ {{ $t('cs.companyStructure.importSuccess', { allCount: allCount })
+ }} {{ allCount - errorCount }} {{ $t('cs.companyStructure.count') }},
+ {{ $t('cs.companyStructure.importFailed') }} {{ errorCount }} {{ $t('cs.companyStructure.count') }}
{{ $t('cs.companyStructure.editPosition') }}
- {{ $t('cs.companyStructure.editAnnualLeave') }}
-
{{ $t('cs.companyStructure.resetPassword') }}
{{ $t('cs.companyStructure.block') }}
diff --git a/cmdb-ui/src/views/setting/components/employeeTable.vue b/cmdb-ui/src/views/setting/components/employeeTable.vue
index 85cd9e8..ad40758 100644
--- a/cmdb-ui/src/views/setting/components/employeeTable.vue
+++ b/cmdb-ui/src/views/setting/components/employeeTable.vue
@@ -92,6 +92,10 @@
{{ $t('cs.companyStructure.sex') }}
+
+ {{ $t('cs.companyStructure.male') }}
+ {{ $t('cs.companyStructure.female') }}
+
-
-
-
-
- {{ $t('cs.companyStructure.annualLeave') }}
-
-
-
-
-
-
-
- {{ $t('cs.companyStructure.virtualAnnualLeave') }}
-
-
-
-
-
-
-
- {{ $t('cs.companyStructure.parentingLeave') }}
-
-
-
-
-
-
-
- {{ $t('cs.companyStructure.entryDate') }}
-
-
-
-
-
-
-
- {{ $t('cs.companyStructure.isInternship') }}
-
-
-
- {{ getIsInterInship(row.is_internship) }}
- I
-
-
-
-
- {{ $t('cs.companyStructure.leaveDate') }}
-
-
-
-
-
-
-
- {{ $t('cs.companyStructure.idCard') }}
-
-
-
-
-
-
-
- {{ $t('cs.companyStructure.idPlace') }}
-
-
-
-
-
-
-
- {{ $t('cs.companyStructure.idPlace') }}
-
-
-
-
-
-
-
- {{ $t('cs.companyStructure.party') }}
-
-
-
-
-
-
-
- {{ $t('cs.companyStructure.hometown') }}
-
-
-
-
-
-
-
- {{ $t('cs.companyStructure.hometown') }}
-
-
-
-
-
-
-
- {{ $t('cs.companyStructure.marry') }}
-
-
-
-
-
-
-
- {{ $t('cs.companyStructure.maxDegree') }}
-
-
-
-
-
-
-
- {{ $t('cs.companyStructure.emergencyPerson') }}
-
-
-
-
-
-
-
- {{ $t('cs.companyStructure.emergencyPhone') }}
-
-
-
-
-
-
-
- {{ $t('cs.companyStructure.bankCardNumber') }}
-
-
-
-
-
-
-
- {{ $t('cs.companyStructure.bankCardName') }}
-
-
-
-
-
-
-
- {{ $t('cs.companyStructure.openingBank') }}
-
-
-
-
-
-
-
- {{ $t('cs.companyStructure.accountOpeningLocation') }}
-
-
-
-
-
-
-
- {{ $t('cs.companyStructure.school') }}
-
-
-
-
-
-
-
- {{ $t('cs.companyStructure.major') }}
-
-
-
-
-
-
-
- {{ $t('cs.companyStructure.education') }}
-
-
-
-
-
-
-
- {{ $t('cs.companyStructure.graduationYear') }}
-
-
-
-
-
-
-
- {{ $t('cs.companyStructure.childrenName') }}
-
-
-
-
-
-
-
- {{ $t('cs.companyStructure.sex') }}
-
-
-
-
-
-
-
- {{ $t('cs.companyStructure.birthDate') }}
-
-
-
-
-
-
-
- {{ $t('cs.companyStructure.leftParentingLeave') }}
-
-
-
-
-
-
-
- {{ $t('cs.companyStructure.birthDate') }}
-
-
-
-
-
-
-
- {{ $t('cs.companyStructure.birthPlace') }}
-
-
-
-
-
-
-
- {{ $t('cs.companyStructure.nationalityRegion') }}
-
-
-
-
-
-
-
- {{ $t('cs.companyStructure.firstEntryDate') }}
-
-
-
-
-
-
-
- {{ $t('cs.companyStructure.estimatedDepartureDate') }}
-
-
-
-
-
-
-
- {{ $t('cs.companyStructure.lastLogin') }}
-
-
-