blob: 5fbd5ea4d37b178740df6ce23ceb98939fe25766 [file] [log] [blame]
Krishya34493be2025-06-09 22:45:46 +08001// // export default NewbieTasks;
2// import React, { useEffect, useState } from 'react';
3// import axios from 'axios';
4
5// const NewbieTasks = () => {
6// const [tasks, setTasks] = useState([]);
7// const [experience, setExperience] = useState({});
8// const [currentStep, setCurrentStep] = useState({});
9// const [loading, setLoading] = useState(true);
10
11// const baseURL = '/echo/task/tutorial';
12// const userId = 1;
13
14// const fetchTasks = async () => {
15// try {
16// const response = await axios.get(`${baseURL}/getAllTasks`, {
17// params: { user_id: userId },
18// });
19// setTasks(response.data.tasks || []);
20// } catch (error) {
21// console.error('获取任务失败:', error);
22// }
23// };
24
25// const fetchExperience = async () => {
26// try {
27// const response = await axios.get(`${baseURL}/getAllTasks`, {
28// params: { user_id: userId },
29// });
30// setExperience(response.data || {});
31// } catch (error) {
32// console.error('获取经验失败:', error);
33// }
34// };
35
36// const fetchCurrentStep = async () => {
37// try {
38// const response = await axios.get(`${baseURL}/getNewStep`, {
39// params: { user_id: userId },
40// });
41// setCurrentStep(response.data || {});
42// } catch (error) {
43// console.error('获取引导步骤失败:', error);
44// }
45// };
46
47// const updateStatus = async (taskId) => {
48// try {
49// await axios.post(`${baseURL}/updateStatus`, {
50// user_id: userId,
51// task_id: taskId,
52// });
53// await fetchTasks();
54// await fetchExperience();
55// } catch (error) {
56// console.error('更新状态失败:', error);
57// }
58// };
59
60// const updateProgress = async (taskId, progress) => {
61// try {
62// await axios.post(`${baseURL}/updateProgress`, {
63// user_id: userId,
64// task_id: taskId,
65// progress,
66// });
67// await fetchTasks();
68// } catch (error) {
69// console.error('更新进度失败:', error);
70// }
71// };
72
73// const claimReward = async (taskId) => {
74// try {
75// await axios.post(`${baseURL}/rewardClaim`, {
76// user_id: userId,
77// task_id: taskId,
78// });
79// await fetchTasks();
80// await fetchExperience();
81// } catch (error) {
82// console.error('领取奖励失败:', error);
83// }
84// };
85
86// const checkRewardStatus = async (taskId) => {
87// try {
88// const response = await axios.post(`${baseURL}/rewardReview`, {
89// user_id: userId,
90// task_id: taskId,
91// });
92// alert(response.data.message || '已完成');
93// } catch (error) {
94// console.error('查看失败:', error);
95// }
96// };
97
98// useEffect(() => {
99// const init = async () => {
100// await fetchTasks();
101// await fetchExperience();
102// await fetchCurrentStep();
103// setLoading(false);
104// };
105// init();
106// }, []);
107
108// if (loading) return <p className="loading">加载中...</p>;
109
110// return (
111// <div className="common-card right-content">
112// <div className="profile-header">
113// <h1>🎯 用户等级</h1>
114// </div>
115
116// <div className="profile-details">
117// <p><strong>当前经验:</strong>{experience.current_experience}</p>
118// <p><strong>等级:</strong>{experience.level}</p>
119// <p><strong>奖励经验:</strong>{experience.reward?.experience || 0}</p>
120// <p><strong>奖励积分:</strong>{experience.reward?.points || 0}</p>
121// </div>
122
123// <div className="profile-details">
124// <p><strong>🧭 当前引导步骤:</strong>{currentStep.current_step}</p>
125// <p>{currentStep.step_description}</p>
126// </div>
127
128// <div className="profile-details">
129// <h2>任务列表</h2>
130// <ul>
131// {tasks.map(task => (
132// <li key={task.task_id} style={{ marginBottom: '20px', borderBottom: '1px solid #eee', paddingBottom: '10px' }}>
133// <p><strong>任务:</strong>{task.title}</p>
134// <p><strong>描述:</strong>{task.description}</p>
135// <p><strong>进度:</strong>{task.progress}%</p>
136// <p><strong>状态:</strong>{task.status}</p>
137// <p><strong>奖励:</strong>经验 {task.reward.experience},积分 {task.reward.points}</p>
138
139// <div className="task-btn-group">
140// <button className="task-btn" onClick={() => updateStatus(task.task_id)}>更新状态</button>
141// <button className="task-btn" onClick={() => updateProgress(task.task_id, 100)}>提交进度</button>
142// <button className="task-btn" onClick={() => claimReward(task.task_id)}>领取奖励</button>
143// <button className="task-btn" onClick={() => checkRewardStatus(task.task_id)}>查看奖励状态</button>
144// </div>
145// </li>
146// ))}
147// </ul>
148// </div>
149// </div>
150// );
151// };
152
2230100901d3ff92025-06-07 16:16:26 +0800153// export default NewbieTasks;
Krishya34493be2025-06-09 22:45:46 +0800154
155
156import React from'react';
157import './NewbieTasks.css';
2230100901d3ff92025-06-07 16:16:26 +0800158
159const NewbieTasks = () => {
Krishya34493be2025-06-09 22:45:46 +0800160 const tableData = [
161 {
162 level: 'lv0【糖果】',
163 newPermissions: '查看种子分类和评论,查看其他用户主页',
164 upgradeConditions: '无'
165 },
166 {
167 level: 'lv1【曲奇】',
168 newPermissions: '上传免费种子,下载免费种子,发布评论,私信/关注其他用户,收藏种子',
169 upgradeConditions: '经验≥50,分享率≥0.5,上传量≥10G,做种时长≥72h'
170 },
171 {
172 level: 'lv2【巧克力】',
173 newPermissions: '下载付费种子,成立和加入兴趣小组',
174 upgradeConditions: '经验≥200,分享率≥0.75,上传量≥50G,做种时长≥240h'
175 },
176 {
177 level: 'lv3【冰激凌】',
178 newPermissions: '上传付费种子',
179 upgradeConditions: '经验≥500,分享率≥1,上传量≥100G,做种时长≥600h'
180 }
181 ];
182 return (
183 <div className="newbie-tasks-container">
184 <h2 className="page-title">🎯 用户等级</h2>
185 <p>各个等级的权限在下面啦~ 经验值可以通过上传种子获得哦!</p>
186 <table className="tasks-table">
187 <thead>
188 <tr>
189 <th>用户等级</th>
190 <th>新增权限</th>
191 <th>升级条件</th>
192 </tr>
193 </thead>
194 <tbody>
195 {tableData.map((item, index) => (
196 <tr key={index}>
197 <td>{item.level}</td>
198 <td>{item.newPermissions}</td>
199 <td>{item.upgradeConditions}</td>
200 </tr>
201 ))}
202 </tbody>
203 </table>
204 </div>
205 );
2230100901d3ff92025-06-07 16:16:26 +0800206};
207
208export default NewbieTasks;