From 2d2b40ebc19e16ac901ec118fa36c4717f954d1d Mon Sep 17 00:00:00 2001 From: ShineKOT <1917095344@qq.com> Date: Tue, 24 Dec 2024 16:21:48 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=20=E5=AF=86=E7=A0=81=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=99=A8=E6=96=B0=E5=A2=9EenableEncryption=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=99=A8=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + src/editor/text-box/input/input.tsx | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d8577fe99..447da3746 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ ### Added - 自定义主题组件新增蓝色主题切换 +- 密码编辑器新增enableEncryption编辑器参数,用以启用密码加密功能 ### Fixed diff --git a/src/editor/text-box/input/input.tsx b/src/editor/text-box/input/input.tsx index 19fa7c8f0..a67f20a0d 100644 --- a/src/editor/text-box/input/input.tsx +++ b/src/editor/text-box/input/input.tsx @@ -69,6 +69,16 @@ export const IBizInput = defineComponent({ } }); + // 当前密文 + let ciphertext = ''; + + // 启用加密 + const enableEncryption = computed(() => { + return ( + type.value === 'password' && c.editorParams.enableEncryption === 'true' + ); + }); + // 是否显示表单默认内容 const showFormDefaultContent = computed(() => { if ( @@ -86,7 +96,11 @@ export const IBizInput = defineComponent({ watch( () => props.value, (newVal, oldVal) => { - if (newVal !== oldVal) { + // 非加密对比新旧值,加密对比新值和当前加密值 + if ( + (!enableEncryption.value && newVal !== oldVal) || + (enableEncryption.value && newVal !== ciphertext) + ) { if (newVal == null) { currentVal.value = ''; } else if (isEmoji(`${newVal}`)) { @@ -119,11 +133,15 @@ export const IBizInput = defineComponent({ return text; }); - const onEmit = ( + const onEmit = async ( val: string | number | undefined, eventName: string = 'blur', ) => { if (eventName === c.triggerMode) { + if (enableEncryption.value) { + ciphertext = await ibiz.util.encryption.encryptByRSA(val as string); + val = ciphertext; + } emit('change', val); } }; -- Gitee