From 31194f67bee8d5e2fe68d8bafc0c8c72919c391d Mon Sep 17 00:00:00 2001 From: Ultrame <1019265060@qq.com> Date: Mon, 24 Nov 2025 22:42:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8B=E6=8B=89=E9=9A=90=E8=97=8F=E7=AE=80?= =?UTF-8?q?=E4=BB=8B=E7=AD=89=E4=BF=A1=E6=81=AF=EF=BC=8C=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E8=B6=85=E5=87=BA=E6=96=87=E6=9C=AC=E9=95=BF=E5=BA=A6=E4=BA=A4?= =?UTF-8?q?=E4=BA=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/EditModal/EditModal.scss | 6 + src/components/EditModal/index.tsx | 66 ++++-- src/components/UserInfo/index.scss | 3 +- src/components/UserInfo/index.tsx | 224 ++++++++++-------- .../components/MyselfPageContent.tsx | 63 +++-- src/user_pages/other/index.scss | 3 +- src/user_pages/other/index.tsx | 13 +- 7 files changed, 222 insertions(+), 156 deletions(-) diff --git a/src/components/EditModal/EditModal.scss b/src/components/EditModal/EditModal.scss index 3c42797..978fcb3 100644 --- a/src/components/EditModal/EditModal.scss +++ b/src/components/EditModal/EditModal.scss @@ -140,6 +140,9 @@ font-size: 14px; line-height: 1.71em; color: rgba(60, 60, 67, 0.3); + &.un-valid { + color: #FF3B30; + } } } } @@ -153,6 +156,9 @@ font-size: 12px; line-height: 1.5em; color: rgba(60, 60, 67, 0.6); + &.illegal { + color: #FF3B30; + } } } } diff --git a/src/components/EditModal/index.tsx b/src/components/EditModal/index.tsx index eefd0c4..99086d0 100644 --- a/src/components/EditModal/index.tsx +++ b/src/components/EditModal/index.tsx @@ -29,6 +29,7 @@ const EditModal: React.FC = ({ }) => { const [value, setValue] = useState(initialValue); const [isValid, setIsValid] = useState(true); + const [isIllegal, setIsIllegal] = useState(false); // 使用全局键盘状态 const { keyboardHeight, isKeyboardVisible, addListener, initializeKeyboardListener } = useKeyboardHeight() @@ -58,6 +59,8 @@ const EditModal: React.FC = ({ const new_value = e.detail.value; setValue(new_value); + const illegal = /\b(SELECT|INSERT|UPDATE|DELETE|DROP|UNION|ALTER|CREATE|EXEC|DECLARE)\b|('|--|\/\*|\*\/|;|#)|(=|'|"|`|\\|\|\|&&)|\bOR\s+['"]?[\w]+['"]?\s*=\s*['"]?[\w]+['"]?|\bUNION\s+SELECT\b|\bDROP\s+TABLE\b|\bINSERT\s+INTO\b|\bUPDATE\s+[\w]+\s+SET\b|\bDELETE\s+FROM\b/i.test(new_value) + setIsIllegal(illegal) // 验证输入 const valid = new_value.length >= 2 && new_value.length <= maxLength; setIsValid(valid); @@ -72,6 +75,14 @@ const EditModal: React.FC = ({ }); return; } + if (isIllegal) { + Taro.showToast({ + title: "输入的字符非法", + icon: 'none', + duration: 2000 + }); + return; + } onSave(value); }; @@ -104,48 +115,61 @@ const EditModal: React.FC = ({ {type === 'nickname' ? ( - + <> + + + maxLength && "un-valid"}`}>{value.length}/{maxLength} + + ) : ( <>