feat: 全局用户头像徽章,所有页面右上角统一显示

- 新增 GlobalUserBadge 组件,固定在右上角,已登录显示头像+用户名,未登录显示登录按钮
- 通过 layout.tsx 全局挂载,仅在个人中心页隐藏
- userId.ts 登录/登出时派发 nowhatever_auth 事件,组件实时响应
- 移除各页面重复的用户指示器(首页、极速救场、周末契约大厅、个人中心顶栏退出按钮)
- TopNav 右侧留出空间避免与全局徽章重叠
- 头像徽章采用暗色主题风格(bg-surface/80)
This commit is contained in:
2026-02-26 14:42:40 +08:00
parent f851eed847
commit 7aa6c7f792
9 changed files with 129 additions and 110 deletions
+37 -11
View File
@@ -22,7 +22,13 @@ import {
Heart,
UserPlus,
} from "lucide-react";
import { Restaurant, MatchType, RunnerUp, SceneType, UserProfile } from "@/types";
import {
Restaurant,
MatchType,
RunnerUp,
SceneType,
UserProfile,
} from "@/types";
import { fireCelebration, playChime } from "@/lib/celebrate";
import { isRegistered } from "@/lib/userId";
import ShareCardModal from "@/components/ShareCardModal";
@@ -237,11 +243,14 @@ export default function MatchResult({
setShowShareCard(true);
}, []);
const handleAuth = useCallback((profile: UserProfile) => {
setRegistered(true);
setShowAuth(false);
showToast(`欢迎,${profile.username}!记录已保存`);
}, [showToast]);
const handleAuth = useCallback(
(profile: UserProfile) => {
setRegistered(true);
setShowAuth(false);
showToast(`欢迎,${profile.username}!记录已保存`);
},
[showToast],
);
const handleFavorite = useCallback(async () => {
if (!registered || favorited || favLoading) return;
@@ -296,7 +305,12 @@ export default function MatchResult({
<motion.div
initial={{ scale: 0, rotate: -20 }}
animate={{ scale: 1, rotate: 0 }}
transition={{ type: "spring", stiffness: 200, damping: 12, delay: 0.2 }}
transition={{
type: "spring",
stiffness: 200,
damping: 12,
delay: 0.2,
}}
>
{isUnanimous ? (
<PartyPopper size={56} className="text-emerald-400" />
@@ -311,7 +325,7 @@ export default function MatchResult({
animate={{ y: 0, opacity: 1 }}
transition={{ delay: 0.35 }}
>
{isSolo ? "帮你选好了" : "就去这了"}
{isSolo ? "帮你选好了" : "就去这了"}
</motion.h1>
<motion.p
@@ -352,7 +366,12 @@ export default function MatchResult({
className="relative mt-6 w-full overflow-hidden rounded-2xl bg-surface shadow-2xl ring-1 ring-border"
initial={{ y: 60, opacity: 0 }}
animate={{ y: 0, opacity: 1 }}
transition={{ type: "spring", stiffness: 180, damping: 18, delay: 0.5 }}
transition={{
type: "spring",
stiffness: 180,
damping: 18,
delay: 0.5,
}}
>
{registered && (
<motion.button
@@ -362,11 +381,18 @@ export default function MatchResult({
whileTap={{ scale: 0.85 }}
initial={{ scale: 0, opacity: 0 }}
animate={{ scale: 1, opacity: 1 }}
transition={{ delay: 0.7, type: "spring", stiffness: 300, damping: 15 }}
transition={{
delay: 0.7,
type: "spring",
stiffness: 300,
damping: 15,
}}
>
<Heart
size={18}
className={favorited ? "fill-red-500 text-red-500" : "text-white"}
className={
favorited ? "fill-red-500 text-red-500" : "text-white"
}
/>
</motion.button>
)}