LoginCoverage.tsx
14.6 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
/*
* @Author: liimin 17653212@qq.com
* @Date: 2026-11-13 10:00:00
* @LastEditors: liimin 17653212@qq.com
* @LastEditTime: 2026-11-15 18:22:00
* @FilePath: \uj-store\src\pages\Login\components\LoginCoverage.tsx
* @Description: 登录页左栏下半部分背景:门店覆盖网络「俯瞰指挥图」,纯装饰、无任何伪造数据。
* 以「俯瞰 + 景深 + 发光网络」呈现冲击感:
* - 透视格点成排向地平线收敛,以点的结构承载「俯瞰地面」;
* - 仅 2 条极淡经线收向消失点(无纬线、无辉光、垂直渐隐),补上最轻的收敛骨架;
* - 枢纽分层均匀铺开 + 按深度层组织的斜向贯通连线(已收紧到 4 条)+ 霓虹辉光(bloom);
* - 一个核心枢纽(最近最大)带呼吸光晕,作为视觉焦点;
* - 景深:近点更大/更亮/近白核且清晰,远点更小/更淡/带散景虚化(bokeh);
* - 不画地平线光带;右侧聚焦光晕营造氛围;右深左淡、顶部渐隐融入墙面;右上留白楔形补星点。
* 实现:固定 600×510 viewBox,CSS 用 width:100%/height:auto 由浏览器按比例算高度,
* 因此无论登录栏多宽多高都保持原始比例——不拉伸、不裁切、左右到边、贴底。
*/
import { useState } from 'react';
const W = 600;
const H = 510; // 背景整体加高:屏幕高 264→306px,顶部明显高出文字区;透视纵深同步拉长
const HORIZON = 60; // 远处地平线 y(远点在此收敛)
const NEAR = H - 20; // 近处地面 y(近点铺到底部)
const Z_FAR = 0.12; // 最远深度
// 固定种子伪随机:装饰用,保证分布一致(非真实门店数据)
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 层、层内横向均匀铺开(相邻层错位 + 轻微抖动)。
// 取代纯随机——随机点在透视收敛下容易扎堆,会让几条连线叠在一小块;分层后骨架本身是散开的。
const WHUBS: WDot[] = (() => {
const out: WDot[] = [];
const BANDS = [0.16, 0.4, 0.64, 0.88]; // 透视进度:远 → 近
const PER_BAND = [3, 3, 4, 3];
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.4 + (rand() - 0.5) * 0.25) / (n - 1 + 0.4);
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;
})();
// 普通网点:沿透视格点散落(带轻微抖动),成排向远处地平线收敛——
// 用「点的结构」承载俯视感,不画网格线。数量适中、远少于最初 82 个。
const COLS = [-0.82, -0.6, -0.38, -0.16, 0.16, 0.38, 0.6, 0.82];
// 从更远的 0.08 起排:最远行明显收窄,收敛比拉大;8 行 + 低保留率,总数仍约 46 个
const ROWS_PP = [0.08, 0.22, 0.36, 0.5, 0.63, 0.75, 0.86, 0.94];
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.74) {
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.45 : 1);
const depthOp = lerp(0.16, 0.96, p); // 远处更淡
const xOp = 0.68 + (x / W) * 0.55; // 右深左淡,但左侧不再淡到看不见,保住扇形左缘
const op = clamp(depthOp * xOp + (d.hub ? 0.12 : 0), 0.08, 0.96);
return { x, y, p, r, op, hub: d.hub, band: d.band ?? -1 };
});
// 连线:按深度层组织,但总量大幅收紧(反馈 9 条仍偏多 → 只留 4 条)。
// ① 相邻层之间每层只连 1 条,左右半区交替 —— 斜线朝消失点收拢,本身也是俯视线索;
// ② 只在最近层留 1 条层内短线,给网络一点横向咬合,其余层内不连;
// ③ 每个枢纽度数 ≤ 2、总边数封顶 4。
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 deg = new Map<PNode, number>();
const MAX_EDGES = 4;
const link = (a: PNode, b: PNode): boolean => {
if (out.length >= MAX_EDGES) return false;
if ((deg.get(a) ?? 0) >= 2 || (deg.get(b) ?? 0) >= 2) return false;
deg.set(a, (deg.get(a) ?? 0) + 1);
deg.set(b, (deg.get(b) ?? 0) + 1);
out.push({ a, b, op: clamp(0.2 + ((a.p + b.p) / 2) * 0.38, 0.18, 0.68) });
return true;
};
// ① 层间贯通:每层只挑 1 对,左右半区交替,避免线挤在同一侧
for (let b = 0; b < BAND_COUNT - 1; 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]) link(pairs[0].a, pairs[0].c);
}
// ② 最近层留 1 条层内短线
const near = rows[BAND_COUNT - 1];
if (near.length >= 2) link(near[near.length - 2], near[near.length - 1]);
return out;
})();
// 核心枢纽:取最近的枢纽作视觉焦点
const CORE = HUBS.reduce((m, h) => (h.p > m.p ? h : m), HUBS[0]);
// B 方案:仅 2 条极淡经线,从近处地面左右两侧收向消失点,给俯视一条最轻的收敛骨架。
// 只有经线、没有纬线、不加辉光;垂直渐隐让远处自然化掉,不形成硬线,也不回到「网格线」。
const MERIDIANS = [-0.72, 0.72].map((lx) => ({
x1: W / 2 + lx * 296,
y1: NEAR,
x2: W / 2,
y2: HORIZON - 10,
}));
// 右上留白楔形区的点缀星点:按纵向分层均匀铺开(不再纯随机扎堆),
// 只落在透视扇面右缘之外填补空三角;极淡、少数微闪
const STAR_TOP = HORIZON + 12;
const STAR_BOTTOM = NEAR - 70;
const STARS = Array.from({ length: 10 }, (_, k) => {
const sy = lerp(STAR_TOP, STAR_BOTTOM, (k + 0.2 + srand() * 0.6) / 10);
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.2 + (x / W) * 0.3) * depthDim, 0.16, 0.46);
return { x, y: sy, r: 0.6 + srand() * 0.9, op, tw: srand() < 0.4 };
});
// 景深分层(远→近):越远模糊越强
const LAYER_BLUR = ['url(#covBlurFar)', 'url(#covBlurMid)', undefined as string | undefined];
export function LoginCoverage() {
// 脉冲点:随机位置,每次挂载重新随机(刷新/重进登录页都变);偏右侧、近-中景
const [pulse] = useState(() => {
const z = Z_FAR + (1 - Z_FAR) * (0.45 + Math.random() * 0.5);
const lx = 0.15 + Math.random() * 0.8;
const { x, y } = project({ z, lx, hub: false, jx: 0, jy: 0 });
return { x, y };
});
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;
const fill = fillOf(n);
if (n.hub) {
return (
<g key={i} filter={LAYER_BLUR[layer]}>
<circle cx={n.x} cy={n.y} r={n.r * 3} fill="url(#ujCovGlow)" />
<circle cx={n.x} cy={n.y} r={n.r} fill={fill} fillOpacity={Math.min(0.98, n.op + 0.12)} />
<circle cx={n.x} cy={n.y} r={n.r + 2} fill="none" stroke="#5B8DEF" strokeOpacity={Math.min(0.7, n.op)} strokeWidth={0.8} />
</g>
);
}
return (
<circle
key={i}
cx={n.x}
cy={n.y}
r={n.r}
fill={fill}
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>
{/* 右侧聚焦光晕:品牌蓝向心渐隐,强化原小方格处的「更深」基调 */}
<radialGradient id="ujCovFocus" cx="50%" cy="50%" r="50%">
<stop offset="0%" stopColor="#3A6BF0" stopOpacity="0.4" />
<stop offset="100%" stopColor="#3A6BF0" 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>
{/* 核心枢纽大光晕 */}
<radialGradient id="ujCovCore" cx="50%" cy="50%" r="50%">
<stop offset="0%" stopColor="#7FA8FF" stopOpacity="0.55" />
<stop offset="100%" stopColor="#7FA8FF" 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.26" />
</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>
{/* 网络霓虹辉光:连线/核心的 bloom(收敛模糊量,避免把细线糊掉) */}
<filter id="covBloom" x="-60%" y="-60%" width="220%" height="220%">
<feGaussianBlur stdDeviation="1.6" result="b" />
<feMerge>
<feMergeNode in="b" />
<feMergeNode in="SourceGraphic" />
</feMerge>
</filter>
</defs>
{/* 近处地面受光(最底) */}
<rect x={0} y={0} width={W} height={H} fill="url(#ujCovGround)" />
{/* 右侧聚焦区 */}
<ellipse cx={W * 0.82} cy={H * 0.55} rx={W * 0.52} ry={H * 0.62} fill="url(#ujCovFocus)" />
{/* 仅 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>
{/* 枢纽连线:已收紧到 4 条(提亮、虚线更连续,让稀疏的骨架能被读出) */}
<g fill="none" stroke="#8FB4FF" strokeWidth={1.1} strokeDasharray="3 3" filter="url(#covBloom)">
{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))}
{/* 核心枢纽:呼吸光晕 + 大光环,作为视觉焦点 */}
<g>
<circle className="uj-cov-core" cx={CORE.x} cy={CORE.y} r={CORE.r * 6} fill="url(#ujCovCore)" />
<circle cx={CORE.x} cy={CORE.y} r={CORE.r * 4.2} fill="url(#ujCovGlow)" />
<circle cx={CORE.x} cy={CORE.y} r={CORE.r * 1.2} fill="#EAF1FF" fillOpacity={0.98} />
<circle cx={CORE.x} cy={CORE.y} r={CORE.r * 2.4} fill="none" stroke="#8FB4FF" strokeOpacity={0.8} strokeWidth={1} />
</g>
{/* 右上空白楔形区的点缀星点:填补透视扇面右缘之外的留白,极淡、少数微闪 */}
{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}
/>
))}
{/* 单个活跃节点:光晕扩散(雷达 ping),鲜艳青绿突出于淡蓝网点;始终清晰不受景深模糊 */}
<g>
<circle cx={pulse.x} cy={pulse.y} r={3.2} fill="#1FE0C8" style={{ filter: 'drop-shadow(0 0 6px #1FE0C8)' }} />
<circle className="uj-cov-pulse" cx={pulse.x} cy={pulse.y} r={3.4} fill="none" stroke="#2DE2C4" strokeWidth={1.2} style={{ animationDelay: '0s' }} />
</g>
</svg>
</div>
);
}