diff --git a/CHANGELOG.md b/CHANGELOG.md index d8577fe990444fea28014877f1d6aa381782d086..447da374630a0e7d4821dda7e13cd7ece1986a7b 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 19fa7c8f0e0eb020788f501677cea8c0110c04fb..a67f20a0df72cfec27786fd7d1be75184e177350 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); } };