feat: 新用户滑动引导,首次进入展示手势提示

- 首张卡片叠加半透明引导层,左滑不想去/右滑想去动画提示
- 支持点击消失、拖拽消失、3秒自动消失
- localStorage 记录标记,每个用户只展示一次
- 修复 React Strict Mode 下 effect 双执行导致引导不显示的问题
This commit is contained in:
2026-02-24 17:43:12 +08:00
parent fb49e21eb2
commit 1b06f4fc0e
2 changed files with 103 additions and 0 deletions
+6
View File
@@ -5,6 +5,7 @@ import { AnimatePresence, motion } from "framer-motion";
import SwipeableCard from "./SwipeableCard";
import ActionButtons from "./ActionButtons";
import MatchResult from "./MatchResult";
import SwipeGuide from "./SwipeGuide";
import { Restaurant, SwipeDirection, MatchType } from "@/types";
import { Heart } from "lucide-react";
@@ -36,6 +37,7 @@ export default function SwipeDeck({
const [localMatchId, setLocalMatchId] = useState<string | null>(null);
const [resetting, setResetting] = useState(false);
const [bubble, setBubble] = useState("");
const [guideVisible, setGuideVisible] = useState(true);
const swipeFnRef = useRef<((direction: SwipeDirection) => void) | null>(null);
const swipingRef = useRef(false);
const prevLikeCounts = useRef<Record<string, number>>({});
@@ -97,6 +99,7 @@ export default function SwipeDeck({
if (!current) return;
swipingRef.current = false;
if (guideVisible) setGuideVisible(false);
const action = direction === "right" ? "like" : "nope";
sendSwipe(current.id, action);
@@ -163,6 +166,9 @@ export default function SwipeDeck({
<div className="relative flex flex-1 items-center justify-center px-4">
<div className="relative h-[70vh] w-full max-w-sm">
{currentIndex === 0 && !resolvedMatchId && guideVisible && (
<SwipeGuide onDismiss={() => setGuideVisible(false)} />
)}
{!resolvedMatchId && (
<AnimatePresence>
{restaurants.map((restaurant, index) => {