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:
@@ -0,0 +1,137 @@
|
||||
"use client";
|
||||
|
||||
/**
|
||||
* About-paragraph passcode easter egg — 1:1 port of the original components
|
||||
* `c9` + `c2` (chunk 4d3f3b68dbbde33a.js):
|
||||
*
|
||||
* - Locked: the brand label slot scrambles as "■■■■■■" (each char wrapped,
|
||||
* PASSCODE_LOCKED_CHAR_CLASS); clicking navigates through the route
|
||||
* transition to /unlock/2026?return=%2F.
|
||||
* - Unlocked: the slot settles to the "TikTok" button span — long-press
|
||||
* (500ms) or context-menu re-locks (confirm + reload).
|
||||
* - The reveal sequence (ScrambleReveal) treats the label as a slot part, so
|
||||
* its 6 characters participate in the per-char scramble timing.
|
||||
*/
|
||||
import { useCallback, useRef } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import ScrambleReveal from "@/components/dom/ScrambleReveal";
|
||||
import {
|
||||
logoutPasscodeAccess,
|
||||
usePasscodeAllowed,
|
||||
} from "@/components/dom/PasscodeAccess";
|
||||
import {
|
||||
PASSCODE_LOCKED_CHAR_CLASS,
|
||||
PASSCODE_LOCKED_SCRAMBLE_CLASS,
|
||||
buildPasscodeUnlockHref,
|
||||
passcodeLockedPlaceholderText,
|
||||
primaryPasscodePath,
|
||||
revealBrandLabel,
|
||||
revealBrandLabelLength,
|
||||
} from "@/lib/passcode";
|
||||
|
||||
const SCOPE = primaryPasscodePath(); // "/2026"
|
||||
const BRAND = revealBrandLabel(); // "TikTok"
|
||||
const BRAND_LEN = revealBrandLabelLength(); // 6
|
||||
|
||||
function RevealLabelButton() {
|
||||
const allowed = usePasscodeAllowed(SCOPE);
|
||||
const router = useRouter();
|
||||
const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||
|
||||
const clearTimer = useCallback(() => {
|
||||
if (timerRef.current) {
|
||||
clearTimeout(timerRef.current);
|
||||
timerRef.current = null;
|
||||
}
|
||||
}, []);
|
||||
|
||||
const relock = useCallback(async () => {
|
||||
if (
|
||||
window.confirm("Lock protected content again? You will need the passcode to view it.")
|
||||
) {
|
||||
await logoutPasscodeAccess({ reload: true });
|
||||
}
|
||||
}, []);
|
||||
|
||||
if (!allowed) {
|
||||
// TODO(route-system): go through useRouteTransitionController().startNavigation
|
||||
const go = () => {
|
||||
router.push(buildPasscodeUnlockHref(SCOPE, "/"));
|
||||
};
|
||||
return (
|
||||
<span
|
||||
role="button"
|
||||
tabIndex={0}
|
||||
aria-label="Protected — enter passcode to reveal"
|
||||
className="inline-flex items-baseline gap-[0.12em] mx-[0.06em] align-baseline cursor-pointer select-text"
|
||||
onClick={go}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter" || e.key === " ") {
|
||||
e.preventDefault();
|
||||
go();
|
||||
}
|
||||
}}
|
||||
>
|
||||
{passcodeLockedPlaceholderText()
|
||||
.split("")
|
||||
.map((ch, i) => (
|
||||
<span key={i} aria-hidden="true" className={PASSCODE_LOCKED_CHAR_CLASS}>
|
||||
{ch}
|
||||
</span>
|
||||
))}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<span
|
||||
role="button"
|
||||
tabIndex={0}
|
||||
aria-label={`${BRAND} — long press to lock again`}
|
||||
className="inline mx-[0.06em] align-baseline cursor-default select-none"
|
||||
onPointerDown={() => {
|
||||
clearTimer();
|
||||
timerRef.current = setTimeout(() => void relock(), 500);
|
||||
}}
|
||||
onPointerUp={clearTimer}
|
||||
onPointerLeave={clearTimer}
|
||||
onPointerCancel={clearTimer}
|
||||
onContextMenu={(e) => {
|
||||
e.preventDefault();
|
||||
void relock();
|
||||
}}
|
||||
>
|
||||
{BRAND}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
export default function PasscodeRevealText({
|
||||
className,
|
||||
startDelayMs = 300,
|
||||
letterDelayMs = 10,
|
||||
}: {
|
||||
className?: string;
|
||||
startDelayMs?: number;
|
||||
letterDelayMs?: number;
|
||||
}) {
|
||||
const allowed = usePasscodeAllowed(SCOPE);
|
||||
const parts = [
|
||||
"I'm Haoqi Wen, leading Design Engineering and AI exploration at ",
|
||||
{
|
||||
length: BRAND_LEN,
|
||||
scramble: allowed ? BRAND : passcodeLockedPlaceholderText(),
|
||||
className: allowed ? undefined : PASSCODE_LOCKED_SCRAMBLE_CLASS,
|
||||
settled: <RevealLabelButton />,
|
||||
},
|
||||
", engineering, and AI at scale. Outside work, I build design tools for team efficiency.",
|
||||
];
|
||||
return (
|
||||
<ScrambleReveal
|
||||
className={className}
|
||||
parts={parts}
|
||||
startDelayMs={startDelayMs}
|
||||
letterDelayMs={letterDelayMs}
|
||||
/>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user