diff --git a/CHANGELOG.md b/CHANGELOG.md index ceedd2e6127659dce99f01f5934c613e2cf6d25e..c9e3bcc0196dd3b6d52b6c93094f2d2f12696f6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ ## [Unreleased] +### Added + +- 更新密码框支持明文,暗文切换功能 + + ## [0.7.41-alpha.9] - 2025-08-25 ### Fixed diff --git a/src/editor/text-box/input/input.scss b/src/editor/text-box/input/input.scss index 63d0f13bcb843a97b921cfbad86398a023888000..0558d4be556d059c8b88c432ab201faa1ed6a52c 100644 --- a/src/editor/text-box/input/input.scss +++ b/src/editor/text-box/input/input.scss @@ -40,4 +40,7 @@ .van-field__clear{ display: getCssVar(form-item-container,required-style); } + .van-field__right-icon{ + font-size: getCssVar('form-size', 'header-4'); + } } diff --git a/src/editor/text-box/input/input.tsx b/src/editor/text-box/input/input.tsx index d39ef4fc75e874b25d64e3cbbf35b2f5eedebb04..daac64315f47c8ff7289fecb92e43d4819785ce0 100644 --- a/src/editor/text-box/input/input.tsx +++ b/src/editor/text-box/input/input.tsx @@ -27,12 +27,22 @@ export const IBizInput = defineComponent({ const editorModel = c.model; const inputRef = ref(); + // 是否显示密码 + const showPassword = ref(false); + + // 是否显示切换明文、暗文密码图标 + let showSwitchIcon = false; + // 文本域默认行数,仅在 textarea 类型下有效 const rows = ref(2); if (editorModel.editorType === 'TEXTAREA_10') { rows.value = 10; } + if (c.editorParams.showswitchicon) { + showSwitchIcon = c.editorParams.showswitchicon === 'true'; + } + // 类型 const type = computed(() => { switch (editorModel.editorType) { @@ -134,6 +144,11 @@ export const IBizInput = defineComponent({ emit('change', ''); }; + // 切换明文密码的显示隐藏 + const switchPwd = () => { + showPassword.value = !showPassword.value && showSwitchIcon; + }; + return { c, ns, @@ -146,6 +161,8 @@ export const IBizInput = defineComponent({ onFocus, onClear, inputRef, + showPassword, + switchPwd, }; }, render() { @@ -167,13 +184,27 @@ export const IBizInput = defineComponent({ return {unitName}; }; } + if (this.type === 'password') { + slots['right-icon'] = () => { + return this.showPassword ? ( + + ) : ( + + ); + }; + } content = (