From a1e9b18a4dbfd21e1bf4d5cb60974ac2f0115efd Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 30 五月 2025 15:18:44 +0800 Subject: [PATCH] 2025-05-30 --- src/tabviews/zshare/mutilform/mkInput/index.jsx | 86 ++++++++++++++++++++++++++++++++++++------ 1 files changed, 73 insertions(+), 13 deletions(-) diff --git a/src/tabviews/zshare/mutilform/mkInput/index.jsx b/src/tabviews/zshare/mutilform/mkInput/index.jsx index a9281ab..0083264 100644 --- a/src/tabviews/zshare/mutilform/mkInput/index.jsx +++ b/src/tabviews/zshare/mutilform/mkInput/index.jsx @@ -1,6 +1,7 @@ import React, { Component } from 'react' import { is, fromJS } from 'immutable' import { Input } from 'antd' +import md5 from 'md5' import MKEmitter from '@/utils/events.js' @@ -14,9 +15,25 @@ super(props) const config = props.config + let _value = config.initval + let encryption = 'false' + + if (config.encryption === 'true') { + encryption = 'true' + if (_value) { + try { + _value = window.decodeURIComponent(window.atob(_value)) + } catch (e) { + _value = config.initval + } + } + } else if (config.encryption === 'md5') { + encryption = 'md5' + } this.state = { - value: config.initval + value: _value, + encryption } } @@ -43,23 +60,61 @@ this.inputRef.current.select() } else if (type === 'input') { this.setState({value}) + let _val = value + + if (this.state.encryption === 'true') { + try { + _val = window.btoa(window.encodeURIComponent(_val)) + } catch (e) { + _val = value + } + this.props.onChange(_val) + } else if (this.state.encryption === 'md5') { + _val = _val + '' + _val = md5(_val.toLowerCase()) + _val = _val.toUpperCase() + + this.props.onChange(_val) + } else { + this.props.onChange(_val, true) + } } } handleChange = (e) => { let val = e.target.value + let submit = /\n/g.test(val) - if (!/\n/ig.test(val)) { - this.props.onChange(val) - this.setState({value: val}) - } else { - val = val.replace(/\n/ig, '') - - this.props.onChange(val) - this.setState({value: val}, () => { - this.handleInputSubmit() - }) + if (submit) { + val = val.replace(/\n|'/g, '') } + + if (submit && /^\s+$/.test(val)) { + submit = false + } + + let _val = val + + if (this.state.encryption === 'true') { + try { + _val = window.btoa(window.encodeURIComponent(_val)) + } catch (e) { + _val = val + } + } else if (this.state.encryption === 'md5') { + _val = md5(_val.toLowerCase()) + _val = _val.toUpperCase() + } + + this.props.onChange(_val) + + this.setState({value: val}, () => { + if (submit) { + this.handleInputSubmit() + } else if (!val) { + this.inputRef.current.focus() + } + }) } handleInputSubmit = () => { @@ -69,7 +124,8 @@ if (config.enter === 'tab') { MKEmitter.emit('mkFC', 'focus', config.tabUuid) } else { - this.props.onSubmit() + MKEmitter.emit('mkFC', 'focus', config.tabUuid) + this.props.onSubmit(config.tabUuid, config.errTabUuid) } } @@ -77,7 +133,11 @@ const { config } = this.props const { value } = this.state - return <Input ref={this.inputRef} placeholder={config.placeholder || ''} value={value} autoComplete="off" disabled={config.readonly} onChange={this.handleChange} onPressEnter={this.handleInputSubmit} /> + if (config.inputType === 'password') { + return <Input.Password ref={this.inputRef} className="mk-form-input" placeholder={config.placeholder || ''} value={value} autoComplete="off" disabled={config.readonly} onChange={this.handleChange} onPressEnter={this.handleInputSubmit}/> + } + + return <Input ref={this.inputRef} className="mk-form-input" allowClear placeholder={config.placeholder || ''} value={value} autoComplete="off" disabled={config.readonly} onChange={this.handleChange} onPressEnter={this.handleInputSubmit} /> } } -- Gitblit v1.8.0