Files
virtheart 285028c61d feat: 北极新一中文个人站 — MiSans 分片字体 + 全站内容国内化
- 字体: cn-font-split 分片 MiSans(4字重×~88片, unicode-range 按需加载)
  接入 --font-sans/--font-mono/--font-mono-2 栈尾; 修复 next/font 与
  Tailwind @theme 变量重名导致的死规则(--font-geist-mono/--font-departure-mono)
- 内容: 品牌名/首屏/关于/导航/页脚/滚动段/文章页 UI/解锁屏全部中文化;
  元数据 title 北极新一©2026, lang=zh-CN; 日期中文格式
- 彩蛋: 品牌标签 TikTok→小红书(保留 char-code 混淆与口令机制), /2026
  文案改为个人创作手记语境
- 页脚: 邮箱 + 抖音/微信/小红书; 有链接项点击新开主页, 全部支持悬停
  二维码卡片(正方形白衬+object-contain 防变形); 无链接项(微信)点击弹
  二维码浮层
- 移除原作者手写签名动画(AboutMedia)
- 构建: cn-font-split devDependency + onlyBuiltDependencies 允许列表
2026-09-02 17:18:22 +08:00

104 lines
3.8 KiB
TypeScript

/**
* Passcode constants + pure helpers — ported from the original modules
* 58156 (paths/href) and 28116 (brand label) from d59f7a97fb1c563f.js,
* 国内化:品牌标签 TikTok → 小红书。
*
* The single passcode-protected scope is the 小红书 work entry (/2026).
* The brand label stays obfuscated as char codes minus one
* (same scheme as the original bundle).
*/
/** "小红书".charCodes + 1(与原站 TikTok 相同的混淆方案)。 */
const BRAND_CODES = [23568, 32419, 20071];
/** revealBrandLabel() — decodes to "小红书". */
export function revealBrandLabel(): string {
let out = "";
for (let i = 0; i < BRAND_CODES.length; i += 1) {
out += String.fromCharCode(BRAND_CODES[i] - 1);
}
return out;
}
/** revealBrandLabelLength() — 3. */
export function revealBrandLabelLength(): number {
return BRAND_CODES.length;
}
/** passcodeLockedPlaceholderText() — "■■■"(与品牌标签等宽)。 */
export function passcodeLockedPlaceholderText(): string {
return "■■■";
}
export const PASSCODE_LOCKED_CHAR_CLASS =
"inline-block min-w-[0.62em] text-center text-l1 tabular-nums select-text";
export const PASSCODE_LOCKED_SCRAMBLE_CLASS =
"inline-flex items-baseline gap-[0.12em] mx-[0.06em] select-text [&>span]:inline-block [&>span]:min-w-[0.62em] [&>span]:text-center [&>span]:tabular-nums";
/** Original module 58156 `y` — the unlock screen renders slotCount slots. */
export const PASSCODE = { slotCount: 4 } as const;
/** The work item hrefs guarded by the passcode (module 58156 `x`). */
export const PASSCODE_PROTECTED_PATHS: string[] = ["/2026"];
/** normalizePath (original `T`): trimmed path with a guaranteed leading "/". */
export function normalizePath(path: string): string {
const t = path.trim();
return t ? (t.startsWith("/") ? t : `/${t}`) : "/";
}
/** workHrefToPath (original module 83039 `v`): internal href only. */
export function workHrefToPath(href: string): string | null {
if (href.startsWith("http://") || href.startsWith("https://")) return null;
return normalizePath(href);
}
/**
* buildPasscodeUnlockHref (original `b`):
* "/2026", "/" → "/unlock/2026?return=%2F"
*/
export function buildPasscodeUnlockHref(scope: string, returnTo: string): string {
const safeReturn = sanitizePasscodeReturnTo(returnTo) ?? "/";
const seg = normalizePath(scope).slice(1) || "_";
return `/unlock/${encodeURIComponent(seg)}?return=${encodeURIComponent(safeReturn)}`;
}
/** scopeToPath (original `P`): decoded scope with a guaranteed leading "/". */
export function scopeToPath(scope: string): string {
const decoded = decodeURIComponent(scope);
return decoded.startsWith("/") ? decoded : `/${decoded}`;
}
/** isPasscodeProtectedPath (original `S`). */
export function isPasscodeProtectedPath(path: string): boolean {
const p = normalizePath(path);
return PASSCODE_PROTECTED_PATHS.includes(p);
}
/** emptyPasscodeAccessState (original `A`). */
export function emptyPasscodeAccessState(): Record<string, boolean> {
return Object.fromEntries(PASSCODE_PROTECTED_PATHS.map((p) => [p, false]));
}
/** primaryPasscodePath (original `w`): the first protected path. */
export function primaryPasscodePath(): string {
return PASSCODE_PROTECTED_PATHS[0] ?? "/2026";
}
/** sanitizePasscodeReturnTo (original `C`): same-origin relative path only. */
export function sanitizePasscodeReturnTo(returnTo?: string | null): string | null {
if (!returnTo) return null;
const t = returnTo.trim();
if (!t.startsWith("/") || t.startsWith("//")) return null;
return t;
}
/** Window event the access provider listens to (module 4278 `E`). */
export const PASSCODE_ACCESS_CHANGED_EVENT = "passcode-access-changed";
/** Shared cookie name for the access state (our API contract). */
export const PASSCODE_COOKIE_NAME = "hq-passcode-access";
export type PasscodeAccessState = Record<string, boolean>;