From abab03eb12087fb9ee5ae33fb62afea672802f64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B4=AA=E6=B4=AA?= <2498601771@qq.com> Date: Wed, 20 Dec 2023 18:38:38 +0800 Subject: [PATCH] =?UTF-8?q?fix:=201=E3=80=81=E6=90=9C=E7=B4=A2=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E6=9C=89=E5=85=B3=E6=9E=9A=E4=B8=BE=E7=9A=84=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=9B=BD=E9=99=85=E5=8C=96=EF=BC=9B2=E3=80=81?= =?UTF-8?q?=E4=BF=AE=E5=A4=8Dtag=E6=A8=A1=E5=BC=8F=E4=B8=8B=E5=88=87?= =?UTF-8?q?=E6=8D=A2key=EF=BC=8Cvalue=E8=BF=98=E4=BF=9D=E7=95=99=E4=B8=8A?= =?UTF-8?q?=E6=AC=A1=E9=80=89=E6=8B=A9=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=9B?= =?UTF-8?q?3=E3=80=81=E4=BF=AE=E5=A4=8D=E5=88=87=E6=8D=A2=E8=AF=AD?= =?UTF-8?q?=E8=A8=80=E7=8E=AF=E5=A2=83=EF=BC=8C=E6=90=9C=E7=B4=A2=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E5=8C=85=E5=90=AB=E5=85=B6=E4=BB=96=E8=AF=AD=E8=A8=80?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E4=B8=8D=E8=83=BD=E8=AF=86=E5=88=AB=E8=BD=AC?= =?UTF-8?q?=E6=8D=A2=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/advancedSearch/TagMode.vue | 19 +++++++++++++++++++ src/components/advancedSearch/meta/parser.js | 16 ++++++++++++++-- .../showhint/Hint/HelperInfo.vue | 18 +++++++++--------- src/i18n/index.js | 1 + src/store/index.js | 3 ++- src/utils/static-data.js | 14 +++++++------- src/utils/tools.js | 18 +++++++++++++++++- src/views/detections/DetectionRow.vue | 5 +++-- src/views/detections/Index.vue | 15 ++++++++------- .../DetectionSecurityEventOverview.vue | 6 ++++-- 10 files changed, 84 insertions(+), 31 deletions(-) diff --git a/src/components/advancedSearch/TagMode.vue b/src/components/advancedSearch/TagMode.vue index c28398ab..973c926d 100644 --- a/src/components/advancedSearch/TagMode.vue +++ b/src/components/advancedSearch/TagMode.vue @@ -273,6 +273,25 @@ export default { if (!meta.operator.value) { meta.operator.isEditing = true meta.operator.show = true + } else { + // 切换column,清除上次column选择的value,包含枚举的则删除,in操作符的让类型回归array + meta.value.value = '' + meta.value.label = '' + meta.value.isEditing = true + meta.value.show = true + const obj = enumerateData.find(d => d.name === meta.column.label) + if (obj) { + meta.doc = obj + if (this.$refs.valuesSelect) { + // 触发focus后,select弹窗并没有生效 + this.$refs.valuesSelect[0].focus(meta) + } + } else { + delete meta.doc + } + if (meta.operator.value.toLowerCase() === 'in') { + meta.column.type = columnType.array + } } }, 200) } diff --git a/src/components/advancedSearch/meta/parser.js b/src/components/advancedSearch/meta/parser.js index 5b5108a2..6c8b7784 100644 --- a/src/components/advancedSearch/meta/parser.js +++ b/src/components/advancedSearch/meta/parser.js @@ -4,6 +4,7 @@ import ParserError, { errorDesc, errorTypes } from '@/components/advancedSearch/ import _ from 'lodash' import { ElMessage } from 'element-plus' import i18n from '@/i18n' +import store from '@/store' const strReg = { // 需要不限制语言,正则过滤中英日俄语出错实现语言都通过。留个记录观察,后续校验 @@ -1500,11 +1501,22 @@ export default class Parser { searchList.forEach((item, index) => { const obj = this.columnList.find(d => item.indexOf(d.label) > -1) if (obj && obj.doc.data) { - obj.doc.data.forEach(item1 => { + for (let i = 0; i < obj.doc.data.length; i++) { + const item1 = obj.doc.data[i] if (item.indexOf(item1.code) > -1) { searchList[index] = searchList[index].replace(new RegExp(item1.code, 'g'), item1.value) + // 匹配到code,终止匹配 + break + } else { + // 该操作是避免中文参数切换到英文环境时,code经i18n转为英文,匹配不到中文参数的情况 + Object.keys(store.state.i18nObj).forEach(lang => { + const i18nCode = store.state.i18nObj[lang][item1.code1] + if (item.indexOf(i18nCode) > -1) { + searchList[index] = searchList[index].replace(new RegExp(i18nCode, 'g'), item1.value) + } + }) } - }) + } } }) key = searchList.join(' AND ') diff --git a/src/components/advancedSearch/showhint/Hint/HelperInfo.vue b/src/components/advancedSearch/showhint/Hint/HelperInfo.vue index abde69bb..4a105daf 100644 --- a/src/components/advancedSearch/showhint/Hint/HelperInfo.vue +++ b/src/components/advancedSearch/showhint/Hint/HelperInfo.vue @@ -82,21 +82,21 @@ export default { let searchKey = hintSearch.toUpperCase() || '' searchKey = searchKey.trim() - if (functionTips[searchKey]) { - return functionTips[searchKey].description - } + // if (functionTips[searchKey]) { + // return functionTips[searchKey].description + // } if (operatorTips[searchKey]) { return operatorTips[searchKey].description } - if (sqlTips[searchKey]) { - return sqlTips[searchKey].description - } + // if (sqlTips[searchKey]) { + // return sqlTips[searchKey].description + // } if (filterTips[searchKey]) { return filterTips[searchKey].description } - if (varTips[searchKey]) { - return varTips[searchKey].description - } + // if (varTips[searchKey]) { + // return varTips[searchKey].description + // } // 完整的匹配关键字 if (this.getDataset()) { diff --git a/src/i18n/index.js b/src/i18n/index.js index 2c7c4e9d..ac04e863 100644 --- a/src/i18n/index.js +++ b/src/i18n/index.js @@ -11,6 +11,7 @@ export async function loadI18n () { const items = await getI18n() if (items) { store.commit('loadI18n') + store.state.i18nObj = items Object.keys(items).forEach(lang => { i18n.global.mergeLocaleMessage(lang, items[lang]) }) diff --git a/src/store/index.js b/src/store/index.js index 32d52966..ff2511d1 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -12,7 +12,8 @@ const store = createStore({ i18n: false, showEntityTypeSelector: false, // 在entity explore页面时,控制header显示实体类型选择框 from: '', // entity type - test: 'jest' // 用于单测的demo + test: 'jest', // 用于单测的demo + i18nObj: {} // 存放i18n的值,用于搜索组件切换环境时参数包含其他语言时使用的 } }, getters: { diff --git a/src/utils/static-data.js b/src/utils/static-data.js index 0f2bf3ce..5bca000f 100644 --- a/src/utils/static-data.js +++ b/src/utils/static-data.js @@ -426,8 +426,8 @@ export const enumerateData = [ { name: 'status', data: [ - { code: 'Ended', value: 1 }, - { code: 'Active', value: 0 } + { code: _this.$t('detections.ended'), code1: 'detections.ended', value: 1 }, + { code: _this.$t('detections.active'), code1: 'detections.active', value: 0 } ] }, { @@ -446,11 +446,11 @@ export const enumerateData = [ { name: 'severity', data: [ - { code: 'critical', value: 'critical' }, - { code: 'high', value: 'high' }, - { code: 'Medium', value: 'Medium' }, - { code: 'low', value: 'low' }, - { code: 'info', value: 'info' } + { code: _this.$t('overall.critical'), code1: 'overall.critical', value: 'critical' }, + { code: _this.$t('overall.high'), code1: 'overall.high', value: 'high' }, + { code: _this.$t('overall.medium'), code1: 'overall.medium', value: 'medium' }, + { code: _this.$t('overall.low'), code1: 'overall.low', value: 'low' }, + { code: _this.$t('overall.info'), code1: 'overall.info', value: 'info' } ] } ] diff --git a/src/utils/tools.js b/src/utils/tools.js index c561a2b4..b518cecb 100644 --- a/src/utils/tools.js +++ b/src/utils/tools.js @@ -1,7 +1,7 @@ import { ElMessageBox, ElMessage } from 'element-plus' import i18n from '@/i18n' import _ from 'lodash' -import { storageKey, iso36112, topDomain, echartsFontSize, dbGeoDataTableName, networkTable, dbDrilldownTableConfig, ZH, EN } from '@/utils/constants' +import { storageKey, iso36112, topDomain, echartsFontSize, dbGeoDataTableName, networkTable, dbDrilldownTableConfig, ZH, EN, securityLevel } from '@/utils/constants' import { getIso36112JsonData, getDictList } from '@/utils/api' import { format } from 'echarts' import router from '@/router' @@ -1447,3 +1447,19 @@ export const changeTimeByDate = (date) => { } } } + +/** + * 转换严重程度severity的国际化值 + */ +export const changeI18nOfSeverity = (severity) => { + if (severity) { + const obj = securityLevel.find(d => d.value === severity) + if (obj) { + return i18n.global.t(obj.label) + } else { + return severity + } + } else { + return '-' + } +} diff --git a/src/views/detections/DetectionRow.vue b/src/views/detections/DetectionRow.vue index b24a443a..586cf970 100644 --- a/src/views/detections/DetectionRow.vue +++ b/src/views/detections/DetectionRow.vue @@ -33,7 +33,7 @@