From a2e4e31869ca5fab9f876d36d2bd3277775dde9e Mon Sep 17 00:00:00 2001 From: LuckyFBB <976060700@qq.com> Date: Fri, 14 Nov 2025 11:09:23 +0800 Subject: [PATCH 1/2] fix(filterrules): support i18n --- src/filterRules/index.tsx | 4 ---- src/filterRules/ruleController/index.tsx | 15 +++++++++------ src/locale/en-US.ts | 2 ++ src/locale/useLocale.tsx | 2 ++ src/locale/zh-CN.ts | 2 ++ 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/filterRules/index.tsx b/src/filterRules/index.tsx index 12f25def7..17a510838 100644 --- a/src/filterRules/index.tsx +++ b/src/filterRules/index.tsx @@ -11,10 +11,6 @@ export enum ROW_PERMISSION_RELATION { AND = 1, OR = 2, } -export const ROW_PERMISSION_RELATION_TEXT = { - [ROW_PERMISSION_RELATION.AND]: '且', - [ROW_PERMISSION_RELATION.OR]: '或', -}; export interface IComponentProps { rowKey: string; // 当前节点的唯一标识 diff --git a/src/filterRules/ruleController/index.tsx b/src/filterRules/ruleController/index.tsx index 60af663d1..673f5a142 100644 --- a/src/filterRules/ruleController/index.tsx +++ b/src/filterRules/ruleController/index.tsx @@ -2,13 +2,9 @@ import React from 'react'; import { MinusCircleOutlined, PlusCircleOutlined } from '@dtinsight/react-icons'; import { InternalNamePath } from 'antd/lib/form/interface'; import classnames from 'classnames'; +import { useLocale } from 'dt-react-component'; -import { - IComponentProps, - IFilterValue, - ROW_PERMISSION_RELATION, - ROW_PERMISSION_RELATION_TEXT, -} from '..'; +import { IComponentProps, IFilterValue, ROW_PERMISSION_RELATION } from '..'; import './index.scss'; interface IProps { @@ -46,6 +42,13 @@ export const RulesController = (props: IProps) => { onChangeRowValues, } = props; + const locale = useLocale('FilterRules'); + + const ROW_PERMISSION_RELATION_TEXT = { + [ROW_PERMISSION_RELATION.AND]: locale.and, + [ROW_PERMISSION_RELATION.OR]: locale.or, + }; + const isCondition = (item: IFilterValue) => item?.type && [ROW_PERMISSION_RELATION.AND, ROW_PERMISSION_RELATION.OR].includes(item?.type); diff --git a/src/locale/en-US.ts b/src/locale/en-US.ts index 6f44cbf28..710db3f96 100644 --- a/src/locale/en-US.ts +++ b/src/locale/en-US.ts @@ -27,6 +27,8 @@ const localeValues: Locale = { }, FilterRules: { message: 'Must have one data item', + and: 'And', + or: 'Or', }, Fullscreen: { exitFull: 'Exit Full Screen', diff --git a/src/locale/useLocale.tsx b/src/locale/useLocale.tsx index 9d57f29e2..d61c050e0 100644 --- a/src/locale/useLocale.tsx +++ b/src/locale/useLocale.tsx @@ -21,6 +21,8 @@ export interface Locale { }; FilterRules: { message: string; + and: string; + or: string; }; Fullscreen: { exitFull: string; full: string }; GlobalLoading: { loading: string }; diff --git a/src/locale/zh-CN.ts b/src/locale/zh-CN.ts index 6e3e55449..a5f00b461 100644 --- a/src/locale/zh-CN.ts +++ b/src/locale/zh-CN.ts @@ -28,6 +28,8 @@ const localeValues: Locale = { }, FilterRules: { message: '必须有一条数据', + and: '且', + or: '或', }, Fullscreen: { exitFull: '退出全屏', From 491609f769acf69b464800d0c3b7908c7e203430 Mon Sep 17 00:00:00 2001 From: LuckyFBB <976060700@qq.com> Date: Fri, 14 Nov 2025 11:50:49 +0800 Subject: [PATCH 2/2] test(filterrules): fix unit test --- src/filterRules/__tests__/filterRules.test.tsx | 1 + src/filterRules/ruleController/index.tsx | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/filterRules/__tests__/filterRules.test.tsx b/src/filterRules/__tests__/filterRules.test.tsx index 5d8693740..c02057d66 100644 --- a/src/filterRules/__tests__/filterRules.test.tsx +++ b/src/filterRules/__tests__/filterRules.test.tsx @@ -10,6 +10,7 @@ const MyInput = ({ rowValues: { input }, rowKey, onChange }: IComponentProps onChange?.(rowKey, { input: e.target.value })} /> ); +jest.mock('remark-gfm', () => () => {}); describe('FilterRules', () => { test('should support FilterRules success render', () => { const wrapper = render( diff --git a/src/filterRules/ruleController/index.tsx b/src/filterRules/ruleController/index.tsx index 673f5a142..bc3cf544b 100644 --- a/src/filterRules/ruleController/index.tsx +++ b/src/filterRules/ruleController/index.tsx @@ -2,8 +2,8 @@ import React from 'react'; import { MinusCircleOutlined, PlusCircleOutlined } from '@dtinsight/react-icons'; import { InternalNamePath } from 'antd/lib/form/interface'; import classnames from 'classnames'; -import { useLocale } from 'dt-react-component'; +import useLocale from '../../locale/useLocale'; import { IComponentProps, IFilterValue, ROW_PERMISSION_RELATION } from '..'; import './index.scss';