优化获取昵称修改状态的时机

This commit is contained in:
2025-12-03 15:44:41 +08:00
parent 7c1a1fafc1
commit b77b4b0536
9 changed files with 160 additions and 128 deletions

View File

@@ -4,7 +4,7 @@
position: fixed;
z-index: 9999 !important;
&:global(.nut-popup-bottom.nut-popup-round) {
border-radius: 20px 20px 0 0!important;
border-radius: 20px 20px 0 0 !important;
}
.common-popup__drag-handle-container {
position: position;
@@ -22,8 +22,8 @@
display: flex;
justify-content: center;
align-items: flex-start;
&::before{
content: '';
&::before {
content: "";
width: 32px;
height: 4px;
background-color: rgba(22, 24, 35, 0.2);
@@ -105,7 +105,7 @@
padding: 8px 10px 0 10px;
display: flex;
gap: 8px;
background: #fff;
background: #fafafa;
padding-bottom: max(10px, env(safe-area-inset-bottom));
}

View File

@@ -11,7 +11,7 @@ interface EditModalProps {
placeholder: string;
initialValue: string;
maxLength: number;
invalidCharacters: string;
invalidCharacters: RegExp | null;
onSave: (value: string) => void;
onCancel: () => void;
validationMessage?: string;
@@ -24,7 +24,7 @@ const EditModal: React.FC<EditModalProps> = ({
placeholder,
initialValue,
maxLength,
invalidCharacters = "",
invalidCharacters = null,
onSave,
onCancel,
validationMessage,
@@ -63,18 +63,13 @@ const EditModal: React.FC<EditModalProps> = ({
}
}, [visible, initialValue]);
const createExcludeRegex = (chars: string) => {
const escapedChars = chars.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
const pattern = `[${escapedChars}]`;
return new RegExp(pattern);
};
const handle_input_change = (e: any) => {
const new_value = e.detail.value;
setValue(new_value);
let ishasIllegal = false;
if (type === "nickname") {
ishasIllegal = createExcludeRegex(invalidCharacters).test(new_value);
setHasIllegal(ishasIllegal);
if (type === "nickname" && invalidCharacters) {
ishasIllegal = invalidCharacters.test(new_value);
setHasIllegal(!ishasIllegal);
}
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(

View File

@@ -610,7 +610,11 @@ const UserInfoCardComponent: React.FC<UserInfoCardProps> = ({
}
initialValue={form_data[editing_field as keyof typeof form_data] || ""}
maxLength={editing_field === "nickname" ? 20 : 100}
invalidCharacters={editing_field === "nickname" ? "@<>/" : ""}
invalidCharacters={
editing_field === "nickname"
? /^[\u4e00-\u9fa5a-zA-Z0-9_\-\.\(\)\s]*$/
: null
}
onSave={handle_edit_modal_save}
onCancel={handle_edit_modal_cancel}
validationMessage={