LoginCoverage.tsx 17 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402
/*
 * @Author: liimin 17653212@qq.com
 * @Date: 2026-11-13 10:00:00
 * @LastEditors: liimin 17653212@qq.com
 * @LastEditTime: 2026-11-15 19:03:00
 * @FilePath: \uj-store\src\pages\Login\components\LoginCoverage.tsx
 * @Description: 登录页左栏下半部分背景:门店覆盖网络「俯瞰指挥图」,纯装饰、无任何伪造数据。
 *   设计主张(震撼但不繁琐):不加元素,改做「极端的尺度层级」——
 *   - 唯一视觉主角:近景基站(5px 青绿实心核 / 25+44px 双层环 / 145px 呼吸辉光),
 *     与最小远景点 0.8px 形成 ~180× 尺度差;亮度整体压低,不与登录卡/文字争注意力;
 *   - 无实心光轴:沿轴的 3 个点(第 4、第 5 链节点 + 基站)用虚线依次相连(2 段),
 *     末段沿段渐隐收口,断续接入主角而不穿过双环;
 *   - 2 道以基站为心的大尺度扫描弧(170 / 250px,两端渐隐),用半径制造张力而非堆元素;
 *   - 沿纵深铺开的 5 个逐级放大/提亮的链节点(1.1→5px / 0.2→0.95),把景深做成节奏;
 *   - 其余全部退到背景并减量:普通点 46→~22、枢纽 13→9、星点 10→6、枢纽连线 4→2;
 *     直线 6 条(2 经线 + 2 枢纽连线 + 2 段链节点虚线)另有 2 道大弧,颜色仅品牌蓝 + 唯一青绿脉冲;
 *     右深左淡、近大远小、近亮远淡、极轻散景(1 / 0.5px)。
 *   - 不画纬线/网格、不画地平线光带;仅 2 条极淡经线收向消失点(B 方案)。
 *   - 青绿脉冲固定在基站中心:5px 实心核(无渐隐/柔光)+ 同径起步的扩散环,只扩到内环半径的一半
 *     12.5px(CSS scale 2.5、non-scaling-stroke 保持细环),不越过 25px 内环;组件无状态、无 Math.random。
 *   - 全部动效尊重 prefers-reduced-motion。
 *   实现:固定 600×510 viewBox + CSS width:100%/height:auto —— 不拉伸、不裁切、贴底到边。
 */

const W = 600;
const H = 510;
const HORIZON = 60; // 远处地平线 y(远点在此收敛)
const NEAR = H - 20; // 近处地面 y(近点铺到底部)
const Z_FAR = 0.12; // 最远深度
const BASE = { x: W * 0.66, y: NEAR - 24 }; // 近景基站:唯一视觉主角,位置固定可控
const AXIS_TOP = { x: W / 2 - 26, y: HORIZON + 26 }; // 链节点的纵深起点(贴近消失点)
const CORE_R = 5; // 青绿实体核半径(缩小后更克制);脉冲扩散环同径起步,CSS 终值 12.5/5=2.5

// 固定种子伪随机:装饰用,保证分布一致(非真实门店数据)
function makeRand(seed: number) {
  let s = seed % 233280;
  return () => {
    s = (s * 9301 + 49297) % 233280;
    return s / 233280;
  };
}
const rand = makeRand(91);
const srand = makeRand(47);
const lerp = (a: number, b: number, t: number) => a + (b - a) * t;
const clamp = (v: number, lo: number, hi: number) => Math.max(lo, Math.min(hi, v));

// 世界坐标:z=深度(0远..1近),lx=横向(-1..1);band=所属深度层(仅枢纽有,供连线分组)
type WDot = { z: number; lx: number; hub: boolean; jx: number; jy: number; band?: number };

// 枢纽节点:4 个深度层、共 9 个(3/2/2/2),层内横向均匀、相邻层错位。
// 数量比上一版 13 个更少——环与光晕全部让给基站,避免满屏都是「小主角」。
const WHUBS: WDot[] = (() => {
  const out: WDot[] = [];
  const BANDS = [0.18, 0.42, 0.66, 0.88];
  const PER_BAND = [3, 2, 2, 2];
  for (let b = 0; b < BANDS.length; b++) {
    const p = Math.pow(BANDS[b], 1 / 0.82);
    const z = Z_FAR + p * (1 - Z_FAR);
    const n = PER_BAND[b];
    for (let i = 0; i < n; i++) {
      const t = (i + (b % 2) * 0.35 + (rand() - 0.5) * 0.25) / (n - 1 + 0.35);
      out.push({
        z: clamp(z + (rand() - 0.5) * 0.08, Z_FAR, 1),
        lx: clamp(lerp(-0.78, 0.78, t), -0.95, 0.95),
        hub: true,
        band: b,
        jx: (rand() - 0.5) * 0.06,
        jy: (rand() - 0.5) * 0.04,
      });
    }
  }
  return out;
})();

