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
+123 -44
View File
@@ -4,7 +4,7 @@ import { useEffect, useMemo, useRef, useState } from "react";
/**
* 1:1 re-implementation of the original scramble-reveal text (chunk
* 2689132c4e070b68.js component `d`):
* 2689132c4e070b68.js module 71358 component `d`):
*
* - charset `ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*+-=?/<>[]{}` picked
* randomly per render while a character is "scrambling"
@@ -15,15 +15,62 @@ import { useEffect, useMemo, useRef, useState } from "react";
* - refresh tick every 40ms; the whole text settles at
* startDelayMs + (n-1)*letterDelayMs + 4*letterDelayMs
* - starts once when the element enters the viewport (threshold 0.1)
*
* Parts accept strings or **slot objects** `{ length, scramble?, className?,
* settled? }` (original slot parts): while scrambling, slot characters show
* `scramble` (default: spaces) with the same per-char delays; once settled
* the slot renders `settled` (a React node, e.g. the passcode button) in
* place of the characters.
*/
const CHARSET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*+-=?/<>[]{}";
const COLORS_LIGHT = ["#c0fe04", "#607F02"];
const randomChar = () => CHARSET[Math.floor(Math.random() * CHARSET.length)];
export type ScrambleSlotPart = {
/** Number of characters this slot occupies in the reveal sequence. */
length: number;
/** Placeholder characters shown while the slot is scrambling. */
scramble?: string;
/** Class for the slot wrapper span. */
className?: string;
/** React node rendered once the reveal has fully settled. */
settled?: React.ReactNode;
};
type Part = string | ScrambleSlotPart;
type NormalizedPart =
| { kind: "text"; value: string }
| {
kind: "slot";
length: number;
scramble: string;
settled?: React.ReactNode;
className?: string;
};
function normalizeParts(parts: Part[] | undefined, text: string | undefined): NormalizedPart[] {
return (parts ?? [text ?? ""]).map((p) => {
if (typeof p === "string") return { kind: "text" as const, value: p };
const length = Math.max(0, p.length);
const scramble = (p.scramble ?? (length > 0 ? " ".repeat(length) : ""))
.slice(0, length)
.padEnd(length, " ");
return {
kind: "slot" as const,
length,
scramble,
settled: p.settled,
className: p.className,
};
});
}
type Props = {
text?: string;
parts?: string[];
parts?: Part[];
className?: string;
startDelayMs?: number;
letterDelayMs?: number;
@@ -41,8 +88,8 @@ export default function ScrambleReveal({
scrambleColors = true,
reverse = false,
}: Props) {
const strings = useMemo(
() => (parts ? parts : [text ?? ""]),
const normalized = useMemo(
() => normalizeParts(parts, text),
[parts, text]
);
const ref = useRef<HTMLSpanElement>(null);
@@ -50,7 +97,10 @@ export default function ScrambleReveal({
const [startedAt, setStartedAt] = useState<number | null>(null);
const [elapsed, setElapsed] = useState(0);
const F = strings.join("").length;
const F = normalized.reduce(
(acc, p) => acc + (p.kind === "text" ? p.value.length : p.length),
0
);
const phaseLen = 2 * letterDelayMs; // j
const scrambleWindow = 2 * phaseLen; // D
const total = startDelayMs + Math.max(0, F - 1) * letterDelayMs + scrambleWindow;
@@ -94,53 +144,82 @@ export default function ScrambleReveal({
if (settled || !entered) {
return (
<span ref={ref} className={className}>
{strings.map((s, i) => (
<span key={i}>{entered ? s : ""}</span>
))}
{normalized.map((p, i) =>
p.kind === "text" ? (
<span key={`text-${i}`}>{entered ? p.value : ""}</span>
) : (
<span key={`slot-${i}`} className={p.className}>
{entered ? p.settled : null}
</span>
)
)}
</span>
);
}
// recompute random chars on each elapsed tick
let index = 0;
const totalChars = strings.join("").length;
return (
<span ref={ref} className={className}>
{strings.map((s, si) => (
<span key={si}>
{s.split("").map((ch, ci) => {
const i = index++;
// Original `reverse`: character delays run last→first.
const order = reverse ? totalChars - 1 - i : i;
if (ch === "\n") return <br key={`br-${si}-${ci}`} />;
if (ch === " ") return <span key={`sp-${si}-${ci}`}> </span>;
const n = order * letterDelayMs;
if (V < n) {
return (
<span key={`c-${si}-${ci}`} style={{ opacity: 0 }}>
{ch}
</span>
);
}
if (V < n + scrambleWindow) {
const phase = Math.min(
1,
Math.floor((V - n) / phaseLen)
);
const color = scrambleColors ? COLORS_LIGHT[phase] : undefined;
return (
<span
key={`c-${si}-${ci}`}
style={color ? { color } : undefined}
>
{randomChar()}
</span>
);
}
return <span key={`c-${si}-${ci}`}>{ch}</span>;
})}
</span>
))}
{normalized.map((p, pi) => {
if (p.kind === "text") {
return (
<span key={`text-${pi}`}>
{p.value.split("").map((ch, ci) => {
const i = index++;
// Original `reverse`: character delays run last→first.
const order = reverse ? F - 1 - i : i;
if (ch === "\n") return <br key={`br-${pi}-${ci}`} />;
if (ch === " ") return <span key={`sp-${pi}-${ci}`}> </span>;
const n = order * letterDelayMs;
if (V < n) {
return (
<span key={`c-${pi}-${ci}`} style={{ opacity: 0 }}>
{ch}
</span>
);
}
if (V < n + scrambleWindow) {
const phase = Math.min(1, Math.floor((V - n) / phaseLen));
const color = scrambleColors ? COLORS_LIGHT[phase] : undefined;
return (
<span key={`c-${pi}-${ci}`} style={color ? { color } : undefined}>
{randomChar()}
</span>
);
}
return <span key={`c-${pi}-${ci}`}>{ch}</span>;
})}
</span>
);
}
return (
<span key={`slot-${pi}`} className={p.className}>
{p.scramble.split("").map((ch, ci) => {
const i = index++;
const order = reverse ? F - 1 - i : i;
const n = order * letterDelayMs;
if (V < n) {
return (
<span key={`sc-${pi}-${ci}`} style={{ opacity: 0 }}>
{ch}
</span>
);
}
if (V < n + scrambleWindow) {
const phase = Math.min(1, Math.floor((V - n) / phaseLen));
const color = scrambleColors ? COLORS_LIGHT[phase] : undefined;
return (
<span key={`sc-${pi}-${ci}`} style={color ? { color } : undefined}>
{randomChar()}
</span>
);
}
return <span key={`sc-${pi}-${ci}`}>{ch}</span>;
})}
</span>
);
})}
</span>
);
}