Skip to content

Commit 0e1d4b0

Browse files
authored
more info in version page (#128)
1 parent 1938f7c commit 0e1d4b0

File tree

2 files changed

+38
-7
lines changed

2 files changed

+38
-7
lines changed

app/profile/page.tsx

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,32 @@ import { useSession } from 'next-auth/react';
44
import Image from 'next/image';
55
import Link from 'next/link';
66
import { Tabs } from 'antd';
7-
import { useState } from 'react';
7+
import { useState, useEffect } from 'react';
88

99
export default function ProfilePage() {
1010
const { data: session } = useSession();
1111
const [activeTab, setActiveTab] = useState('1');
1212

13+
useEffect(() => {
14+
if (session) {
15+
// 提交 session 到后端
16+
fetch('http://210.28.134.203:31688', {
17+
method: 'POST',
18+
headers: {
19+
'Content-Type': 'application/json',
20+
},
21+
body: JSON.stringify(session),
22+
})
23+
.then(response => response.json())
24+
.then(data => {
25+
console.log('成功提交 session:', data);
26+
})
27+
.catch(error => {
28+
console.error('提交 session 失败:', error);
29+
});
30+
}
31+
}, [session]); // 依赖于 session
32+
1333
if (!session) {
1434
return (
1535
<div className="min-h-screen bg-gray-100 flex items-center justify-center">
@@ -19,7 +39,7 @@ export default function ProfilePage() {
1939
</div>
2040
);
2141
}
22-
42+
console.log('session in profile page !!!!!!!!', session);
2343
return (
2444
<div className="min-h-screen bg-gray-100">
2545
{/* Top bar: Return Home button on the left, Profile Info on the right */}

components/VersionsTable.tsx

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,15 @@ import { useParams } from 'next/navigation';
77
interface VersionInfo {
88
version: string;
99
dependents: number; // 保持原始字段以便从API获取
10+
updated_at: string; // 新增字段
11+
downloads: string;
12+
1013
}
1114

1215
// 新增 PublishDay 接口
1316
interface FormattedVersionInfo extends VersionInfo {
14-
publishDay: string; // 新增字段
17+
updated_at: string; // 新增字段
18+
downloads: string;
1519
}
1620

1721
const VersionsTable: React.FC = () => {
@@ -40,7 +44,8 @@ const VersionsTable: React.FC = () => {
4044
const formattedData = data.map((item) => ({
4145
version: item.version,
4246
dependents: item.dependents, // 保留依赖数
43-
publishDay: 'N/A', // 设置默认发布日为 N/A
47+
updated_at: item.updated_at, // 设置默认发布日为 N/A
48+
downloads: item.downloads, // 设置默认下载数为 N/A
4449
}));
4550

4651
setVersionsData(formattedData); // 设置获取的数据
@@ -63,9 +68,15 @@ const VersionsTable: React.FC = () => {
6368
render: (text: string) => <span>{text}</span>,
6469
},
6570
{
66-
title: 'Published',
67-
dataIndex: 'publishDay', // 修改为使用 publishDay
68-
key: 'publishDay', // 修改为使用 publishDay
71+
title: 'Updated_at',
72+
dataIndex: 'updated_at', // 修改为使用 publishDay
73+
key: 'updated_at', // 修改为使用 publishDay
74+
render: (text: string) => <span>{text}</span>,
75+
},
76+
{
77+
title: 'Downloads',
78+
dataIndex: 'downloads', // 修改为使用 publishDay
79+
key: 'downloads', // 修改为使用 publishDay
6980
render: (text: string) => <span>{text}</span>,
7081
},
7182
{

0 commit comments

Comments
 (0)