feat: 暗色主题 + /2026 详情页 + 逐页标题 — 对齐原站剩余缺口
- 暗色主题 1:1:ThemeModeProvider 原逻辑(localStorage 'theme' light/dark/system、system 跟随 prefers-color-scheme、<html> class 切换), CSS tokens 按原站 .dark 块翻值(--label/--background-deep/--code-*); shellMedia 重构为 useSyncExternalStore 单例 store(Header 与 Canvas 共享) - WebGL 主题分支:BackgroundFX 暗色渐变(#2c4bd5/#00000d/#00344C + outputMix .95/edgeIntensity -.82,原 sj 配置)、DotOverlay #0F1111、 LoadingCurtain #191b1b、玻璃模型暗色参数组(shininess 100/fresnel .72/ brightness .6/uDark=1 Hard-Light)与暗色 tint(hello #64c3ff、 footer #8e9dc4/#64c3ff) - /2026 路由:rewrite 补 2026(此前 404),workArticles 增加 /2026 占位文章 (原站内容被服务端口令保密无法读取,已注释说明);解锁屏→刷新→服务端 放行全链路 CDP 验证通过 - 逐页 <title>:app/work/[slug]/layout.tsx generateMetadata 映射作品名 (reunimos→Reunimos™),受保护 /2026 未解锁时 SSR 'Protected'(原站行为), 根标题改回原站 'HAOQI©2026'
This commit is contained in:
+43
-13
@@ -1,34 +1,40 @@
|
|||||||
@import "tailwindcss";
|
@import "tailwindcss";
|
||||||
|
|
||||||
|
/* Theme color indirection: utilities (text-l1, bg-b1, …) reference these
|
||||||
|
tokens, and the .dark block (below) flips their values — the same
|
||||||
|
light/dark token pairs the original stylesheet emits. */
|
||||||
@theme {
|
@theme {
|
||||||
--font-sans: var(--font-tiktok), sans-serif;
|
--font-sans: var(--font-tiktok), sans-serif;
|
||||||
--font-mono: var(--font-mono), monospace;
|
--font-mono: var(--font-mono), monospace;
|
||||||
--font-mono-2: var(--font-mono-2), monospace;
|
--font-mono-2: var(--font-mono-2), monospace;
|
||||||
|
|
||||||
--color-l1: rgba(0, 0, 0, 1);
|
--color-l1: var(--label-1);
|
||||||
--color-l2: rgba(54, 54, 48, 0.6);
|
--color-l2: var(--label-2);
|
||||||
--color-l3: rgba(54, 54, 48, 0.32);
|
--color-l3: var(--label-3);
|
||||||
--color-line: rgba(54, 54, 48, 0.1);
|
--color-line: var(--line);
|
||||||
--color-b1: rgb(251, 250, 244);
|
--color-b1: rgb(var(--background-deep));
|
||||||
--color-be: #efede7;
|
--color-be: var(--background-elevated);
|
||||||
--color-selection: #c0fe04;
|
--color-selection: #c0fe04;
|
||||||
}
|
}
|
||||||
|
|
||||||
:root {
|
:root {
|
||||||
--bg-color: rgb(251, 250, 244);
|
--bg-color: rgb(var(--background-deep));
|
||||||
--text-color: rgba(0, 0, 0, 1);
|
--text-color: var(--label-1);
|
||||||
--grid-dot: rgba(54, 54, 48, 0.1);
|
--grid-dot: var(--line);
|
||||||
--selection-bg: #c0fe04;
|
--selection-bg: #c0fe04;
|
||||||
|
|
||||||
/* Original label tokens (light theme): --label-1 = primary label,
|
/* Light theme tokens (chunk 635eb04122aa774f.css :root). */
|
||||||
--label-3 = tertiary label (link underline decoration color). */
|
|
||||||
--label: 0, 0, 0;
|
--label: 0, 0, 0;
|
||||||
--label-d: 54, 54, 48;
|
--label-d: 54, 54, 48;
|
||||||
|
--background-deep: 251, 250, 244;
|
||||||
|
--background-elevated: #efede7;
|
||||||
--label-1: rgba(var(--label), 1);
|
--label-1: rgba(var(--label), 1);
|
||||||
|
--label-2: rgba(var(--label-d), 0.6);
|
||||||
--label-3: rgba(var(--label-d), 0.32);
|
--label-3: rgba(var(--label-d), 0.32);
|
||||||
|
--label-4: rgba(var(--label-d), 0.18);
|
||||||
|
--line: rgba(var(--label-d), 0.1);
|
||||||
|
|
||||||
/* Original code token colors (light theme, chunk 635eb04122aa774f.css) —
|
/* Original code token colors (light theme). */
|
||||||
the MDX CodeBlock maps prism token types to these vars. */
|
|
||||||
--code-comment: rgba(var(--label-d), 0.45);
|
--code-comment: rgba(var(--label-d), 0.45);
|
||||||
--code-string: lab(43.8263% -47.6118 18.596);
|
--code-string: lab(43.8263% -47.6118 18.596);
|
||||||
--code-number: lab(46.7992% 8.99872 72.9973);
|
--code-number: lab(46.7992% 8.99872 72.9973);
|
||||||
@@ -38,6 +44,30 @@
|
|||||||
--code-operator: rgba(var(--label-d), 0.75);
|
--code-operator: rgba(var(--label-d), 0.75);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Dark theme (original .dark block: ThemeModeProvider adds the class to
|
||||||
|
<html>; localStorage "theme" ∈ light|dark|system, system follows
|
||||||
|
prefers-color-scheme). */
|
||||||
|
.dark {
|
||||||
|
color-scheme: dark;
|
||||||
|
--label: 255, 255, 255;
|
||||||
|
--label-d: 230, 232, 232;
|
||||||
|
--background-deep: 15, 17, 17;
|
||||||
|
--background-elevated: #191b1b;
|
||||||
|
--label-1: rgba(var(--label), 1);
|
||||||
|
--label-2: rgba(var(--label-d), 0.6);
|
||||||
|
--label-3: rgba(var(--label-d), 0.32);
|
||||||
|
--label-4: rgba(var(--label-d), 0.16);
|
||||||
|
--line: rgba(var(--label-d), 0.08);
|
||||||
|
|
||||||
|
--code-comment: rgba(var(--label-d), 0.5);
|
||||||
|
--code-string: lab(80.5863% -36.0539 14.2351);
|
||||||
|
--code-number: lab(81.7507% 5.58251 51.1676);
|
||||||
|
--code-keyword: lab(74.3615% 26.3244 -70.4223);
|
||||||
|
--code-function: lab(78.8788% -11.9607 -42.8116);
|
||||||
|
--code-tag: lab(76.4079% 47.9123 21.2271);
|
||||||
|
--code-operator: rgba(var(--label-d), 0.85);
|
||||||
|
}
|
||||||
|
|
||||||
/* Background lives on the ROOT only — per CSS painting it propagates to the
|
/* Background lives on the ROOT only — per CSS painting it propagates to the
|
||||||
canvas backdrop, so it stays BEHIND the original's -z-1 fixed WebGL host.
|
canvas backdrop, so it stays BEHIND the original's -z-1 fixed WebGL host.
|
||||||
A body-level background would paint as normal-flow content and cover the
|
A body-level background would paint as normal-flow content and cover the
|
||||||
|
|||||||
+3
-1
@@ -31,7 +31,9 @@ const departureMono = localFont({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
title: "HAOQI©2026 - Clone",
|
// Original home title (index.html): HAOQI©2026. Detail pages override via
|
||||||
|
// generateMetadata in app/work/[slug]/layout.tsx (original: per-page title).
|
||||||
|
title: "HAOQI©2026",
|
||||||
description: "Digital Product Designer & Builder © 2026",
|
description: "Digital Product Designer & Builder © 2026",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
import type { Metadata } from "next";
|
||||||
|
import { WORK_ARTICLES } from "@/content/workArticles";
|
||||||
|
import { isPasscodeProtectedPath } from "@/lib/passcode";
|
||||||
|
import { getPasscodeAccessServer } from "@/lib/passcodeServer";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Per-page <title>: the original detail route sets <title> to the work name
|
||||||
|
* (haoqi.design/reunimos → "Reunimos™"). The protected /2026 is gated on the
|
||||||
|
* server — without the access cookie its SSR title is "Protected"; once
|
||||||
|
* unlocked the server renders the article. We mirror both states. Lives in a
|
||||||
|
* segment layout so `params` contains the slug for both /work/[slug] and its
|
||||||
|
* root rewrite.
|
||||||
|
*/
|
||||||
|
export async function generateMetadata({
|
||||||
|
params,
|
||||||
|
}: {
|
||||||
|
params: Promise<{ slug: string }>;
|
||||||
|
}): Promise<Metadata> {
|
||||||
|
const { slug } = await params;
|
||||||
|
const path = `/${slug}`;
|
||||||
|
if (isPasscodeProtectedPath(path)) {
|
||||||
|
const access = await getPasscodeAccessServer();
|
||||||
|
if (!access[path]) return { title: "Protected" };
|
||||||
|
}
|
||||||
|
const article = WORK_ARTICLES[path];
|
||||||
|
return { title: article ? article.title : "HAOQI©2026" };
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function WorkLayout({
|
||||||
|
children,
|
||||||
|
}: Readonly<{ children: React.ReactNode }>) {
|
||||||
|
return children;
|
||||||
|
}
|
||||||
@@ -19,6 +19,7 @@ import {
|
|||||||
} from "three";
|
} from "three";
|
||||||
import { usePointer } from "@/lib/pointer";
|
import { usePointer } from "@/lib/pointer";
|
||||||
import { scrollBus } from "@/lib/scrollBus";
|
import { scrollBus } from "@/lib/scrollBus";
|
||||||
|
import { useResolvedTheme } from "@/lib/shellMedia";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Animated background — 1:1 port of the original `sz` + `sV` + `s$`
|
* Animated background — 1:1 port of the original `sz` + `sV` + `s$`
|
||||||
@@ -39,6 +40,11 @@ import { scrollBus } from "@/lib/scrollBus";
|
|||||||
const BG_COLOR = "#ffead6";
|
const BG_COLOR = "#ffead6";
|
||||||
const VIGNETTE_COLOR = "#6196ff";
|
const VIGNETTE_COLOR = "#6196ff";
|
||||||
const OUTPUT_COLOR = "#acffb9";
|
const OUTPUT_COLOR = "#acffb9";
|
||||||
|
// Dark branch (original sL/sH/s_ + sj.dark): deep blue bg, near-black
|
||||||
|
// vignette, teal output; stronger output mix, much stronger edge falloff.
|
||||||
|
const DARK_BG_COLOR = "#2c4bd5";
|
||||||
|
const DARK_VIGNETTE_COLOR = "#00000d";
|
||||||
|
const DARK_OUTPUT_COLOR = "#00344C";
|
||||||
const OUTPUT_MIX = 0.65;
|
const OUTPUT_MIX = 0.65;
|
||||||
const MOUSE_POS = new Vector2(0.5, -0.1);
|
const MOUSE_POS = new Vector2(0.5, -0.1);
|
||||||
const CENTER = new Vector2(0.5, 0.5);
|
const CENTER = new Vector2(0.5, 0.5);
|
||||||
@@ -548,9 +554,32 @@ export function BackgroundFX() {
|
|||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
|
|
||||||
const bgColor = useMemo(() => toVec3(BG_COLOR), []);
|
const isDark = useResolvedTheme() === "dark";
|
||||||
const vignetteColor = useMemo(() => toVec3(VIGNETTE_COLOR), []);
|
// sj: light {outputMix:.65, edgeIntensity:-.16} / dark {outputMix:.95,
|
||||||
const outputColor = useMemo(() => toVec3(OUTPUT_COLOR), []);
|
// edgeIntensity:-.82} — swapped on theme flip (original sz reads
|
||||||
|
// resolvedTheme and re-seeds the uniforms per branch).
|
||||||
|
const bgColor = useMemo(() => toVec3(isDark ? DARK_BG_COLOR : BG_COLOR), [isDark]);
|
||||||
|
const vignetteColor = useMemo(
|
||||||
|
() => toVec3(isDark ? DARK_VIGNETTE_COLOR : VIGNETTE_COLOR),
|
||||||
|
[isDark]
|
||||||
|
);
|
||||||
|
const outputColor = useMemo(
|
||||||
|
() => toVec3(isDark ? DARK_OUTPUT_COLOR : OUTPUT_COLOR),
|
||||||
|
[isDark]
|
||||||
|
);
|
||||||
|
|
||||||
|
// sj dark branch values + clear color: keep the RT clear in sync so the
|
||||||
|
// first pre-pass composites over the right base after a theme flip.
|
||||||
|
useEffect(() => {
|
||||||
|
materials.outputMaterial.uniforms.uOutputMix.value = isDark ? 0.95 : 0.65;
|
||||||
|
materials.vignetteMaterial.uniforms.uEdgeIntensity.value = isDark
|
||||||
|
? -0.82
|
||||||
|
: -0.16;
|
||||||
|
gl.setClearColor(new Color(isDark ? DARK_BG_COLOR : BG_COLOR), 1);
|
||||||
|
gl.setRenderTarget(rtsRef.current.read);
|
||||||
|
gl.clear();
|
||||||
|
gl.setRenderTarget(null);
|
||||||
|
}, [isDark, materials, gl]);
|
||||||
|
|
||||||
// Internal ortho scene for pre-passes (original v/A + first-pass mesh).
|
// Internal ortho scene for pre-passes (original v/A + first-pass mesh).
|
||||||
const preScene = useMemo(() => new Scene(), []);
|
const preScene = useMemo(() => new Scene(), []);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { useLayoutEffect, useMemo, useRef } from "react";
|
|||||||
import { useFrame, useThree } from "@react-three/fiber";
|
import { useFrame, useThree } from "@react-three/fiber";
|
||||||
import { Color, Vector2 } from "three";
|
import { Color, Vector2 } from "three";
|
||||||
import { scrollBus } from "@/lib/scrollBus";
|
import { scrollBus } from "@/lib/scrollBus";
|
||||||
|
import { useResolvedTheme } from "@/lib/shellMedia";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scroll dot-overlay — 1:1 port of the original `s1` (chunk
|
* Scroll dot-overlay — 1:1 port of the original `s1` (chunk
|
||||||
@@ -30,8 +31,8 @@ function sT(e?: number): number {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function DotOverlay() {
|
export function DotOverlay() {
|
||||||
// Light-only theme (original: resolvedTheme from useThemeMode).
|
// Original: resolvedTheme from useThemeMode (s1 picks e[0] dark / e[1] light).
|
||||||
const isDark = false;
|
const isDark = useResolvedTheme() === "dark";
|
||||||
const size = useThree((s) => s.size);
|
const size = useThree((s) => s.size);
|
||||||
const materialRef = useRef<any>(null);
|
const materialRef = useRef<any>(null);
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { mergeGeometries } from "three/examples/jsm/utils/BufferGeometryUtils.js
|
|||||||
import { scrollBus } from "@/lib/scrollBus";
|
import { scrollBus } from "@/lib/scrollBus";
|
||||||
import { usePointer } from "@/lib/pointer";
|
import { usePointer } from "@/lib/pointer";
|
||||||
import { loadingBus } from "@/lib/loadingBus";
|
import { loadingBus } from "@/lib/loadingBus";
|
||||||
|
import { useResolvedTheme } from "@/lib/shellMedia";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Glass models for the hero section, reverse-engineered 1:1 from the
|
* Glass models for the hero section, reverse-engineered 1:1 from the
|
||||||
@@ -259,6 +260,25 @@ const LIGHT_PARAMS = {
|
|||||||
lightZ: 0.5,
|
lightZ: 0.5,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Dark-theme branch of the same cloned controls (original dark* control
|
||||||
|
// values): the glass switches to Hard-Light duotone mixing (uDark 1) with a
|
||||||
|
// different highlight/fresnel response.
|
||||||
|
const DARK_PARAMS = {
|
||||||
|
shininess: 100,
|
||||||
|
diffuseness: 0.05,
|
||||||
|
fresnelPower: 3,
|
||||||
|
fresnelStrength: 0.72,
|
||||||
|
brightness: 0.6,
|
||||||
|
contrast: 0.98,
|
||||||
|
gamma: 1,
|
||||||
|
saturation: 1.2,
|
||||||
|
tintMix: 1,
|
||||||
|
tintThicknessMinAlpha: 1,
|
||||||
|
tintThicknessMaxAlpha: 0.4,
|
||||||
|
tintColorA: "#64c3ff",
|
||||||
|
tintColorB: "#8e9dc4",
|
||||||
|
};
|
||||||
|
|
||||||
// Default uniforms from the bundle's uniform factory
|
// Default uniforms from the bundle's uniform factory
|
||||||
const IOR = { R: 1.15, Y: 1.16, G: 1.18, C: 1.22, B: 1.22, P: 1.22 };
|
const IOR = { R: 1.15, Y: 1.16, G: 1.18, C: 1.22, B: 1.22, P: 1.22 };
|
||||||
|
|
||||||
@@ -495,6 +515,35 @@ function GlassModel({
|
|||||||
uniforms.uTintLocalYRange.value.set(tintYRange[0], tintYRange[1]);
|
uniforms.uTintLocalYRange.value.set(tintYRange[0], tintYRange[1]);
|
||||||
}, [tintYRange, uniforms]);
|
}, [tintYRange, uniforms]);
|
||||||
|
|
||||||
|
// Theme branch (original cf(controls, theme) + E useMemo): swap the
|
||||||
|
// highlight/fresnel response and tint colors when the resolved theme
|
||||||
|
// flips. Per-model tingColor overrides: m[0]/m[1] light A/B,
|
||||||
|
// m[2]/m[3] dark A/B, missing entries fall back to the theme defaults.
|
||||||
|
const isDark = useResolvedTheme() === "dark";
|
||||||
|
useEffect(() => {
|
||||||
|
const P = isDark ? DARK_PARAMS : LIGHT_PARAMS;
|
||||||
|
uniforms.uShininess.value = P.shininess;
|
||||||
|
uniforms.uDiffuseness.value = P.diffuseness;
|
||||||
|
uniforms.uFresnelPower.value = P.fresnelPower;
|
||||||
|
uniforms.uFresnelStrength.value = P.fresnelStrength;
|
||||||
|
uniforms.uBrightness.value = P.brightness;
|
||||||
|
uniforms.uContrast.value = P.contrast;
|
||||||
|
uniforms.uGamma.value = P.gamma;
|
||||||
|
uniforms.uSaturation.value = P.saturation;
|
||||||
|
uniforms.uTintMix.value = P.tintMix;
|
||||||
|
uniforms.uTintThicknessMinAlpha.value = P.tintThicknessMinAlpha;
|
||||||
|
uniforms.uTintThicknessMaxAlpha.value = P.tintThicknessMaxAlpha;
|
||||||
|
const tintA = isDark
|
||||||
|
? (tintColors?.[2] ?? DARK_PARAMS.tintColorA)
|
||||||
|
: (tintColors?.[0] ?? LIGHT_PARAMS.tintColorA);
|
||||||
|
const tintB = isDark
|
||||||
|
? (tintColors?.[3] ?? DARK_PARAMS.tintColorB)
|
||||||
|
: (tintColors?.[1] ?? LIGHT_PARAMS.tintColorB);
|
||||||
|
uniforms.uTintColorA.value.copy(hexToVec4(tintA));
|
||||||
|
uniforms.uTintColorB.value.copy(hexToVec4(tintB));
|
||||||
|
uniforms.uDark.value = isDark ? 1 : 0;
|
||||||
|
}, [isDark, tintColors, uniforms]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const drawingBufferSize = gl.getDrawingBufferSize(new THREE.Vector2());
|
const drawingBufferSize = gl.getDrawingBufferSize(new THREE.Vector2());
|
||||||
uniforms.uScreenResolutionPx.value.set(
|
uniforms.uScreenResolutionPx.value.set(
|
||||||
@@ -675,9 +724,9 @@ export function CursorStar({ isMobile = false }: { isMobile?: boolean }) {
|
|||||||
afterRotation={[0, 720, 0]}
|
afterRotation={[0, 720, 0]}
|
||||||
rotation={[0, 0, 0]}
|
rotation={[0, 0, 0]}
|
||||||
scale={0.1}
|
scale={0.1}
|
||||||
// Original tingColor light theme: tint A and B are BOTH #009dff
|
// Original tingColor: light m[0]/m[1] both #009dff, dark m[2]/m[3]
|
||||||
// (m[0]/m[1]); #64c3ff (m[2]/m[3]) is the dark-theme value.
|
// both #64c3ff.
|
||||||
tintColors={["#009dff", "#009dff"]}
|
tintColors={["#009dff", "#009dff", "#64c3ff", "#64c3ff"]}
|
||||||
tintEnabled
|
tintEnabled
|
||||||
isMobile={isMobile}
|
isMobile={isMobile}
|
||||||
scrollSyncFactor={0.72}
|
scrollSyncFactor={0.72}
|
||||||
@@ -714,7 +763,7 @@ export function FooterModel() {
|
|||||||
beforeRotation={[-180, 0, 0]}
|
beforeRotation={[-180, 0, 0]}
|
||||||
rotation={[0, 0, 0]}
|
rotation={[0, 0, 0]}
|
||||||
scale={19}
|
scale={19}
|
||||||
tintColors={["#FFFFFF", "#009dff"]}
|
tintColors={["#FFFFFF", "#009dff", "#8e9dc4", "#64c3ff"]}
|
||||||
tintEnabled
|
tintEnabled
|
||||||
sectionTopDocY={geom.top}
|
sectionTopDocY={geom.top}
|
||||||
sectionHeightPx={geom.height}
|
sectionHeightPx={geom.height}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { Canvas, useFrame, useThree } from "@react-three/fiber";
|
|||||||
import { Color, MathUtils, UnsignedByteType } from "three";
|
import { Color, MathUtils, UnsignedByteType } from "three";
|
||||||
import { Effect, BlendFunction } from "postprocessing";
|
import { Effect, BlendFunction } from "postprocessing";
|
||||||
import { EffectComposer } from "@react-three/postprocessing";
|
import { EffectComposer } from "@react-three/postprocessing";
|
||||||
|
import { useResolvedTheme } from "@/lib/shellMedia";
|
||||||
import { customCubic } from "@/lib/customCubic";
|
import { customCubic } from "@/lib/customCubic";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -253,8 +254,9 @@ function RadialHoleMask({
|
|||||||
const { size } = useThree();
|
const { size } = useThree();
|
||||||
const invalidate = useThree((s) => s.invalidate);
|
const invalidate = useThree((s) => s.invalidate);
|
||||||
|
|
||||||
// Light theme picks f[1] (#efede7).
|
// Original f(p): dark picks f[0] (#191b1b), light picks f[1] (#efede7).
|
||||||
const color = CURTAIN_COLORS[1];
|
const isDark = useResolvedTheme() === "dark";
|
||||||
|
const color = isDark ? CURTAIN_COLORS[0] : CURTAIN_COLORS[1];
|
||||||
|
|
||||||
const uniforms = useMemo(
|
const uniforms = useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
|
|||||||
@@ -273,4 +273,18 @@ export const WORK_ARTICLES: Record<string, WorkArticle> = {
|
|||||||
{ type: "p", segs: [{ t: "link", v: "teambition.com", href: "https://www.teambition.com/" }] },
|
{ type: "p", segs: [{ t: "link", v: "teambition.com", href: "https://www.teambition.com/" }] },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
// /2026 — the passcode-protected TikTok post. The original article body is
|
||||||
|
// server-gated behind the site's secret passcode and therefore unreadable;
|
||||||
|
// this is stand-in content in the same structure (swap in real copy if it
|
||||||
|
// ever becomes available).
|
||||||
|
"/2026": {
|
||||||
|
title: "TikTok",
|
||||||
|
date: "May 31, 2026",
|
||||||
|
year: "2022-2026",
|
||||||
|
iframe: null,
|
||||||
|
blocks: [
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "This article is passcode-protected on the original site, so its content could not be cloned. What is known from the public bundle: it is a post dated 2022-2026 about design engineering and AI exploration work, protected behind the 4-digit passcode flow." }] },
|
||||||
|
{ type: "p", segs: [{ t: "text", v: "Everything around it — the card, the locked brand label, the unlock screen, and this route — is reproduced 1:1. Unlock with the clone's passcode (default 2026, override with PASSCODE_CODE) to read this page like on the original." }] },
|
||||||
|
],
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
+150
-43
@@ -1,20 +1,76 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useCallback, useEffect, useState } from "react";
|
import { useCallback, useSyncExternalStore } from "react";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shell media state (theme + sound) — mirrors the original useShellMedia /
|
* Shell media state (theme + sound) — 1:1 port of the original
|
||||||
* useThemeMode contract: theme ∈ {light, dark, system}, persisted to
|
* ThemeModeProvider (chunk 2689132c4e070b68.js module 90975) + ShellMedia
|
||||||
* localStorage; soundEnabled persisted likewise (original keys
|
* sound store (module 23525):
|
||||||
* "hq-theme" / "hq-sound"; namespaced here). The THEME cycle is
|
*
|
||||||
* light → dark → system, keyboard [L]/[D]/[A] shortcuts live in the
|
* - theme ∈ {light, dark, system}, persisted to localStorage "theme"
|
||||||
* header component (original ASCIIThemeToggle behavior).
|
* (original key, kept verbatim for parity); default "light".
|
||||||
|
* - resolvedTheme = theme === "system"
|
||||||
|
* ? (matchMedia("(prefers-color-scheme: dark)").matches ? dark : light)
|
||||||
|
* : theme;
|
||||||
|
* <html> gets BOTH the resolved class (light/dark) and the setting, so
|
||||||
|
* CSS tokens flip via the .dark block in globals.css.
|
||||||
|
* - "system" follows OS changes live (original matchMedia change listener).
|
||||||
|
* - soundEnabled persisted to localStorage "sound" ("on"/"off", original
|
||||||
|
* keys).
|
||||||
|
*
|
||||||
|
* Implemented as a module-singleton external store (useSyncExternalStore)
|
||||||
|
* instead of the original context: the header and the canvas components
|
||||||
|
* (DotOverlay, LoadingCurtain, GlassModels) live in different trees and the
|
||||||
|
* canvas reads theme without re-mounting.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export type ThemeSetting = "light" | "dark" | "system";
|
export type ThemeSetting = "light" | "dark" | "system";
|
||||||
|
export type ResolvedTheme = "light" | "dark";
|
||||||
|
|
||||||
const THEME_KEY = "vh-theme";
|
const THEME_KEY = "theme";
|
||||||
const SOUND_KEY = "vh-sound";
|
const SOUND_KEY = "sound";
|
||||||
|
const SETTINGS: ThemeSetting[] = ["light", "dark", "system"];
|
||||||
|
|
||||||
|
type ShellMediaState = {
|
||||||
|
theme: ThemeSetting;
|
||||||
|
resolvedTheme: ResolvedTheme;
|
||||||
|
soundEnabled: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
let state: ShellMediaState = {
|
||||||
|
theme: "light",
|
||||||
|
resolvedTheme: "light",
|
||||||
|
soundEnabled: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
const listeners = new Set<() => void>();
|
||||||
|
let hydrated = false;
|
||||||
|
let mediaQuery: MediaQueryList | null = null;
|
||||||
|
|
||||||
|
function emit() {
|
||||||
|
for (const l of listeners) l();
|
||||||
|
}
|
||||||
|
|
||||||
|
function setState(patch: Partial<ShellMediaState>) {
|
||||||
|
state = { ...state, ...patch };
|
||||||
|
emit();
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolve(theme: ThemeSetting): ResolvedTheme {
|
||||||
|
if (theme !== "system") return theme;
|
||||||
|
return window.matchMedia("(prefers-color-scheme: dark)").matches
|
||||||
|
? "dark"
|
||||||
|
: "light";
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Mirror the resolved theme onto <html> (original: classList + remove/add). */
|
||||||
|
function applyDocument(theme: ThemeSetting) {
|
||||||
|
const el = document.documentElement;
|
||||||
|
const resolved = resolve(theme);
|
||||||
|
el.classList.remove("light", "dark");
|
||||||
|
el.classList.add(resolved);
|
||||||
|
el.dataset.themeSetting = theme;
|
||||||
|
}
|
||||||
|
|
||||||
function readStored(key: string): string | null {
|
function readStored(key: string): string | null {
|
||||||
try {
|
try {
|
||||||
@@ -24,44 +80,95 @@ function readStored(key: string): string | null {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useShellMedia() {
|
function writeStored(key: string, value: string) {
|
||||||
const [theme, setThemeState] = useState<ThemeSetting>("light");
|
|
||||||
const [soundEnabled, setSoundEnabledState] = useState(false);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const t = readStored(THEME_KEY);
|
|
||||||
if (t === "light" || t === "dark" || t === "system") setThemeState(t);
|
|
||||||
setSoundEnabledState(readStored(SOUND_KEY) === "1");
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
// Theme is light-only in this port: system/dark resolve to light.
|
|
||||||
useEffect(() => {
|
|
||||||
document.documentElement.dataset.themeSetting = theme;
|
|
||||||
}, [theme]);
|
|
||||||
|
|
||||||
const setTheme = useCallback((next: ThemeSetting) => {
|
|
||||||
setThemeState(next);
|
|
||||||
try {
|
try {
|
||||||
window.localStorage.setItem(THEME_KEY, next);
|
window.localStorage.setItem(key, value);
|
||||||
} catch {}
|
} catch {}
|
||||||
}, []);
|
}
|
||||||
|
|
||||||
const setSoundEnabled = useCallback((next: boolean) => {
|
function hydrate() {
|
||||||
setSoundEnabledState(next);
|
if (hydrated || typeof window === "undefined") return;
|
||||||
try {
|
hydrated = true;
|
||||||
window.localStorage.setItem(SOUND_KEY, next ? "1" : "0");
|
const stored = readStored(THEME_KEY);
|
||||||
} catch {}
|
const theme: ThemeSetting = SETTINGS.includes(stored as ThemeSetting)
|
||||||
}, []);
|
? (stored as ThemeSetting)
|
||||||
|
: "light";
|
||||||
|
mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
||||||
|
mediaQuery.addEventListener("change", onSystemChange);
|
||||||
|
state = { ...state, theme, resolvedTheme: resolve(theme) };
|
||||||
|
applyDocument(theme);
|
||||||
|
state = {
|
||||||
|
...state,
|
||||||
|
soundEnabled: readStored(SOUND_KEY) === "on",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return { theme, setTheme, soundEnabled, setSoundEnabled };
|
function onSystemChange() {
|
||||||
|
if (state.theme !== "system") return;
|
||||||
|
const resolved = resolve("system");
|
||||||
|
applyDocument("system");
|
||||||
|
setState({ resolvedTheme: resolved });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof window !== "undefined") {
|
||||||
|
// SSR-safe: hydrate on the first client access (module evaluation happens
|
||||||
|
// before first paint for the header, matching the original effect timing
|
||||||
|
// closely enough that no flash is observable).
|
||||||
|
hydrate();
|
||||||
|
}
|
||||||
|
|
||||||
|
function setTheme(next: ThemeSetting) {
|
||||||
|
writeStored(THEME_KEY, next);
|
||||||
|
applyDocument(next);
|
||||||
|
setState({ theme: next, resolvedTheme: resolve(next) });
|
||||||
|
}
|
||||||
|
|
||||||
|
function setSoundEnabled(next: boolean) {
|
||||||
|
writeStored(SOUND_KEY, next ? "on" : "off");
|
||||||
|
setState({ soundEnabled: next });
|
||||||
|
}
|
||||||
|
|
||||||
|
function subscribe(listener: () => void) {
|
||||||
|
listeners.add(listener);
|
||||||
|
return () => listeners.delete(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
const getSnapshot = () => state;
|
||||||
|
|
||||||
|
export function useShellMedia(): ShellMediaState & {
|
||||||
|
setTheme: (next: ThemeSetting) => void;
|
||||||
|
setSoundEnabled: (next: boolean) => void;
|
||||||
|
} {
|
||||||
|
const snapshot = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
||||||
|
// Stable identity via module-level functions (no per-render closures).
|
||||||
|
return useSnapshotWithActions(snapshot);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Keep the actions on the same object shape as the original hook return.
|
||||||
|
function useSnapshotWithActions(
|
||||||
|
snapshot: ShellMediaState
|
||||||
|
): ShellMediaState & {
|
||||||
|
setTheme: (next: ThemeSetting) => void;
|
||||||
|
setSoundEnabled: (next: boolean) => void;
|
||||||
|
} {
|
||||||
|
return {
|
||||||
|
...snapshot,
|
||||||
|
setTheme,
|
||||||
|
setSoundEnabled,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getResolvedTheme(): ResolvedTheme {
|
||||||
|
return state.resolvedTheme;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function subscribeShellMedia(listener: () => void) {
|
||||||
|
return subscribe(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useResolvedTheme(): ResolvedTheme {
|
||||||
|
const s = useShellMedia();
|
||||||
|
return s.resolvedTheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ShellMedia = ReturnType<typeof useShellMedia>;
|
export type ShellMedia = ReturnType<typeof useShellMedia>;
|
||||||
|
|
||||||
let contextValue: ShellMedia | null = null;
|
|
||||||
|
|
||||||
/** Module-singleton variant (no provider tree needed for this port). */
|
|
||||||
export function useShellMediaSingleton(): ShellMedia {
|
|
||||||
const own = useShellMedia();
|
|
||||||
return contextValue ?? own;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ const WORK_SLUGS = [
|
|||||||
"adrive",
|
"adrive",
|
||||||
"shore_icon",
|
"shore_icon",
|
||||||
"teambition",
|
"teambition",
|
||||||
|
// The passcode-protected TikTok post (original: haoqi.design/2026).
|
||||||
|
"2026",
|
||||||
];
|
];
|
||||||
|
|
||||||
const nextConfig: NextConfig = {
|
const nextConfig: NextConfig = {
|
||||||
|
|||||||
Reference in New Issue
Block a user