LoginCoverage.tsx
11.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
/*
* @Author: liimin 17653212@qq.com
* @Date: 2026-11-13 10:00:00
* @LastEditors: liimin 17653212@qq.com
* @LastEditTime: 2026-11-15 15:57:00
* @FilePath: \uj-store\src\pages\Login\components\LoginCoverage.tsx
* @Description: 登录页左栏下半部分背景:门店覆盖网络「俯瞰指挥图」,纯装饰、无任何伪造数据。
* 以「俯瞰 + 景深 + 发光网络」呈现冲击感:
* - 透视发光地面网格:经线收向地平线消失点、纬线近宽远窄,一眼读出「俯瞰地面」;
* - 枢纽节点网状互联(就近相连)+ 霓虹辉光(bloom),形成真实的规模化门店网络;
* - 一个核心枢纽(最近最大)带呼吸光晕,作为视觉焦点;
* - 景深:近点更大/更亮/近白核且清晰,远点更小/更淡/带散景虚化(bokeh);
* - 地平线光带 + 右侧聚焦光晕营造氛围;右深左淡、顶部渐隐融入墙面;右上留白楔形补星点。
* 实现:固定 600×340 横向 viewBox,CSS 用 width:100%/height:auto 由浏览器按比例算高度,
* 因此无论登录栏多宽多高都保持原始比例——不拉伸、不裁切、左右到边、贴底。
*/
import { useState } from 'react';
const W = 600;
const H = 340;
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);投影到屏幕形成收敛透视
type WDot = { z: number; lx: number; hub: boolean; jx: number; jy: number };
// 枢纽节点:数量固定,构成「被连线连起来的」网络骨架(保留密度,是图的视觉主体)
const WHUBS: WDot[] = Array.from({ length: 13 }, () => ({
z: Z_FAR + rand() * (1 - Z_FAR),
lx: rand() * 2 - 1,
hub: true,
jx: (rand() - 0.5) * 0.1,
jy: (rand() - 0.5) * 0.05,
}));
// 普通网点:沿透视格点散落(带轻微抖动),成排向远处地平线收敛——
// 用「点的结构」承载俯视感,不画网格线。数量适中、远少于最初 82 个。
const COLS = [-0.82, -0.6, -0.38, -0.16, 0.16, 0.38, 0.6, 0.82];
const ROWS_PP = [0.16, 0.3, 0.44, 0.58, 0.7, 0.81, 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.78) {
WFIELD.push({
z,
lx: clamp(cx + (rand() - 0.5) * 0.1, -1, 1),
hub: false,
jx: (rand() - 0.5) * 0.06,
jy: (rand() - 0.5) * 0.04,
});
}
}
}
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;
}
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.5 + (x / W) * 0.75; // 左侧更淡(右深左淡)
const op = clamp(depthOp * xOp + (d.hub ? 0.12 : 0), 0.08, 0.96);
return { x, y, p, r, op, hub: d.hub };
});
// 枢纽节点 + 就近互联网格(每个枢纽连最近的 2 个,去重成网)
const HUBS = NODES.filter((n) => n.hub).sort((a, b) => a.y - b.y);
const MESH: { a: PNode; b: PNode; op: number }[] = (() => {
const used = new Set<string>();
const out: { a: PNode; b: PNode; op: number }[] = [];
for (let i = 0; i < HUBS.length; i++) {
const others = HUBS.map((h, idx) => ({
idx,
d: Math.hypot(h.x - HUBS[i].x, h.y - HUBS[i].y),
}))
.filter((o) => o.idx !== i)
.sort((a, b) => a.d - b.d)
.slice(0, 2);
for (const o of others) {
const key = i < o.idx ? `${i}-${o.idx}` : `${o.idx}-${i}`;
if (used.has(key)) continue;
used.add(key);
const a = HUBS[i];
const b = HUBS[o.idx];
out.push({ a, b, op: clamp(0.12 + ((a.p + b.p) / 2) * 0.32, 0.1, 0.6) });
}
}
return out;
})();
// 核心枢纽:取最近的枢纽作视觉焦点
const CORE = HUBS.reduce((m, h) => (h.p > m.p ? h : m), HUBS[0]);
// 透视网格线已按需求移除;俯视感改由 WFIELD 的透视格点(成排向地平线收敛)承载。
// 右上留白楔形区的点缀星点:只落在透视扇面右缘之外,填补空三角;极淡、少数微闪
const STARS = Array.from({ length: 10 }, () => {
const sy = lerp(HORIZON + 8, 222, srand());
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 + srand() * (W - edge - 16), edge + 4, W - 8);
const depthDim = lerp(0.5, 1, (sy - HORIZON) / (222 - 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="ujCovHorizon" x1="0" y1="0" x2="0" y2="1">
<stop offset="0%" stopColor="#5B8DEF" stopOpacity="0" />
<stop offset="50%" stopColor="#7FA8F5" stopOpacity="0.3" />
<stop offset="100%" stopColor="#5B8DEF" stopOpacity="0" />
</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="2.4" 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)" />
{/* 地平线光带 */}
<rect x={0} y={HORIZON - 16} width={W} height={32} fill="url(#ujCovHorizon)" />
{/* 枢纽就近互联网格(霓虹辉光) */}
<g fill="none" stroke="#6FA0FF" strokeWidth={0.9} strokeDasharray="2.4 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>
);
}