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