San3yuan | 4d0e803 | 2025-04-04 17:21:40 +0800 | [diff] [blame] | 1 | import React from "react"; |
| 2 | import { useAppSelector } from "../../hooks/store"; |
San3yuan | 2534d42 | 2025-04-08 21:43:18 +0800 | [diff] [blame] | 3 | import style from "./style.module.css" |
San3yuan | 4d0e803 | 2025-04-04 17:21:40 +0800 | [diff] [blame] | 4 | |
San3yuan | 6f2ed69 | 2025-04-16 20:24:49 +0800 | [diff] [blame^] | 5 | interface SelfStatusProps { |
| 6 | className?: string; |
| 7 | } |
San3yuan | 4d0e803 | 2025-04-04 17:21:40 +0800 | [diff] [blame] | 8 | |
San3yuan | 6f2ed69 | 2025-04-16 20:24:49 +0800 | [diff] [blame^] | 9 | const SelfStatus: React.FC<SelfStatusProps> = () => { |
San3yuan | 2534d42 | 2025-04-08 21:43:18 +0800 | [diff] [blame] | 10 | const userName = useAppSelector(state => state.user.userName); |
| 11 | const role = useAppSelector(state => state.user.role); |
| 12 | const uploadTraffic = useAppSelector(state => state.user.uploadTraffic); |
| 13 | const downloadTraffic = useAppSelector(state => state.user.downloadTraffic); |
| 14 | const downloadPoints = useAppSelector(state => state.user.downloadPoints); |
| 15 | const avatar = useAppSelector(state => state.user.avatar); |
| 16 | console.log(avatar) |
| 17 | |
| 18 | return ( |
| 19 | <div className={style.container}> |
| 20 | <div className={style.left}> |
| 21 | <img className={style.avatar} src={avatar} alt="User Avatar" /> |
San3yuan | 4d0e803 | 2025-04-04 17:21:40 +0800 | [diff] [blame] | 22 | </div> |
San3yuan | 2534d42 | 2025-04-08 21:43:18 +0800 | [diff] [blame] | 23 | <div className={style.right}> |
| 24 | <div className={style.info}> |
| 25 | <p className={style.userName}>{userName}</p> |
| 26 | <p className={style.role}>角色: {role}</p> |
| 27 | <p className={style.uploadTraffic}>上传量: {uploadTraffic}</p> |
| 28 | <p className={style.downloadTraffic}>下载量: {downloadTraffic}</p> |
San3yuan | 6f2ed69 | 2025-04-16 20:24:49 +0800 | [diff] [blame^] | 29 | |
San3yuan | 2534d42 | 2025-04-08 21:43:18 +0800 | [diff] [blame] | 30 | <p className={style.shareRatio}> |
| 31 | 分享率: {uploadTraffic && downloadTraffic ? (uploadTraffic / downloadTraffic).toFixed(2) : "N/A"} |
| 32 | </p> |
San3yuan | 6f2ed69 | 2025-04-16 20:24:49 +0800 | [diff] [blame^] | 33 | <p className={style.downloadPoints}>下载积分: {downloadPoints}</p> |
San3yuan | 2534d42 | 2025-04-08 21:43:18 +0800 | [diff] [blame] | 34 | </div> |
| 35 | <button className={style.signInButton}>签到</button> |
San3yuan | 4d0e803 | 2025-04-04 17:21:40 +0800 | [diff] [blame] | 36 | </div> |
San3yuan | 2534d42 | 2025-04-08 21:43:18 +0800 | [diff] [blame] | 37 | </div> |
| 38 | ); |
| 39 | }; |
San3yuan | 4d0e803 | 2025-04-04 17:21:40 +0800 | [diff] [blame] | 40 | |
San3yuan | 2534d42 | 2025-04-08 21:43:18 +0800 | [diff] [blame] | 41 | export default SelfStatus; |