fix: 前端兼容 phone 字段可能为非字符串的情况
- 在所有显示 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 <noreply@anthropic.com>
This commit is contained in:
@@ -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(({
|
||||
/>
|
||||
<Box>
|
||||
<Text fontSize="sm" fontWeight="bold">{getDisplayName()}</Text>
|
||||
{user.phone && (
|
||||
{typeof user.phone === 'string' && user.phone && (
|
||||
<Text fontSize="xs" color={emailTextColor}>{user.phone}</Text>
|
||||
)}
|
||||
</Box>
|
||||
|
||||
@@ -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 }) => {
|
||||
{/* 用户信息区 */}
|
||||
<Box px={3} py={2} borderBottom="1px" borderColor="gray.200">
|
||||
<Text fontSize="sm" fontWeight="bold">{getDisplayName()}</Text>
|
||||
{user.phone && (
|
||||
{typeof user.phone === 'string' && user.phone && (
|
||||
<Text fontSize="xs" color="gray.500">{user.phone}</Text>
|
||||
)}
|
||||
{user.has_wechat && (
|
||||
|
||||
@@ -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(({
|
||||
{/* 用户信息区 */}
|
||||
<Box px={3} py={2} borderBottom="1px" borderColor={borderColor}>
|
||||
<Text fontSize="sm" fontWeight="bold">{getDisplayName()}</Text>
|
||||
{user.phone && (
|
||||
{typeof user.phone === 'string' && user.phone && (
|
||||
<Text fontSize="xs" color="gray.500">{user.phone}</Text>
|
||||
)}
|
||||
{user.has_wechat && (
|
||||
|
||||
@@ -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 '用户';
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user