用户名称添加@<>/等字符的检查

This commit is contained in:
2025-11-26 16:58:32 +08:00
parent 6751ec3c00
commit c471b90ecf
3 changed files with 318 additions and 273 deletions

View File

@@ -76,7 +76,6 @@ const UserInfoCardComponent: React.FC<UserInfoCardProps> = ({
set_user_info,
onTab,
}) => {
const { setShowGuideBar } = useGlobalState();
const { updateUserInfo } = useUserActions();
@@ -383,7 +382,14 @@ const UserInfoCardComponent: React.FC<UserInfoCardProps> = ({
{/* 统计数据 */}
<View className="stats_section">
<View className="stats_container" style={{ marginBottom: `${collapseProfile && setMarginBottom ? "16px" : "unset"}` }}>
<View
className="stats_container"
style={{
marginBottom: `${
collapseProfile && setMarginBottom ? "16px" : "unset"
}`,
}}
>
<View
className="stat_item clickable"
onClick={() => handle_stats_click("following")}
@@ -461,121 +467,118 @@ const UserInfoCardComponent: React.FC<UserInfoCardProps> = ({
</View>
{/* 标签和简介 */}
{
!collapseProfile ?
<View className="tags_bio_section">
<View className="tags_container">
{user_info.gender && user_info.gender !== "2" ? (
<View className="tag_item">
{user_info.gender === "0" && (
<Image
className="tag_icon"
src={require("../../static/userInfo/male.svg")}
onClick={() => {
editable && handle_open_edit_modal("gender");
}}
/>
)}
{user_info.gender === "1" && (
<Image
className="tag_icon"
src={require("../../static/userInfo/female.svg")}
onClick={() => {
editable && handle_open_edit_modal("gender");
}}
/>
)}
</View>
) : is_current_user && user_info.gender !== "2" ? (
<View
className="button_edit"
onClick={() => {
handle_open_edit_modal("gender");
}}
>
<Text></Text>
</View>
) : null}
{user_info.ntrp_level !== "" ? (
<View
className="tag_item"
onClick={() => {
editable && handle_open_edit_modal("ntrp_level");
}}
>
<Text className="tag_text">{`NTRP ${formatNtrpDisplay(
user_info.ntrp_level
)}`}</Text>
</View>
{!collapseProfile ? (
<View className="tags_bio_section">
<View className="tags_container">
{user_info.gender && user_info.gender !== "2" ? (
<View className="tag_item">
{user_info.gender === "0" && (
<Image
className="tag_icon"
src={require("../../static/userInfo/male.svg")}
onClick={() => {
editable && handle_open_edit_modal("gender");
}}
/>
)}
{user_info.gender === "1" && (
<Image
className="tag_icon"
src={require("../../static/userInfo/female.svg")}
onClick={() => {
editable && handle_open_edit_modal("gender");
}}
/>
)}
</View>
) : is_current_user && user_info.gender !== "2" ? (
<View
className="button_edit"
onClick={() => {
handle_open_edit_modal("gender");
}}
>
<Text></Text>
</View>
) : null}
{user_info.ntrp_level !== "" ? (
<View
className="tag_item"
onClick={() => {
editable && handle_open_edit_modal("ntrp_level");
}}
>
<Text className="tag_text">{`NTRP ${formatNtrpDisplay(
user_info.ntrp_level
)}`}</Text>
</View>
) : is_current_user ? (
<View
className="button_edit"
onClick={() => {
handle_open_edit_modal("ntrp_level");
}}
>
<Text>NTRP水平</Text>
</View>
) : null}
{user_info.occupation ? (
<View
className="tag_item"
onClick={() => {
editable && handle_open_edit_modal("occupation");
}}
>
<Text className="tag_text">
{user_info.occupation.split(" ")[2]}
</Text>
</View>
) : is_current_user ? (
<View
className="button_edit"
onClick={() => {
handle_open_edit_modal("occupation");
}}
>
<Text></Text>
</View>
) : null}
{user_info.country || user_info.province || user_info.city ? (
<View
className="tag_item"
onClick={() => editable && handle_open_edit_modal("location")}
>
<Text className="tag_text">{`${user_info.province}${user_info.city}`}</Text>
</View>
) : is_current_user ? (
<View
className="button_edit"
onClick={() => handle_open_edit_modal("location")}
>
<Text></Text>
</View>
) : null}
</View>
<View
className="personal_profile"
onClick={() => handle_open_edit_modal("personal_profile")}
>
{!collapseProfile ? (
user_info.personal_profile ? (
<Text className="bio_text">{user_info.personal_profile}</Text>
) : is_current_user ? (
<View
className="button_edit"
onClick={() => {
handle_open_edit_modal("ntrp_level");
}}
>
<Text>NTRP水平</Text>
<View className="personal_profile_edit">
<Image
className="edit_icon"
src={require("../../static/userInfo/info_edit.svg")}
/>
<Text className="bio_text"></Text>
</View>
) : null}
{user_info.occupation ? (
<View
className="tag_item"
onClick={() => {
editable && handle_open_edit_modal("occupation");
}}
>
<Text className="tag_text">
{user_info.occupation.split(" ")[2]}
</Text>
</View>
) : is_current_user ? (
<View
className="button_edit"
onClick={() => {
handle_open_edit_modal("occupation");
}}
>
<Text></Text>
</View>
) : null}
{user_info.country || user_info.province || user_info.city ? (
<View
className="tag_item"
onClick={() => editable && handle_open_edit_modal("location")}
>
<Text className="tag_text">{`${user_info.province}${user_info.city}`}</Text>
</View>
) : is_current_user ? (
<View
className="button_edit"
onClick={() => handle_open_edit_modal("location")}
>
<Text></Text>
</View>
) : null}
</View>
<View
className="personal_profile"
onClick={() => handle_open_edit_modal("personal_profile")}
>
{!collapseProfile ?
user_info.personal_profile ? (
<Text className="bio_text">{user_info.personal_profile}</Text>
) : is_current_user ? (
<View className="personal_profile_edit">
<Image
className="edit_icon"
src={require("../../static/userInfo/info_edit.svg")}
/>
<Text className="bio_text"></Text>
</View>
) :
null :
null}
</View>
</View> :
null
}
) : null
) : null}
</View>
</View>
) : null}
{/* 编辑个人简介弹窗 */}
<EditModal
@@ -589,11 +592,12 @@ 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" ? "@<>/" : ""}
onSave={handle_edit_modal_save}
onCancel={handle_edit_modal_cancel}
validationMessage={
editing_field === "nickname"
? "请填写 1-20 个字符"
? "请填写 2-24 个字符,不包括 @<>/等无效字符"
: "请填写 2-100 个字符"
}
/>
@@ -663,7 +667,9 @@ const UserInfoCardComponent: React.FC<UserInfoCardProps> = ({
visible={ntrp_picker_visible}
setvisible={setNtrpPickerVisible}
value={
!form_data.ntrp_level || form_data.ntrp_level === "0" ? ["3.0"] : [form_data.ntrp_level]
!form_data.ntrp_level || form_data.ntrp_level === "0"
? ["3.0"]
: [form_data.ntrp_level]
}
onChange={handle_ntrp_level_change}
/>
@@ -842,8 +848,9 @@ export const GameTabs: React.FC<GameTabsProps> = ({
<Text className="tab_text">{hosted_text}</Text>
</View>
<View
className={`tab_item ${active_tab === "participated" ? "active" : ""
}`}
className={`tab_item ${
active_tab === "participated" ? "active" : ""
}`}
onClick={() => on_tab_change("participated")}
>
<Text className="tab_text">{participated_text}</Text>