// 普通网点:沿透视格点成排收敛,8 列 × 5 行 × 55% 保留 ≈ 22 个(上一版约 46 个)。
// 只做背景层,不承担视觉焦点。
const COLS = [-0.82, -0.6, -0.38, -0.16, 0.16, 0.38, 0.6, 0.82];
const ROWS_PP = [0.12, 0.34, 0.55, 0.74, 0.9];
const WFIELD: WDot[] = [];
for (const pp of ROWS_PP) {
  const p = Math.pow(pp, 1 / 0.82);
  const z = Z_FAR + p * (1 - Z_FAR);
  for (const cx of COLS) {
    if (rand() < 0.55) {
      WFIELD.push({
        z,
        lx: clamp(cx + (rand() - 0.5) * 0.045, -1, 1),
        hub: false,
        jx: (rand() - 0.5) * 0.022,
        jy: (rand() - 0.5) * 0.014,
      });
    }
  }
}

const WDOTS: WDot[] = [...WHUBS, ...WFIELD];

// 投影:世界坐标 → 屏幕坐标,含透视收敛
function project(d: WDot) {
  const p = (d.z - Z_FAR) / (1 - Z_FAR); // 0 远 .. 1 近
  const pp = Math.pow(p, 0.82);
  const y = lerp(HORIZON, NEAR, pp) + d.jy * (NEAR - HORIZON);
  const halfSpread = lerp(34, 296, pp);
  const x = W / 2 + (d.lx + d.jx) * halfSpread;
  return { x, y, p };
}

interface PNode {
  x: number;
  y: number;
  p: number;
  r: number;
  op: number;
  hub: boolean;
  band: number;
}
const NODES: PNode[] = WDOTS.map((d) => {
  const { x, y, p } = project(d);
  const r = lerp(0.8, 3.1, p) * (d.hub ? 1.35 : 1);
  const depthOp = lerp(0.16, 0.9, p);
  const xOp = 0.66 + (x / W) * 0.55; // 右深左淡,文字区压低保证可读
  const op = clamp(depthOp * xOp + (d.hub ? 0.08 : 0), 0.08, 0.95);
  return { x, y, p, r, op, hub: d.hub, band: d.band ?? -1 };
});

// 枢纽连线:只留 2 条(层间一左一右),不成网、不抢主角。
const HUBS = NODES.filter((n) => n.hub).sort((a, b) => a.y - b.y);
const BAND_COUNT = 4;
const MESH: { a: PNode; b: PNode; op: number }[] = (() => {
  const rows: PNode[][] = Array.from({ length: BAND_COUNT }, () => []);
  for (const h of HUBS) {
    if (h.band >= 0 && h.band < BAND_COUNT) rows[h.band].push(h);
  }
  for (const r of rows) r.sort((a, b) => a.x - b.x);

  const out: { a: PNode; b: PNode; op: number }[] = [];
  const MAX_EDGES = 2;
  for (let b = 0; b < BAND_COUNT - 1 && out.length < MAX_EDGES; b++) {
    const wantRight = b % 2 === 1;
    const pairs: { a: PNode; c: PNode; d: number }[] = [];
    for (const a of rows[b]) {
      for (const c of rows[b + 1]) {
        const mid = (a.x + c.x) / 2;
        if ((mid >= W / 2) !== wantRight) continue;
        pairs.push({ a, c, d: Math.abs(a.x - c.x) + Math.abs(a.y - c.y) * 0.15 });
      }
    }
    pairs.sort((x, y) => x.d - y.d);
    if (pairs[0]) {
      out.push({
        a: pairs[0].a,
        b: pairs[0].c,
        op: clamp(0.18 + ((pairs[0].a.p + pairs[0].c.p) / 2) * 0.3, 0.18, 0.55),
      });
    }
  }
  return out;
})();

