blob: 55bc9551c7da56c4a52bc5674742c40386f31601 [file] [log] [blame]
Akane121765b61a72025-05-17 13:52:25 +08001import React from 'react';
2import { useNavigate,useLocation } from 'react-router-dom';
3import './personalSubpage.css';
4
5const Notice = ({ onLogout }) => {
6 const navigate = useNavigate();
7 const location = useLocation();
8 // 模拟数据
9 const [notices] = React.useState([
10 {
11 id: 1,
12 title: '积分奖励到账',
13 content: '您上传的资源《盗梦空间》获得100积分奖励',
14 date: '2023-10-20',
15 read: false
16 },
17 {
18 id: 2,
19 title: '系统通知',
20 content: '服务器将于今晚2:00-4:00进行维护',
21 date: '2023-10-18',
22 read: true
23 }
24 ]);
25
26 const handleBack = () => {
27 // 返回个人中心,并携带来源标记
28 navigate('/personal', {
29 state: {
30 fromSubpage: true, // 标记来自子页面
31 dashboardTab: location.state?.dashboardTab // 保留Dashboard的标签页状态
32 },
33 replace: true // 替换当前历史记录
34 });
35 };
36
37 return (
38 <div className="subpage-container">
39 <button className="back-button" onClick={(handleBack)}>
40 返回个人中心
41 </button>
42
43 <h2 className="page-title">消息通知</h2>
44
45 <div className="notice-list">
46 {notices.map(notice => (
47 <div key={notice.id} className={`list-item ${!notice.read ? 'unread' : ''}`}>
48 <div className="notice-header">
49 <h3>{notice.title}</h3>
50 <span className="notice-date">{notice.date}</span>
51 </div>
52 <p className="notice-content">{notice.content}</p>
53 </div>
54 ))}
55 </div>
56 </div>
57 );
58};
59
60export default Notice;