ssq | 5067cb9 | 2025-06-05 11:44:23 +0000 | [diff] [blame] | 1 | import React, { useState } from "react";
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 2 | import AccountCircleIcon from "@mui/icons-material/AccountCircle";
|
| 3 | import { useNavigate } from "react-router-dom";
|
| 4 | import "./App.css";
|
| 5 |
|
| 6 | export default function UserProfile() {
|
| 7 | const navigate = useNavigate();
|
| 8 | const [userInfo, setUserInfo] = useState({
|
| 9 | username: "示例用户",
|
| 10 | email: "user@example.com",
|
ssq | 5067cb9 | 2025-06-05 11:44:23 +0000 | [diff] [blame] | 11 | company: "",
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 12 | school: "",
|
ssq | 5067cb9 | 2025-06-05 11:44:23 +0000 | [diff] [blame] | 13 | birthday: "",
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 14 | });
|
| 15 | const [tempUserInfo, setTempUserInfo] = useState({ ...userInfo });
|
| 16 |
|
| 17 | const handleInputChange = (field, value) => {
|
| 18 | setTempUserInfo({ ...tempUserInfo, [field]: value });
|
| 19 | };
|
| 20 |
|
ssq | 5067cb9 | 2025-06-05 11:44:23 +0000 | [diff] [blame] | 21 | const handleSave = () => {
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 22 | setUserInfo({ ...tempUserInfo });
|
ssq | 5067cb9 | 2025-06-05 11:44:23 +0000 | [diff] [blame] | 23 | alert("信息已保存!");
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 24 | };
|
| 25 |
|
| 26 | const handleAvatarClick = () => {
|
| 27 | const avatarUrl = prompt("请输入头像的URL:");
|
| 28 | if (avatarUrl) {
|
| 29 | setTempUserInfo({ ...tempUserInfo, avatar: avatarUrl });
|
| 30 | }
|
| 31 | };
|
| 32 |
|
| 33 | return (
|
| 34 | <div className="container" style={{ minHeight: '100vh', background: 'linear-gradient(135deg, #f0f4ff 0%, #e0e7ff 100%)', display: 'grid', gridTemplateColumns: '1fr 2fr', gridTemplateRows: 'auto 1fr', gap: '20px', padding: '40px' }}>
|
| 35 | {/* 左侧:用户资料 */}
|
| 36 | <div style={{ gridColumn: '1 / 2', gridRow: '1 / 3', display: 'flex', flexDirection: 'column', alignItems: 'center', background: '#fff', borderRadius: 18, boxShadow: '0 4px 24px #e0e7ff', padding: '20px' }}>
|
| 37 | <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', marginBottom: 16 }}>
|
| 38 | <div onClick={handleAvatarClick} style={{ cursor: 'pointer', position: 'relative' }}>
|
| 39 | <AccountCircleIcon style={{ fontSize: 90, color: '#1a237e', marginBottom: 12 }} />
|
| 40 | {tempUserInfo.avatar && (
|
| 41 | <img
|
ssq | 5067cb9 | 2025-06-05 11:44:23 +0000 | [diff] [blame] | 42 | src={tempUserInfo.avatar}
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 43 | alt="用户头像"
|
| 44 | style={{
|
| 45 | position: 'absolute',
|
| 46 | top: 0,
|
| 47 | left: 0,
|
| 48 | width: 90,
|
| 49 | height: 90,
|
| 50 | borderRadius: '50%',
|
| 51 | objectFit: 'cover',
|
| 52 | }}
|
| 53 | />
|
| 54 | )}
|
| 55 | </div>
|
| 56 | <h2 style={{ color: '#1a237e', marginBottom: 0, fontSize: 24 }}>用户个人资料</h2>
|
| 57 | </div>
|
| 58 | <div className="card" style={{ padding: 28, width: '100%', background: '#fff', borderRadius: 18, boxShadow: '0 4px 24px #e0e7ff', flex: 1 }}>
|
| 59 | <div style={{ marginBottom: 18, display: 'flex', alignItems: 'center' }}>
|
| 60 | <b style={{ width: 72, textAlign: 'left', marginRight: 0, fontSize: 16 }}>用户名:</b>
|
| 61 | <input
|
| 62 | type="text"
|
| 63 | value={tempUserInfo.username}
|
| 64 | onChange={(e) => handleInputChange("username", e.target.value)}
|
| 65 | style={{ flex: 1, padding: '6px 10px', borderRadius: 7, border: '1px solid #b2b2b2', minWidth: 0, fontSize: 15 }}
|
| 66 | />
|
| 67 | </div>
|
| 68 | <div style={{ marginBottom: 18, display: 'flex', alignItems: 'center' }}>
|
| 69 | <b style={{ width: 72, textAlign: 'left', marginRight: 0, fontSize: 16 }}>邮箱:</b>
|
ssq | 5067cb9 | 2025-06-05 11:44:23 +0000 | [diff] [blame] | 70 | <input
|
| 71 | type="email"
|
| 72 | value={tempUserInfo.email}
|
| 73 | onChange={(e) => handleInputChange("email", e.target.value)}
|
| 74 | style={{ flex: 1, padding: '6px 10px', borderRadius: 7, border: '1px solid #b2b2b2', minWidth: 0, fontSize: 15 }}
|
| 75 | />
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 76 | </div>
|
| 77 | <div style={{ marginBottom: 18, display: 'flex', alignItems: 'center' }}>
|
ssq | 5067cb9 | 2025-06-05 11:44:23 +0000 | [diff] [blame] | 78 | <b style={{ width: 72, textAlign: 'left', marginRight: 0, fontSize: 16 }}>公司:</b>
|
| 79 | <input
|
| 80 | type="text"
|
| 81 | value={tempUserInfo.company}
|
| 82 | onChange={(e) => handleInputChange("company", e.target.value)}
|
| 83 | style={{ flex: 1, padding: '6px 10px', borderRadius: 7, border: '1px solid #b2b2b2', minWidth: 0, fontSize: 15 }}
|
| 84 | />
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 85 | </div>
|
| 86 | <div style={{ marginBottom: 18, display: 'flex', alignItems: 'center' }}>
|
| 87 | <b style={{ width: 72, textAlign: 'left', marginRight: 0, fontSize: 16 }}>学校:</b>
|
| 88 | <input
|
| 89 | type="text"
|
| 90 | value={tempUserInfo.school}
|
| 91 | onChange={(e) => handleInputChange("school", e.target.value)}
|
| 92 | style={{ flex: 1, padding: '6px 10px', borderRadius: 7, border: '1px solid #b2b2b2', minWidth: 0, fontSize: 15 }}
|
| 93 | />
|
| 94 | </div>
|
| 95 | <div style={{ marginBottom: 18, display: 'flex', alignItems: 'center' }}>
|
ssq | 5067cb9 | 2025-06-05 11:44:23 +0000 | [diff] [blame] | 96 | <b style={{ width: 72, textAlign: 'left', marginRight: 0, fontSize: 16 }}>生日:</b>
|
| 97 | <input
|
| 98 | type="date"
|
| 99 | value={tempUserInfo.birthday}
|
| 100 | onChange={(e) => handleInputChange("birthday", e.target.value)}
|
| 101 | style={{ flex: 1, padding: '6px 10px', borderRadius: 7, border: '1px solid #b2b2b2', minWidth: 0, fontSize: 15 }}
|
| 102 | />
|
| 103 | </div>
|
| 104 | <div style={{ marginBottom: 18, display: 'flex', alignItems: 'center' }}>
|
| 105 | <b style={{ width: 72, textAlign: 'left', marginRight: 0, fontSize: 16 }}>密码:</b>
|
| 106 | <input
|
| 107 | type="password"
|
| 108 | value={tempUserInfo.password || ""}
|
| 109 | onChange={(e) => handleInputChange("password", e.target.value)}
|
| 110 | style={{ flex: 1, padding: '6px 10px', borderRadius: 7, border: '1px solid #b2b2b2', minWidth: 0, fontSize: 15 }}
|
| 111 | />
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 112 | </div>
|
| 113 | <div style={{ marginBottom: 18, display: 'flex', alignItems: 'center' }}>
|
| 114 | <b style={{ width: 72, textAlign: 'left', marginRight: 0, fontSize: 16 }}>性别:</b>
|
| 115 | <div style={{ position: 'relative', flex: 1 }}>
|
| 116 | <button
|
| 117 | onClick={() => setTempUserInfo({ ...tempUserInfo, showGenderOptions: !tempUserInfo.showGenderOptions })}
|
| 118 | style={{
|
| 119 | width: '100%',
|
| 120 | padding: '6px 10px',
|
| 121 | borderRadius: 7,
|
| 122 | border: '1px solid #b2b2b2',
|
| 123 | textAlign: 'left',
|
| 124 | backgroundColor: '#fff',
|
| 125 | fontSize: 15,
|
| 126 | cursor: 'pointer',
|
| 127 | }}
|
| 128 | >
|
| 129 | {tempUserInfo.gender || "性别"}
|
| 130 | </button>
|
| 131 | {tempUserInfo.showGenderOptions && (
|
| 132 | <ul
|
| 133 | style={{
|
| 134 | position: 'absolute',
|
| 135 | top: '100%',
|
| 136 | left: 0,
|
| 137 | right: 0,
|
| 138 | backgroundColor: '#fff',
|
| 139 | border: '1px solid #b2b2b2',
|
| 140 | borderRadius: 7,
|
| 141 | listStyle: 'none',
|
| 142 | margin: 0,
|
| 143 | padding: 0,
|
| 144 | zIndex: 10,
|
| 145 | }}
|
| 146 | >
|
| 147 | {["男", "女", "跨性别男", "跨性别女", "无性别"].map((option) => (
|
| 148 | <li
|
| 149 | key={option}
|
| 150 | onClick={() => {
|
| 151 | setTempUserInfo({ ...tempUserInfo, gender: option, showGenderOptions: false });
|
| 152 | }}
|
| 153 | style={{
|
| 154 | padding: '6px 10px',
|
| 155 | cursor: 'pointer',
|
| 156 | borderBottom: '1px solid #e0e0e0',
|
| 157 | backgroundColor: option === tempUserInfo.gender ? '#f0f0f0' : '#fff',
|
| 158 | }}
|
| 159 | >
|
| 160 | {option}
|
| 161 | </li>
|
| 162 | ))}
|
| 163 | </ul>
|
| 164 | )}
|
| 165 | </div>
|
| 166 | </div>
|
| 167 | <button
|
| 168 | onClick={handleSave}
|
| 169 | style={{
|
| 170 | marginTop: 20,
|
| 171 | padding: '10px 20px',
|
| 172 | backgroundColor: '#1a237e',
|
| 173 | color: '#fff',
|
| 174 | border: 'none',
|
| 175 | borderRadius: 7,
|
| 176 | cursor: 'pointer',
|
| 177 | fontSize: 16,
|
| 178 | alignSelf: 'center', // Center the button horizontally
|
| 179 | }}
|
| 180 | onMouseOver={(e) => (e.target.style.backgroundColor = '#0d1b5e')}
|
| 181 | onMouseOut={(e) => (e.target.style.backgroundColor = '#1a237e')}
|
| 182 | >
|
| 183 | 保存
|
| 184 | </button>
|
| 185 | </div>
|
| 186 | </div>
|
| 187 | {/* 上传种子列表 */}
|
| 188 | <div style={{ gridColumn: '2 / 3', gridRow: '1 / 2', background: '#fff', borderRadius: 18, boxShadow: '0 4px 24px #e0e7ff', padding: '20px' }}>
|
| 189 | <h3 style={{ color: '#1a237e', fontSize: 22, marginBottom: 18 }}>个人上传种子列表</h3>
|
ssq | 5067cb9 | 2025-06-05 11:44:23 +0000 | [diff] [blame] | 190 | <div style={{ border: '1px dashed #b2b2b2', borderRadius: 12, height: '100%', display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#b2b2b2', fontSize: 18 }}>
|
| 191 | (此处显示上传种子列表)
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 192 | </div>
|
| 193 | </div>
|
| 194 | {/* 活跃度模块 */}
|
| 195 | <div style={{ gridColumn: '2 / 3', gridRow: '2 / 3', background: '#fff', borderRadius: 18, boxShadow: '0 4px 24px #e0e7ff', padding: '20px' }}>
|
| 196 | <h3 style={{ color: '#1a237e', fontSize: 22, marginBottom: 18 }}>活跃度</h3>
|
ssq | 5067cb9 | 2025-06-05 11:44:23 +0000 | [diff] [blame] | 197 | <div style={{ border: '1px dashed #b2b2b2', borderRadius: 12, height: '100%', display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#b2b2b2', fontSize: 18 }}>
|
| 198 | (此处显示活跃度信息)
|
956303669 | a32fc2c | 2025-06-02 19:45:53 +0800 | [diff] [blame] | 199 | </div>
|
| 200 | </div>
|
| 201 | </div>
|
| 202 | );
|
| 203 | } |