21301050 | 01e07a1 | 2025-06-09 18:00:40 +0800 | [diff] [blame] | 1 | import React from 'react'; |
| 2 | import { Avatar } from 'antd'; |
| 3 | import frameImage from './avatar-frame.png'; // 头像框图片素材 |
| 4 | import './AvatarWithFrame.css'; |
| 5 | |
| 6 | const AvatarWithFrame = () => { |
| 7 | // 从localStorage获取用户数据 |
| 8 | const userData = JSON.parse(localStorage.getItem('user')) || {}; |
| 9 | const { image, decoration = '' } = userData; |
| 10 | |
| 11 | // 检查是否包含头像框 |
| 12 | const hasFrame = decoration.includes('头像框'); |
| 13 | |
| 14 | return ( |
| 15 | <div className="avatar-container"> |
| 16 | {/* 头像 */} |
| 17 | <Avatar |
| 18 | src={image} |
| 19 | size={80} |
| 20 | className={`user-avatar ${hasFrame ? 'with-frame' : ''}`} |
| 21 | /> |
| 22 | |
| 23 | {/* 头像框图片 - 根据decoration显示 */} |
| 24 | {hasFrame && ( |
| 25 | <img |
| 26 | src={frameImage} |
| 27 | alt="头像框" |
| 28 | className="avatar-frame-image" |
| 29 | /> |
| 30 | )} |
| 31 | </div> |
| 32 | ); |
| 33 | }; |
| 34 | |
| 35 | export default AvatarWithFrame; |