From e493ae5ad10291dd2a2ea4e707bd2a73fbfa2f22 Mon Sep 17 00:00:00 2001 From: zdl <3489966805@qq.com> Date: Mon, 15 Dec 2025 13:50:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=89=8D=E7=AB=AF=E5=85=BC=E5=AE=B9=20p?= =?UTF-8?q?hone=20=E5=AD=97=E6=AE=B5=E5=8F=AF=E8=83=BD=E4=B8=BA=E9=9D=9E?= =?UTF-8?q?=E5=AD=97=E7=AC=A6=E4=B8=B2=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在所有显示 user.phone 的地方添加类型检查 - 使用 typeof user.phone === 'string' && user.phone 确保只有字符串才显示 - 修复微信登录后 phone 为对象时显示 [object Object] 的问题 涉及文件: - TabletUserMenu.js - MobileDrawer.js - UserAvatar.js - PersonalCenterMenu.js 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../Navbars/components/MobileDrawer/MobileDrawer.js | 4 ++-- .../Navbars/components/Navigation/PersonalCenterMenu.js | 4 ++-- src/components/Navbars/components/UserMenu/TabletUserMenu.js | 4 ++-- src/components/Navbars/components/UserMenu/UserAvatar.js | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/components/Navbars/components/MobileDrawer/MobileDrawer.js b/src/components/Navbars/components/MobileDrawer/MobileDrawer.js index bc1218ed..d9f7a3e8 100644 --- a/src/components/Navbars/components/MobileDrawer/MobileDrawer.js +++ b/src/components/Navbars/components/MobileDrawer/MobileDrawer.js @@ -54,7 +54,7 @@ const MobileDrawer = memo(({ if (user.nickname) return user.nickname; if (user.username) return user.username; if (user.email) return user.email.split('@')[0]; - if (user.phone) return user.phone; + if (typeof user.phone === 'string' && user.phone) return user.phone; return '用户'; }; @@ -92,7 +92,7 @@ const MobileDrawer = memo(({ /> {getDisplayName()} - {user.phone && ( + {typeof user.phone === 'string' && user.phone && ( {user.phone} )} diff --git a/src/components/Navbars/components/Navigation/PersonalCenterMenu.js b/src/components/Navbars/components/Navigation/PersonalCenterMenu.js index 510f8281..167e4425 100644 --- a/src/components/Navbars/components/Navigation/PersonalCenterMenu.js +++ b/src/components/Navbars/components/Navigation/PersonalCenterMenu.js @@ -40,7 +40,7 @@ const PersonalCenterMenu = memo(({ user, handleLogout }) => { if (user.nickname) return user.nickname; if (user.username) return user.username; if (user.email) return user.email.split('@')[0]; - if (user.phone) return user.phone; + if (typeof user.phone === 'string' && user.phone) return user.phone; return '用户'; }; @@ -61,7 +61,7 @@ const PersonalCenterMenu = memo(({ user, handleLogout }) => { {/* 用户信息区 */} {getDisplayName()} - {user.phone && ( + {typeof user.phone === 'string' && user.phone && ( {user.phone} )} {user.has_wechat && ( diff --git a/src/components/Navbars/components/UserMenu/TabletUserMenu.js b/src/components/Navbars/components/UserMenu/TabletUserMenu.js index dc813313..ddb19987 100644 --- a/src/components/Navbars/components/UserMenu/TabletUserMenu.js +++ b/src/components/Navbars/components/UserMenu/TabletUserMenu.js @@ -46,7 +46,7 @@ const TabletUserMenu = memo(({ if (user.nickname) return user.nickname; if (user.username) return user.username; if (user.email) return user.email.split('@')[0]; - if (user.phone) return user.phone; + if (typeof user.phone === 'string' && user.phone) return user.phone; return '用户'; }; @@ -75,7 +75,7 @@ const TabletUserMenu = memo(({ {/* 用户信息区 */} {getDisplayName()} - {user.phone && ( + {typeof user.phone === 'string' && user.phone && ( {user.phone} )} {user.has_wechat && ( diff --git a/src/components/Navbars/components/UserMenu/UserAvatar.js b/src/components/Navbars/components/UserMenu/UserAvatar.js index 0ac08e3d..d1212203 100644 --- a/src/components/Navbars/components/UserMenu/UserAvatar.js +++ b/src/components/Navbars/components/UserMenu/UserAvatar.js @@ -29,7 +29,7 @@ const UserAvatar = forwardRef(({ if (user.nickname) return user.nickname; if (user.username) return user.username; if (user.email) return user.email.split('@')[0]; - if (user.phone) return user.phone; + if (typeof user.phone === 'string' && user.phone) return user.phone; return '用户'; };