// 链节点:沿纵深非线性铺开,半径 1.1→5px、透明度 0.2→0.95,
// 与远景点形成可读的尺度节奏;末端不重复(那里是基站)。
const CHAIN = Array.from({ length: 5 }, (_, i) => {
  const t = (i + 1) / 6;
  const pp = Math.pow(t, 0.82);
  return {
    x: lerp(AXIS_TOP.x, BASE.x, pp),
    y: lerp(AXIS_TOP.y, BASE.y, pp),
    r: lerp(1.1, 5, pp),
    op: lerp(0.2, 0.95, pp),
    glow: pp > 0.55,
  };
});

// 虚线窗口再往基站方向挪一个节点:沿轴序列是「5 个链节点 + 基站」,
// 因此 3 个端点 = 第 4、第 5 个链节点 + 基站,仍是 2 段虚线(取代原实心光轴)。
// 接入主角的那一段更淡,避免虚线线头插进圆盘抢戏。
const CHAIN_TAIL: { x: number; y: number }[] = [...CHAIN.slice(-2), { x: BASE.x, y: BASE.y }];
const CHAIN_DASH = CHAIN_TAIL.slice(1).map((c, i) => ({
  a: CHAIN_TAIL[i],
  b: c,
  op: 0.42 - i * 0.1, // 0.42 / 0.32:越靠近主角越淡
}));

// B 方案:仅 2 条极淡经线,从近处地面左右两侧收向消失点(无纬线、无辉光、垂直渐隐)
const MERIDIANS = [-0.72, 0.72].map((lx) => ({
  x1: W / 2 + lx * 296,
  y1: NEAR,
  x2: W / 2,
  y2: HORIZON - 10,
}));

// 大尺度扫描弧:仅 2 条,以基站为心向远处上方展开,两端水平渐隐不出现硬切口。
// 这是「主角的结构」,不是地面网格;用大半径制造画面张力,元素数不变。
const SCAN_ARCS = [170, 250].map((r, i) => {
  const a0 = Math.PI * 1.08;
  const a1 = Math.PI * 1.92;
  return {
    r,
    op: i === 0 ? 0.9 : 0.55,
    d: `M ${BASE.x + r * Math.cos(a0)} ${BASE.y + r * Math.sin(a0)} A ${r} ${r} 0 0 1 ${BASE.x + r * Math.cos(a1)} ${BASE.y + r * Math.sin(a1)}`,
  };
});

// 右上留白楔形区的点缀星点:6 颗、纵向分层均匀、极淡、少数微闪
const STAR_TOP = HORIZON + 12;
const STAR_BOTTOM = NEAR - 70;
const STARS = Array.from({ length: 6 }, (_, k) => {
  const sy = lerp(STAR_TOP, STAR_BOTTOM, (k + 0.2 + srand() * 0.6) / 6);
  const pp = Math.pow(clamp((sy - HORIZON) / (NEAR - HORIZON), 0, 1), 1 / 0.82);
  const edge = W / 2 + lerp(34, 296, pp);
  const x = clamp(edge + 8 + srand() * (W - edge - 22), edge + 4, W - 8);
  const depthDim = lerp(0.5, 1, (sy - HORIZON) / (STAR_BOTTOM - HORIZON));
  const op = clamp((0.18 + (x / W) * 0.26) * depthDim, 0.14, 0.4);
  return { x, y: sy, r: 0.6 + srand() * 0.8, op, tw: srand() < 0.35 };
});

// 景深分层(远→近):越远模糊越强
const LAYER_BLUR = ['url(#covBlurFar)', 'url(#covBlurMid)', undefined as string | undefined];

