107 lines
2.9 KiB
TypeScript
107 lines
2.9 KiB
TypeScript
import { ExhibitOverlay, Image, Title, Cursor } from "@/components";
|
|
import { useNavigate, useParams } from "react-router-dom";
|
|
import { getBackgroundImage, getStaticImage } from "@/lib/utils";
|
|
import { useState } from "react";
|
|
|
|
// starName 固定为 luxun
|
|
const starName = "luxun";
|
|
|
|
// 展品 ID 与资源路径映射
|
|
const exhibitSrcMap: Record<1 | 2, string> = {
|
|
1: "luxun/place4/展品9_t",
|
|
2: "luxun/place4/展品9_b",
|
|
};
|
|
|
|
const LuxunPlace4 = () => {
|
|
const navigate = useNavigate();
|
|
const { moduleName } = useParams<{
|
|
moduleName: string;
|
|
}>();
|
|
|
|
const [activeExhibitId, setActiveExhibitId] = useState<1 | 2 | null>(null);
|
|
const [visited, setVisited] = useState<Set<number>>(new Set());
|
|
|
|
const handleOpenExhibit = (index: 1 | 2) => {
|
|
setActiveExhibitId(index);
|
|
};
|
|
|
|
const progressCount = visited.size;
|
|
const total = 2;
|
|
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(`luxun/place4/背景`),
|
|
}}
|
|
>
|
|
<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}/place3`);
|
|
}
|
|
}}
|
|
/>
|
|
|
|
{/* 展品 */}
|
|
<Cursor
|
|
className="absolute left-170 bottom-115"
|
|
size={0.4}
|
|
onClick={() => handleOpenExhibit(1)}
|
|
read={visited.has(1)}
|
|
/>
|
|
<Cursor
|
|
className="absolute left-183 bottom-115"
|
|
size={0.4}
|
|
onClick={() => handleOpenExhibit(2)}
|
|
read={visited.has(2)}
|
|
/>
|
|
|
|
{completed && (
|
|
<Image
|
|
className="absolute bottom-0 right-120"
|
|
src={getStaticImage("luxun/place4/前进")}
|
|
button
|
|
onClick={() => {
|
|
navigate(`/${moduleName}/${starName}/place5`);
|
|
}}
|
|
/>
|
|
)}
|
|
|
|
<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);
|
|
}}
|
|
/>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default LuxunPlace4;
|