feat:init

This commit is contained in:
zhongyidian committed 2025-12-29 19:19:10 +08:00
1 parent 53d0eeac6b
commit ae0c050010
494 files changed
+17701 -2318

No files matched your search

+127
View File
@@ -0,0 +1,127 @@
import {
ExhibitOverlay,
GuideSteps,
GuideStepsItem,
Image,
Title,
} from "@/components";
import { useNavigate, useParams } from "react-router-dom";
import { getBackgroundImage, getStaticImage } from "@/lib/utils";
import { useState } from "react";
import Cursor from "@/components/cursor";
// starName 固定为 huangyanpei
const starName = "huangyanpei";
// 展品 ID 与资源路径映射,ID 用来做唯一标识
const exhibitSrcMap: Record<1, string> = {
1: "huangyanpei/place1/3_003",
};
const HuangyanpeiPlace1 = () => {
const navigate = useNavigate();
const { moduleName } = useParams<{
moduleName: string;
}>();
// 引导对话显示状态
const [visible, setVisible] = useState(true);
// 当前激活的展品 ID(只存 ID,不直接存路径,便于作为唯一标识)
const [activeExhibitId, setActiveExhibitId] = useState<1 | null>(null);
// 已浏览展品的 ID 集合
const [visited, setVisited] = useState<Set<number>>(new Set());
const handleOpenExhibit = (index: 1 | null) => {
setActiveExhibitId(index);
};
const progressCount = visited.size;
const total = 1;
const completed = progressCount >= total;
const subtitle = completed
? "探索黄炎培故居门前(已完成)"
: `探索黄炎培故居门前(${progressCount}/${total})`;
const subtitleClassName = completed
? "text-[#fff998] [text-shadow:_0_8px_8px_rgba(0,0,0,0.35),_0_0_16px_rgba(0,0,0,0.25)]"
: undefined;
return (
<div
className="w-full h-full bg-cover bg-center bg-no-repeat"
style={{
backgroundImage: getBackgroundImage(`huangyanpei/place1/3_001`),
}}
>
{/* 标题 */}
<Title
title="思想启蒙"
subtitle={subtitle}
subtitleClassName={subtitleClassName}
className="absolute top-10 left-1/2 -translate-x-1/2"
/>
<Image
className="absolute right-5 top-5"
src={getStaticImage("components/离开")}
button
onClick={() => {
if (moduleName && starName) {
navigate(`/${moduleName}/${starName}/home`);
}
}}
/>
{/* 展品1 */}
<Cursor
className="absolute left-[calc(50%-8px)] bottom-100"
onClick={() => handleOpenExhibit(1)}
read={visited.has(1)}
/>
{/* 继续前进 - 仅在完成所有展品后显示 */}
{completed && (
<Image
className="absolute bottom-[calc(50%-140px)] right-80"
src={getStaticImage("huangyanpei/place1/3_005")}
button
onClick={() => {
navigate(`/${moduleName}/${starName}/place2`);
}}
/>
)}
{/* 遮罩层 */}
<ExhibitOverlay
visible={activeExhibitId !== null}
src={activeExhibitId ? exhibitSrcMap[activeExhibitId] : ""}
onClose={() => {
if (activeExhibitId !== null) {
setVisited((prev) => {
const next = new Set(prev);
next.add(activeExhibitId);
return next;
});
}
setActiveExhibitId(null);
}}
/>
{/* 引导 */}
<GuideSteps
visible={visible}
onVisibleChange={setVisible}
showMask={true}
highlightSelectors={[]}
>
<GuideStepsItem speaker="student">
小沪!这就是黄炎培先生曾经生活过的地方吗?
</GuideStepsItem>
<GuideStepsItem speaker="guide">
是的,这里就是黄炎培故居。让我们一起来探索黄炎培先生的思想启蒙之路...
</GuideStepsItem>
</GuideSteps>
</div>
);
};
export default HuangyanpeiPlace1;