export function LoginCoverage() {
  const fillOf = (n: PNode) => (n.hub ? '#E4EDFF' : n.p > 0.6 ? '#C6D8FF' : '#9DBBFF');

  const renderDot = (n: PNode, i: number) => {
    const layer = n.p < 0.4 ? 0 : n.p < 0.72 ? 1 : 2;
    if (n.hub) {
      // 枢纽只留小辉光 + 亮核,不画环——环是主角的专属语言
      return (
        <g key={i} filter={LAYER_BLUR[layer]}>
          <circle cx={n.x} cy={n.y} r={n.r * 2.6} fill="url(#ujCovGlow)" />
          <circle cx={n.x} cy={n.y} r={n.r} fill={fillOf(n)} fillOpacity={Math.min(0.98, n.op + 0.1)} />
        </g>
      );
    }
    return (
      <circle
        key={i}
        cx={n.x}
        cy={n.y}
        r={n.r}
        fill={fillOf(n)}
        fillOpacity={n.op}
        filter={LAYER_BLUR[layer]}
      />
    );
  };

  return (
    <div className="uj-login-coverage" aria-hidden="true">
      <svg viewBox={`0 0 ${W} ${H}`} width="100%" height="auto" preserveAspectRatio="xMidYMax meet">
        <defs>
          {/* 大尺度聚焦光场:以基站为心,中心 0.45 → 边缘 0,制造整图的明暗骨架 */}
          <radialGradient id="ujCovFocus" cx="50%" cy="50%" r="50%">
            <stop offset="0%" stopColor="#2F63E8" stopOpacity="0.55" />
            <stop offset="55%" stopColor="#2F63E8" stopOpacity="0.16" />
            <stop offset="100%" stopColor="#2F63E8" stopOpacity="0" />
          </radialGradient>
          {/* 枢纽 / 基站中层辉光 */}
          <radialGradient id="ujCovGlow" cx="50%" cy="50%" r="50%">
            <stop offset="0%" stopColor="#5B8DEF" stopOpacity="0.7" />
            <stop offset="100%" stopColor="#5B8DEF" stopOpacity="0" />
          </radialGradient>
          {/* 基站 145px 大辉光(呼吸):亮度已压低,只留体积感,不做亮斑 */}
          <radialGradient id="ujCovCore" cx="50%" cy="50%" r="50%">
            <stop offset="0%" stopColor="#8FB4FF" stopOpacity="0.42" />
            <stop offset="45%" stopColor="#5B8DEF" stopOpacity="0.16" />
            <stop offset="100%" stopColor="#5B8DEF" stopOpacity="0" />
          </radialGradient>
          {/* 近处地面受光 */}
          <linearGradient id="ujCovGround" x1="0" y1="0" x2="0" y2="1">
            <stop offset="0%" stopColor="#0A1430" stopOpacity="0" />
            <stop offset="100%" stopColor="#2A4A9E" stopOpacity="0.22" />
          </linearGradient>
          {/* 扫描弧两端渐隐:中间 0.16、左右 0,避免大弧出现硬切口 */}
          <linearGradient id="ujCovArc" x1="0" y1="0" x2="1" y2="0">
            <stop offset="0%" stopColor="#8FB4FF" stopOpacity="0" />
            <stop offset="50%" stopColor="#8FB4FF" stopOpacity="0.16" />
            <stop offset="100%" stopColor="#8FB4FF" stopOpacity="0" />
          </linearGradient>
          {/* 接入主角的虚线段末端渐隐:线头化进基站辉光,不出现穿过双环的硬线头 */}
          <linearGradient
            id="ujCovDashFade"
            gradientUnits="userSpaceOnUse"
            x1={CHAIN[CHAIN.length - 1].x}
            y1={CHAIN[CHAIN.length - 1].y}
            x2={BASE.x}
            y2={BASE.y}
          >
            <stop offset="0%" stopColor="#A9C6FF" stopOpacity="1" />
            <stop offset="55%" stopColor="#A9C6FF" stopOpacity="0.55" />
            <stop offset="100%" stopColor="#A9C6FF" stopOpacity="0" />
          </linearGradient>
          {/* 极淡经线的垂直渐隐:远处化掉,不形成硬线 */}
          <linearGradient
            id="ujCovMeridian"
            gradientUnits="userSpaceOnUse"
            x1="0"
            y1={HORIZON - 10}
            x2="0"
            y2={NEAR}
          >
            <stop offset="0%" stopColor="#6FA0FF" stopOpacity="0" />
            <stop offset="55%" stopColor="#6FA0FF" stopOpacity="0.07" />
            <stop offset="100%" stopColor="#6FA0FF" stopOpacity="0.16" />
          </linearGradient>
          {/* 景深散景:极轻,主体不发糊 */}
          <filter id="covBlurFar" x="-30%" y="-30%" width="160%" height="160%">
            <feGaussianBlur stdDeviation="1" />
          </filter>
          <filter id="covBlurMid" x="-30%" y="-30%" width="160%" height="160%">
            <feGaussianBlur stdDeviation="0.5" />
          </filter>
        </defs>

        {/* 明暗底层:地面受光 + 以基站为心的大光场 */}
        <rect x={0} y={0} width={W} height={H} fill="url(#ujCovGround)" />
        <ellipse cx={BASE.x} cy={BASE.y - 40} rx={340} ry={260} fill="url(#ujCovFocus)" />

        {/* 2 道大尺度扫描弧:主角向外扩散的结构,两端渐隐 */}
        <g fill="none" stroke="url(#ujCovArc)" strokeWidth={1}>
          {SCAN_ARCS.map((a) => (
            <path key={a.r} d={a.d} strokeOpacity={a.op} />
          ))}
        </g>

        {/* 2 条极淡经线:收向消失点(无纬线、无网格) */}
        <g fill="none" stroke="url(#ujCovMeridian)" strokeWidth={0.8}>
          {MERIDIANS.map((m, i) => (
            <line key={i} x1={m.x1} y1={m.y1} x2={m.x2} y2={m.y2} />
          ))}
        </g>

        {/* 枢纽连线 2 条:退到背景,不抢主角 */}
        <g fill="none" stroke="#8FB4FF" strokeWidth={1} strokeDasharray="3 3" strokeOpacity={0.5}>
          {MESH.map((s, i) => (
            <line key={i} x1={s.a.x} y1={s.a.y} x2={s.b.x} y2={s.b.y} strokeOpacity={s.op} />
          ))}
        </g>

        {/* 背景点:近大远小、近亮远淡、极轻散景 */}
        {NODES.map((n, i) => renderDot(n, i))}

        {/* 沿轴 3 个点(第 4、第 5 链节点 + 基站)的虚线连接:2 段,接入主角处更淡 */}
        <g fill="none" stroke="#A9C6FF" strokeWidth={1.1} strokeDasharray="4 5" strokeLinecap="round">
          {CHAIN_DASH.map((s, i) => (
            <line
              key={`dash${i}`}
              x1={s.a.x}
              y1={s.a.y}
              x2={s.b.x}
              y2={s.b.y}
              stroke={i === 1 ? 'url(#ujCovDashFade)' : undefined}
              strokeOpacity={s.op}
            />
          ))}
        </g>

        {/* 链节点:逐级放大/提亮,把景深做成节奏 */}
        {CHAIN.map((c, i) => (
          <g key={`chain${i}`}>
            {c.glow && <circle cx={c.x} cy={c.y} r={c.r * 3.2} fill="url(#ujCovGlow)" />}
            <circle cx={c.x} cy={c.y} r={c.r} fill="#DCE8FF" fillOpacity={c.op} />
          </g>
        ))}

        {/* 唯一视觉主角:近景基站(尺度层级保留,亮度压低——不抢登录卡与文字) */}
        <g>
          <circle className="uj-cov-core" cx={BASE.x} cy={BASE.y} r={145} fill="url(#ujCovCore)" />
          <circle cx={BASE.x} cy={BASE.y} r={62} fill="url(#ujCovGlow)" fillOpacity={0.45} />
          <circle cx={BASE.x} cy={BASE.y} r={44} fill="none" stroke="#7FA8F5" strokeOpacity={0.32} strokeWidth={1.1} />
          <circle cx={BASE.x} cy={BASE.y} r={25} fill="none" stroke="#A9C6FF" strokeOpacity={0.5} strokeWidth={1.2} />
          {/* 青绿脉冲:扩散环(起点与实体核同径,只扩到内环半径的一半 12.5px)+ 实体核,位置固定在 BASE,不再随机 */}
          <circle
            className="uj-cov-pulse"
            cx={BASE.x}
            cy={BASE.y}
            r={CORE_R}
            fill="none"
            stroke="#2DE2C4"
            strokeWidth={1.2}
            vectorEffect="non-scaling-stroke"
          />
          {/* 实心圆点:缩小到 5px、纯色填充、无渐隐、无 drop-shadow,边缘清晰不发虚 */}
          <circle cx={BASE.x} cy={BASE.y} r={CORE_R} fill="#1FE0C8" />
        </g>

        {/* 右上留白楔形区的 6 颗极淡星点 */}
        {STARS.map((s, i) => (
          <circle
            key={`star${i}`}
            cx={s.x}
            cy={s.y}
            r={s.r}
            fill="#BCD4FF"
            fillOpacity={s.op}
            className={s.tw ? 'uj-cov-star-tw' : undefined}
          />
        ))}

      </svg>
    </div>
  );
}