refactor: 移除个人页面决策记录,统一由成就墙展示

决策记录已完整迁移至 /achievements 成就墙页面,
个人中心不再重复展示,减少冗余数据请求。
This commit is contained in:
2026-02-27 10:05:22 +08:00
parent c17b13b6a8
commit beb2c632bb
+1 -21
View File
@@ -20,13 +20,12 @@ import {
} from "lucide-react";
import Card from "@/components/Card";
import Input from "@/components/Input";
import ProfileHistoryCard from "@/components/ProfileHistoryCard";
import ProfileFavoritesCard from "@/components/ProfileFavoritesCard";
import { useToast } from "@/hooks/useToast";
import { ProfileCardSkeleton, RecordItemSkeleton } from "@/components/Skeleton";
import { getUserId, getCachedProfile, setCachedProfile, setCachedPreferences, logout } from "@/lib/userId";
import { getAvatarBg, AVATARS } from "@/lib/avatars";
import type { UserProfile, UserPreferences, DecisionRecord, FavoriteRecord } from "@/types";
import type { UserProfile, UserPreferences, FavoriteRecord } from "@/types";
export default function ProfilePage() {
const router = useRouter();
@@ -34,9 +33,7 @@ export default function ProfilePage() {
const [profile, setProfile] = useState<(UserProfile & { email?: string; preferences?: UserPreferences; decisionCount?: number }) | null>(null);
const [loading, setLoading] = useState(true);
const [history, setHistory] = useState<DecisionRecord[]>([]);
const [favorites, setFavorites] = useState<FavoriteRecord[]>([]);
const [historyLoading, setHistoryLoading] = useState(false);
const [favLoading, setFavLoading] = useState(false);
const [editingUsername, setEditingUsername] = useState(false);
@@ -58,7 +55,6 @@ export default function ProfilePage() {
const [emailSaving, setEmailSaving] = useState(false);
const [emailMsg, setEmailMsg] = useState("");
const [showHistory, setShowHistory] = useState(true);
const [showFavorites, setShowFavorites] = useState(true);
const toast = useToast();
@@ -93,13 +89,6 @@ export default function ProfilePage() {
useEffect(() => {
if (!userId) return;
setHistoryLoading(true);
fetch(`/api/user/history?userId=${userId}`)
.then((r) => { if (!r.ok) throw new Error(); return r.json(); })
.then((data) => setHistory(Array.isArray(data) ? data : []))
.catch(() => {})
.finally(() => setHistoryLoading(false));
setFavLoading(true);
fetch(`/api/user/favorite?userId=${userId}`)
.then((r) => { if (!r.ok) throw new Error(); return r.json(); })
@@ -500,15 +489,6 @@ export default function ProfilePage() {
</button>
</Card>
<ProfileHistoryCard
history={history}
loading={historyLoading}
open={showHistory}
onToggle={() => setShowHistory((v) => !v)}
onEmpty={() => router.push("/blindbox")}
delay={0.2}
/>
<ProfileFavoritesCard
favorites={favorites}
loading={favLoading}