feat: 服务页双栏布局 + 滑块验证码 v2(图片化挑战/行为校验/限流/蜜罐)
服务页(/services): - lg+ 双栏:左列服务菜单(NO.01-07,点击选中)、右列表单 (sticky 跟随);移动端保持上下堆叠 滑块验证码 v2(防机械脚本): - 答案坐标不再下发:缺口位置由服务端烘进 PNG(lib/captchaImage 自绘点阵底图 + 拼块裁片,lib/pngEncoder 纯 TS PNG 编码器, node:zlib 零依赖),脚本必须做图像识别才能定位 - 行为轨迹校验:拖动采样提交服务端,样本数 ≥6、总时长 ≥1.2s、 单调时间戳、峰值速度 > 平均×1.8(匀速直线 = 拒)、末点 ≈ 答案 - 位置容差 ±10px;失败 5 次作废;挑战 10 分钟过期 - IP 指纹(哈希)限流:challenge 15/10min、verify 30/10min、 咨询提交 3/小时;蜜罐字段(website)命中静默丢弃 端到端:无轨迹/匀速直线/超短时长均拒;真人节奏通过;重放拦截; 蜜罐丢弃;第 14 次刷 challenge 起 429;SMTP 真发正常。
This commit is contained in:
@@ -1,42 +1,28 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState, useSyncExternalStore } from "react";
|
||||
import { usePathname } from "next/navigation";
|
||||
import { useEffect, useSyncExternalStore } from "react";
|
||||
import { loadingBus } from "@/lib/loadingBus";
|
||||
import LoadingCurtain from "@/components/canvas/LoadingCurtain";
|
||||
|
||||
/**
|
||||
* Heavy-load hooks (formerly the entry LoadingOverlay). The entry/route
|
||||
* curtain orchestration now lives in RouteTransitionOverlay (the original
|
||||
* module 34841 drives BOTH flows from one pinhole curtain); this file keeps
|
||||
* only the readiness plumbing other components consume.
|
||||
*/
|
||||
|
||||
/** Stable server snapshot (must be cached — a fresh object would loop). */
|
||||
const SERVER_SNAPSHOT = { progress: 0, ready: false };
|
||||
|
||||
function useHeavyLoad() {
|
||||
export function useHeavyLoad() {
|
||||
return useSyncExternalStore(
|
||||
loadingBus.subscribe,
|
||||
loadingBus.getSnapshot,
|
||||
loadingBusSubscribe,
|
||||
loadingBusGetSnapshot,
|
||||
() => SERVER_SNAPSHOT
|
||||
);
|
||||
}
|
||||
|
||||
function useFontsReady() {
|
||||
const [fontsReady, setFontsReady] = useState(false);
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
const fonts = (document as any).fonts;
|
||||
if (!fonts) {
|
||||
setFontsReady(true);
|
||||
return;
|
||||
}
|
||||
fonts.ready.then(() => {
|
||||
if (!cancelled) setFontsReady(true);
|
||||
});
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, []);
|
||||
return fontsReady;
|
||||
}
|
||||
|
||||
const clamp = (v: number, min: number, max: number) =>
|
||||
Math.min(max, Math.max(min, v));
|
||||
const loadingBusSubscribe = loadingBus.subscribe;
|
||||
const loadingBusGetSnapshot = loadingBus.getSnapshot;
|
||||
|
||||
/**
|
||||
* Heavy-asset readiness for the camera intro dolly (original cV's `p`:
|
||||
@@ -53,91 +39,3 @@ export function useAppReady(): boolean {
|
||||
|
||||
return heavy.ready;
|
||||
}
|
||||
|
||||
/**
|
||||
* Entry loading flow — port of the original route-transition controller
|
||||
* (module 34841) for the entry case on "/":
|
||||
*
|
||||
* 1. entry:wait — curtain fully closed (initialProgress 1), centered
|
||||
* 140px bar shows 50%·fontsReady + 50%·heavyLoadProgress.
|
||||
* 2. readyToLoadHeavy && fontsReady → hold 250ms → bar fades (250ms)
|
||||
* → 250ms later the curtain opens (0.8s customCubic radial hole +
|
||||
* dot mask) — reveal phase.
|
||||
* 3. Curtain reveal completes (+0.9s grace) → idle: unmount everything.
|
||||
*/
|
||||
export function LoadingOverlay() {
|
||||
const heavy = useHeavyLoad();
|
||||
const fontsReady = useFontsReady();
|
||||
// Original useHomeLoadingGate: the entry curtain is a "/"-only flow —
|
||||
// detail routes render with no loading curtain at all.
|
||||
const pathname = usePathname();
|
||||
|
||||
// wait → fading → reveal → (unmount when reveal completes)
|
||||
const [phase, setPhase] = useState<"wait" | "fading" | "reveal">("wait");
|
||||
const [mounted, setMounted] = useState(true);
|
||||
|
||||
const progress = Math.round(clamp(50 * +fontsReady + heavy.progress / 2, 0, 100));
|
||||
const assetsDone = heavy.ready && fontsReady;
|
||||
|
||||
useEffect(() => {
|
||||
if (!assetsDone || phase !== "wait") return;
|
||||
// Original: 250ms hold → fade the bar → 250ms later open the curtain.
|
||||
const t1 = window.setTimeout(() => setPhase("fading"), 250);
|
||||
return () => window.clearTimeout(t1);
|
||||
}, [assetsDone, phase]);
|
||||
|
||||
useEffect(() => {
|
||||
if (phase !== "fading") return;
|
||||
const t2 = window.setTimeout(() => setPhase("reveal"), 250);
|
||||
return () => window.clearTimeout(t2);
|
||||
}, [phase]);
|
||||
|
||||
if (!mounted || pathname !== "/") return null;
|
||||
|
||||
return (
|
||||
<>
|
||||
<LoadingCurtain
|
||||
open={phase === "reveal"}
|
||||
duration={0.8}
|
||||
initialProgress={1}
|
||||
resetKey={`entry:${phase}`}
|
||||
onComplete={(open) => {
|
||||
if (open) {
|
||||
// Reveal finished — a beat later the curtain canvas unmounts.
|
||||
window.setTimeout(() => setMounted(false), 900);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
{phase !== "reveal" && (
|
||||
<ProgressBar progress={progress} fading={phase === "fading"} />
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
/** Centered 140px progress bar (original `b`). */
|
||||
function ProgressBar({ progress, fading }: { progress: number; fading: boolean }) {
|
||||
const clamped = clamp(progress, 0, 100);
|
||||
return (
|
||||
<div
|
||||
aria-hidden="true"
|
||||
className={`left-1/2 top-1/2 z-40 fixed flex h-4 w-[140px] -translate-x-1/2 -translate-y-1/2 items-center justify-center pointer-events-none ${
|
||||
fading ? "opacity-0" : "opacity-100"
|
||||
}`}
|
||||
style={{ transition: "opacity 250ms cubic-bezier(0.25, 1, 0.5, 1)" }}
|
||||
>
|
||||
<div className="relative h-1.5 w-full overflow-hidden rounded-full bg-l3">
|
||||
<div
|
||||
className="absolute inset-y-0 left-0 rounded-full bg-l1"
|
||||
style={{
|
||||
width: `${clamped}%`,
|
||||
transition: "width 520ms cubic-bezier(0.22, 1, 0.36, 1)",
|
||||
willChange: "width",
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default LoadingOverlay;
|
||||
|
||||
Reference in New Issue
Block a user