feat: 剩余页面 useT() 改造 + 首页课程动态加载

- 搜索/发现/工具/My 页面全部使用 useT(),支持中英切换
- 搜索页 Badge variant 修正
- 首页热门专题改为从 API 动态获取(无数据时用静态兜底)
- 新增 discover 翻译键 viewCount/likeCount/postStats
- 首页/仪表盘/社区 等 JSX 优化
This commit is contained in:
yuzhiran-dev
2026-05-22 17:08:17 +08:00
parent 1b4c19daa6
commit 477226ac15
7 changed files with 97 additions and 127 deletions
+16 -30
View File
@@ -1,60 +1,46 @@
'use client';
import { useEffect, useState } from 'react';
import Link from 'next/link';
import { apiFetch } from '../../lib/auth';
interface LearningItem {
courseId: number;
courseTitle: string;
progress: number;
completedLessons: number;
totalLessons: number;
}
import { useT } from '@/i18n';
export default function MyPage() {
const t = useT();
return (
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
<div className="mb-8">
<h1 className="text-3xl font-bold text-foreground"></h1>
<p className="mt-2 text-muted-foreground"></p>
<h1 className="text-3xl font-bold text-foreground">{t.nav.my}</h1>
<p className="mt-2 text-muted-foreground">{t.my.desc}</p>
</div>
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
<Link href="/my/learning" className="bg-card rounded-xl border border-border p-6 hover:shadow-md transition-shadow block">
<div className="w-12 h-12 bg-brand-100 rounded-xl flex items-center justify-center text-brand-600 text-xl mb-4">📚</div>
<h3 className="font-semibold text-foreground mb-2"></h3>
<p className="text-sm text-muted-foreground"></p>
<h3 className="font-semibold text-foreground mb-2">{t.my.learningProgress}</h3>
<p className="text-sm text-muted-foreground">{t.my.learningProgressDesc}</p>
</Link>
<Link href="/my/favorites" className="bg-card rounded-xl border border-border p-6 hover:shadow-md transition-shadow block">
<div className="w-12 h-12 bg-red-100 rounded-xl flex items-center justify-center text-red-600 text-xl mb-4"></div>
<h3 className="font-semibold text-foreground mb-2"></h3>
<p className="text-sm text-muted-foreground"></p>
<h3 className="font-semibold text-foreground mb-2">{t.my.favorites}</h3>
<p className="text-sm text-muted-foreground">{t.my.favoritesDesc}</p>
</Link>
<Link href="/my/member" className="bg-card rounded-xl border border-border p-6 hover:shadow-md transition-shadow block">
<div className="w-12 h-12 bg-amber-100 rounded-xl flex items-center justify-center text-amber-600 text-xl mb-4">👑</div>
<h3 className="font-semibold text-foreground mb-2"></h3>
<p className="text-sm text-muted-foreground"></p>
<h3 className="font-semibold text-foreground mb-2">{t.my.memberCenter}</h3>
<p className="text-sm text-muted-foreground">{t.my.memberDesc}</p>
</Link>
<Link href="/my/settings" className="bg-card rounded-xl border border-border p-6 hover:shadow-md transition-shadow block">
<div className="w-12 h-12 bg-muted rounded-xl flex items-center justify-center text-muted-foreground text-xl mb-4"></div>
<h3 className="font-semibold text-foreground mb-2"></h3>
<p className="text-sm text-muted-foreground"></p>
<h3 className="font-semibold text-foreground mb-2">{t.my.settings}</h3>
<p className="text-sm text-muted-foreground">{t.my.settingsDesc}</p>
</Link>
<Link href="/learning/analytics" className="bg-card rounded-xl border border-border p-6 hover:shadow-md transition-shadow block">
<div className="w-12 h-12 bg-brand-100 rounded-xl flex items-center justify-center text-brand-600 text-xl mb-4">📊</div>
<h3 className="font-semibold text-foreground mb-2"></h3>
<p className="text-sm text-muted-foreground"></p>
<h3 className="font-semibold text-foreground mb-2">{t.learning.analytics}</h3>
<p className="text-sm text-muted-foreground">{t.my.analyticsDesc}</p>
</Link>
<Link href="/learning/path" className="bg-card rounded-xl border border-border p-6 hover:shadow-md transition-shadow block">
<div className="w-12 h-12 bg-green-100 rounded-xl flex items-center justify-center text-green-600 text-xl mb-4">🗺</div>
<h3 className="font-semibold text-foreground mb-2"></h3>
<p className="text-sm text-muted-foreground"> AI </p>
<h3 className="font-semibold text-foreground mb-2">{t.learning.path}</h3>
<p className="text-sm text-muted-foreground">{t.my.pathDesc}</p>
</Link>
</div>
</div>