修复 lint 阻塞错误并恢复门禁

This commit is contained in:
2026-03-03 12:25:03 +08:00
parent 52b87abee3
commit 45dbac1935
8 changed files with 28 additions and 41 deletions
+1 -1
View File
@@ -339,7 +339,7 @@ export default function BlindboxLobbyPage() {
animate={{ opacity: 1 }}
transition={{ duration: 0.5, delay: 0.08 }}
>
"想做但一直没做"
""
</motion.p>
<motion.div
+1 -1
View File
@@ -38,7 +38,7 @@ export default function LandingPage() {
animate={{ opacity: 1 }}
transition={{ delay: 0.2 }}
>
"随便"
&quot;便&quot;
<br />
</motion.p>
+2 -10
View File
@@ -14,19 +14,11 @@ const HIDDEN_PREFIXES = ["/profile"];
export default function GlobalUserBadge() {
const router = useRouter();
const pathname = usePathname();
const [profile, setProfile] = useState<UserProfile | null>(null);
const [profile, setProfile] = useState<UserProfile | null>(() => getCachedProfile());
const [showAuth, setShowAuth] = useState(false);
const [theme, setTheme] = useState<Theme>("system");
const [theme, setTheme] = useState<Theme>(() => getStoredTheme());
const hidden = HIDDEN_PREFIXES.some((p) => pathname.startsWith(p));
useEffect(() => {
setProfile(getCachedProfile());
}, [pathname]);
useEffect(() => {
setTheme(getStoredTheme());
}, []);
useEffect(() => {
const handler = () => setProfile(getCachedProfile());
window.addEventListener("nowhatever_auth", handler);
+2 -2
View File
@@ -1,6 +1,6 @@
"use client";
import { useContext, useRef, type PropsWithChildren } from "react";
import { useContext, useState, type PropsWithChildren } from "react";
import { AnimatePresence, motion } from "framer-motion";
import { usePathname } from "next/navigation";
import { LayoutRouterContext } from "next/dist/shared/lib/app-router-context.shared-runtime";
@@ -11,7 +11,7 @@ import { LayoutRouterContext } from "next/dist/shared/lib/app-router-context.sha
*/
function FrozenRoute({ children }: PropsWithChildren) {
const ctx = useContext(LayoutRouterContext);
const frozen = useRef(ctx).current;
const [frozen] = useState(ctx);
return (
<LayoutRouterContext.Provider value={frozen}>
{children}
+5 -19
View File
@@ -1,6 +1,6 @@
"use client";
import { useCallback, useState, useEffect, useRef } from "react";
import { useCallback, useState, useEffect } from "react";
import { motion, AnimatePresence } from "framer-motion";
import { Star, MapPin, Clock, ExternalLink, Flame, Bookmark, ChevronLeft, ChevronRight } from "lucide-react";
import { Restaurant } from "@/types";
@@ -119,17 +119,6 @@ function ImageGallery({ images, name }: { images: string[]; name: string }) {
export default function RestaurantCard({ restaurant, likeCount = 0 }: RestaurantCardProps) {
const [favorited, setFavorited] = useState(false);
const [likeBounce, setLikeBounce] = useState(false);
const prevLikeRef = useRef(likeCount);
useEffect(() => {
if (likeCount > prevLikeRef.current) {
setLikeBounce(true);
const t = setTimeout(() => setLikeBounce(false), 600);
return () => clearTimeout(t);
}
prevLikeRef.current = likeCount;
}, [likeCount]);
const images = restaurant.images?.filter(Boolean);
const hasImage = images && images.length > 0;
@@ -175,21 +164,18 @@ export default function RestaurantCard({ restaurant, likeCount = 0 }: Restaurant
<AnimatePresence>
{likeCount > 0 && (
<motion.span
key="like-badge"
key={`like-badge-${likeCount}`}
className="flex items-center gap-0.5 rounded-full bg-rose-500/90 px-2 py-0.5 text-xs font-semibold text-white shadow-sm backdrop-blur-sm"
initial={{ opacity: 0, scale: 0.5, x: -8 }}
animate={{
opacity: 1,
scale: likeBounce ? [1, 1.3, 1] : 1,
scale: [1, 1.3, 1],
x: 0,
}}
exit={{ opacity: 0, scale: 0.5 }}
transition={likeBounce
? { scale: { duration: 0.4, ease: "easeInOut" }, default: { type: "spring", stiffness: 400, damping: 20 } }
: { type: "spring", stiffness: 400, damping: 20 }
}
transition={{ scale: { duration: 0.4, ease: "easeInOut" }, default: { type: "spring", stiffness: 400, damping: 20 } }}
>
<Flame size={11} className={likeBounce ? "animate-pulse" : ""} />
<Flame size={11} className="animate-pulse" />
{likeCount}
</motion.span>
)}
+6 -5
View File
@@ -1,6 +1,6 @@
"use client";
import { useRef } from "react";
import { useRef, useCallback, useEffect } from "react";
import {
motion,
useMotionValue,
@@ -64,7 +64,7 @@ export default function SwipeableCard({
const isSwiping = useRef(false);
const flyOut = (direction: SwipeDirection) => {
const flyOut = useCallback((direction: SwipeDirection) => {
if (isSwiping.current) return;
isSwiping.current = true;
const exit = getExitX();
@@ -75,11 +75,12 @@ export default function SwipeableCard({
damping: 40,
onComplete: () => onSwipe(direction),
});
};
}, [onSwipe, x]);
if (registerSwipe) {
useEffect(() => {
if (!registerSwipe) return;
registerSwipe(flyOut);
}
}, [registerSwipe, flyOut]);
const handleDragEnd = (_: unknown, info: PanInfo) => {
const offsetX = info.offset.x;
+4 -1
View File
@@ -64,7 +64,10 @@ export function useGeolocation() {
}, []);
useEffect(() => {
locate();
const timer = setTimeout(() => {
void locate();
}, 0);
return () => clearTimeout(timer);
}, [locate]);
return { status, coords, locationName, retry: locate };