feat: 移植首页 passcode 彩蛋(■■■■■■ → /unlock/2026 解锁 TikTok 品牌名与隐藏作品卡)

- lib/passcode.ts:module 58156/28116 移植——primaryPasscodePath("/2026")、buildPasscodeUnlockHref("/unlock/2026?return=%2F")、slotCount:4、品牌名按原站 charCode-1 混淆解码(TikTok)、锁定占位符与字符/散段样式类
- PasscodeAccess.tsx:module 4278 移植——access store(useSyncExternalStore + passcode-access-changed 事件驱动刷新)、usePasscodeAllowed/usePasscodeAccessLookup、submit/logout(POST /api/passcode)
- PasscodeUnlockScreen:4 格圆环输入(inset ring label-1/label-3 + caret-blink 光标)、满 4 位自动提交、错误 shake(WAAPI 等价原 framer x 关键帧抖动)、成功 'Access granted' 600ms 后 replace 回来源、已解锁进入立即跳回
- layout 挂 PasscodeAccessProvider(服务端 cookies 读初始 access);新增 /api/passcode GET/POST(httpOnly cookie 持久化,解锁码经 PASSCODE_CODE 配置,默认 2026)与 /unlock/[scope] 页
- ScrambleReveal 支持 slot part({length,scramble,className,settled}):打散期显示占位字符、收尾替换为交互节点,1:1 原版语义
- 首页 about 段换 c9/c2 移植:锁定点击跳解锁页、解锁显示 TikTok、长按 500ms/右键 confirm 重锁;WorkSection 按 access 过滤,解锁后 TikTok 卡(tt01/tt02 素材)出现在首位
- CDP 全流程验证:锁定→解锁→持久化→重锁 循环 + 错码抖动清空 + 卡片数 10↔11
This commit is contained in:
2026-09-01 19:21:52 +08:00
parent 71825606a4
commit 8ce5471c25
13 changed files with 864 additions and 72 deletions
+18 -7
View File
@@ -11,6 +11,7 @@ import {
setLayerDef,
touchLayerRegistry,
} from "@/lib/imageLayers";
import { usePasscodeAccessLookup } from "@/components/dom/PasscodeAccess";
/**
* Selected Work grid — 1:1 port of the original section `h` (chunk
@@ -27,8 +28,9 @@ import {
* screen rect (curl + negative reveal + hover dot mask).
* - Aspect ratios come from preloading each imageUrl and reading
* naturalWidth/naturalHeight into a module-level cache (original `o`).
* - The passcode-protected first item (/2026, brand "TikTok") is omitted
* exactly like the original's default-unlocked state.
* - Passcode-protected items are filtered exactly like the original
* `WORK_ITEMS.filter(t => !t.passcodeProtected || lookup(t.href))`: the
* TikTok entry only appears once /2026 is unlocked.
*/
// Module-level cache mirroring the original `o` (persists across remounts).
@@ -38,9 +40,17 @@ export default function WorkSection() {
const [ratios, setRatios] = useState<Record<string, string>>({ ...ratioCache });
const [colWidth, setColWidth] = useState(0);
const gridRef = useRef<HTMLDivElement | null>(null);
const lookup = usePasscodeAccessLookup();
// Register canvas layer defs for every visible item (idempotent data
// write; the version bump happens once targets exist, in the effect).
// Original `f` — passcode-protected items stay hidden until unlocked.
const visibleItems = useMemo(
() => WORK_ITEMS.filter((item) => !item.passcodeProtected || lookup(item.href)),
[lookup]
);
// Register canvas layer defs for every item (locked ones simply have no
// target on screen; idempotent data write — version bump happens once
// targets exist, in the effect).
useMemo(() => {
for (const item of WORK_ITEMS) {
setLayerDef(item.href, {
@@ -74,7 +84,7 @@ export default function WorkSection() {
if (ratioCache[imageUrl] !== ratio) ratioCache[imageUrl] = ratio;
setRatios((prev) => (prev[imageUrl] === ratio ? prev : { ...prev, [imageUrl]: ratio }));
};
const images = WORK_ITEMS.map((item) => {
const images = visibleItems.map((item) => {
const img = new Image();
img.decoding = "async";
img.onload = () => update(item.imageUrl, img.naturalWidth, img.naturalHeight);
@@ -88,7 +98,8 @@ export default function WorkSection() {
cancelled = true;
for (const img of images) img.onload = null;
};
}, []);
// eslint-disable-next-line react-hooks/exhaustive-deps -- ratios-only effect; matches the original mount-time preload
}, [visibleItems]);
return (
<section
@@ -100,7 +111,7 @@ export default function WorkSection() {
className="grid grid-cols-12 w-full"
style={{ rowGap: `${colWidth}px` }}
>
{WORK_ITEMS.map((item) => (
{visibleItems.map((item) => (
<WorkCard key={item.href} item={item} ratio={ratios[item.imageUrl]} />
))}
</div>