topo-engine 0.1.9 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/index.d.ts +18 -1
- package/dist/style.css +11 -11
- package/dist/topo-engine.cjs +335 -57
- package/dist/topo-engine.cjs.map +1 -1
- package/dist/topo-engine.js +335 -57
- package/dist/topo-engine.js.map +1 -1
- package/dist/topo-engine.umd.cjs +335 -57
- package/dist/topo-engine.umd.cjs.map +1 -1
- package/docs/API.md +46 -11
- package/package.json +1 -1
package/dist/topo-engine.cjs
CHANGED
|
@@ -6660,11 +6660,11 @@ var parseGradient$1 = /* @__PURE__ */ function() {
|
|
|
6660
6660
|
}
|
|
6661
6661
|
}
|
|
6662
6662
|
function matchPositioning() {
|
|
6663
|
-
var
|
|
6664
|
-
if (
|
|
6663
|
+
var location2 = matchCoordinates();
|
|
6664
|
+
if (location2.x || location2.y) {
|
|
6665
6665
|
return {
|
|
6666
6666
|
type: "position",
|
|
6667
|
-
value:
|
|
6667
|
+
value: location2
|
|
6668
6668
|
};
|
|
6669
6669
|
}
|
|
6670
6670
|
}
|
|
@@ -26313,8 +26313,10 @@ class TopoApi {
|
|
|
26313
26313
|
}
|
|
26314
26314
|
// ------------------------------------------------------------
|
|
26315
26315
|
// 光晕 / 脉动 动画 —— 节点 & 箱内电表户
|
|
26316
|
-
// setNodeGlow(ref, { color, spread/radius, duration, opacity })
|
|
26316
|
+
// setNodeGlow(ref, { color, spread/radius, duration, opacity, width, intensity, blink })
|
|
26317
26317
|
// ref = 节点 id/psrId → 图元光环;assetNo → 该户表位光环
|
|
26318
|
+
// 强度栈:blur 柔光底衬 + 实心光块 + 外扩散环×2 + 霓虹主环(shadowBlur) + 亮芯环
|
|
26319
|
+
// intensity = 强度倍率(默认 1);blink = true/0~1 → 图元「整体闪烁」
|
|
26318
26320
|
// setNodePulse(ref, opts) → 节点透明度呼吸;assetNo → 该户电表格淡入淡出
|
|
26319
26321
|
// ------------------------------------------------------------
|
|
26320
26322
|
/** 是否有需要逐帧推进的动画(节点光晕 / 户光晕 / 户脉动) */
|
|
@@ -26412,6 +26414,9 @@ class TopoApi {
|
|
|
26412
26414
|
_glowSpread: void 0,
|
|
26413
26415
|
_glowOpacity: void 0,
|
|
26414
26416
|
_glowDuration: void 0,
|
|
26417
|
+
_glowWidth: void 0,
|
|
26418
|
+
_glowLevel: void 0,
|
|
26419
|
+
_glowBlink: void 0,
|
|
26415
26420
|
_glowT: void 0
|
|
26416
26421
|
}
|
|
26417
26422
|
}]);
|
|
@@ -26419,9 +26424,32 @@ class TopoApi {
|
|
|
26419
26424
|
}
|
|
26420
26425
|
}
|
|
26421
26426
|
/**
|
|
26422
|
-
*
|
|
26427
|
+
* 归一化「整体闪烁」参数:false / 未给 → 0(只画光环);true → 0.85;数字 → clamp(0,1)。
|
|
26428
|
+
* 数值含义 = 图元最暗时被压掉的透明度幅度(1 → 图元完全隐去,0.5 → 最暗降到 50%)。
|
|
26429
|
+
*/
|
|
26430
|
+
_normBlink(v) {
|
|
26431
|
+
if (v === true) return 0.85;
|
|
26432
|
+
if (v === false || v == null) return 0;
|
|
26433
|
+
const n = Number(v);
|
|
26434
|
+
return Number.isFinite(n) ? Math.max(0, Math.min(1, n)) : 0;
|
|
26435
|
+
}
|
|
26436
|
+
/** 归一化强度倍率(intensity/level/strength):默认 1,范围 0.2~3 */
|
|
26437
|
+
_normLevel(v) {
|
|
26438
|
+
const n = Number(v);
|
|
26439
|
+
return Number.isFinite(n) && n > 0 ? Math.max(0.2, Math.min(3, n)) : 1;
|
|
26440
|
+
}
|
|
26441
|
+
/**
|
|
26442
|
+
* 节点 / 箱内电表户光晕(发光环 + 霓虹辉光)动画。
|
|
26423
26443
|
* @param {string} ref 节点 id / psrId(图元光环)或资产编号 assetNo(该户表位光环)
|
|
26424
|
-
* @param {object} [opts] - { color, spread/radius, duration, opacity }
|
|
26444
|
+
* @param {object} [opts] - { color, spread/radius, duration, opacity, width, intensity/level/strength, blink/flash }
|
|
26445
|
+
* 渲染栈:blur 柔光底衬 + 贴合图元的实心光块(面光)→ 图元 → 外扩散环 ×2 →
|
|
26446
|
+
* 霓虹主环(粗线 + canvas shadowBlur 辉光)→ 偏白亮芯环(刺眼高光)。
|
|
26447
|
+
* intensity:强度倍率,默认 1(线宽/辉光/底光同时放大);想“更夸张”给 1.5~2.5,想收敛给 0.5~0.7。
|
|
26448
|
+
* spread:光环外扩半径,默认按图元大小自适应(短边 ×0.7,16~46px)。
|
|
26449
|
+
* blink:图元「整体闪烁」开关/强度(默认 false 只画光环;true = 0.85;数字 0~1)。
|
|
26450
|
+
* 开启后图元本体透明度随相位「亮 ↔ 暗」交替(与光环相位互补,始终有强视觉元素),
|
|
26451
|
+
* 图元变暗的瞬间底衬光块最亮 —— 整块明暗交替比细线醒目得多。
|
|
26452
|
+
* width:主环初始线宽 (px),默认 5.6(节点)/ 3.6(户表位),随相位收细。
|
|
26425
26453
|
* @returns {boolean} 是否命中并启动
|
|
26426
26454
|
*/
|
|
26427
26455
|
setNodeGlow(ref, opts = {}) {
|
|
@@ -26431,11 +26459,17 @@ class TopoApi {
|
|
|
26431
26459
|
console.warn(`[TopoApi] setNodeGlow: 无法解析目标 ${ref}(节点用 id/psrId,电表户用 assetNo)`);
|
|
26432
26460
|
return false;
|
|
26433
26461
|
}
|
|
26462
|
+
const width = parseFloat(opts.width);
|
|
26463
|
+
const spread = opts.spread != null ? opts.spread : opts.radius;
|
|
26434
26464
|
const cfg = {
|
|
26435
26465
|
color: opts.color || "#00C8FF",
|
|
26436
|
-
spread:
|
|
26437
|
-
|
|
26466
|
+
spread: Number.isFinite(parseFloat(spread)) ? parseFloat(spread) : null,
|
|
26467
|
+
// null → 按图元大小自适应
|
|
26468
|
+
opacity: opts.opacity != null ? opts.opacity : 0.95,
|
|
26438
26469
|
duration: opts.duration || 1600,
|
|
26470
|
+
width: Number.isFinite(width) && width > 0 ? width : null,
|
|
26471
|
+
level: this._normLevel(opts.intensity != null ? opts.intensity : opts.level != null ? opts.level : opts.strength),
|
|
26472
|
+
blink: this._normBlink(opts.blink != null ? opts.blink : opts.flash),
|
|
26439
26473
|
_start: performance.now(),
|
|
26440
26474
|
t: 0
|
|
26441
26475
|
};
|
|
@@ -26445,9 +26479,12 @@ class TopoApi {
|
|
|
26445
26479
|
id: t.id,
|
|
26446
26480
|
style: {
|
|
26447
26481
|
_glowColor: cfg.color,
|
|
26448
|
-
_glowSpread: cfg.spread,
|
|
26482
|
+
_glowSpread: cfg.spread == null ? void 0 : cfg.spread,
|
|
26449
26483
|
_glowOpacity: cfg.opacity,
|
|
26450
26484
|
_glowDuration: cfg.duration,
|
|
26485
|
+
_glowWidth: cfg.width == null ? void 0 : cfg.width,
|
|
26486
|
+
_glowLevel: cfg.level,
|
|
26487
|
+
_glowBlink: cfg.blink || void 0,
|
|
26451
26488
|
_glowT: 0
|
|
26452
26489
|
}
|
|
26453
26490
|
}]);
|
|
@@ -26499,6 +26536,9 @@ class TopoApi {
|
|
|
26499
26536
|
_glowSpread: void 0,
|
|
26500
26537
|
_glowOpacity: void 0,
|
|
26501
26538
|
_glowDuration: void 0,
|
|
26539
|
+
_glowWidth: void 0,
|
|
26540
|
+
_glowLevel: void 0,
|
|
26541
|
+
_glowBlink: void 0,
|
|
26502
26542
|
_glowT: void 0
|
|
26503
26543
|
}
|
|
26504
26544
|
});
|
|
@@ -28701,6 +28741,8 @@ const THEMES = {
|
|
|
28701
28741
|
cyan: "#00C8FF",
|
|
28702
28742
|
gold: "#FFD700",
|
|
28703
28743
|
gray: "#8B8B8B",
|
|
28744
|
+
// 开关/熔丝(Kxx)标签文字:画在红色箱体(red)里的文字色,随主题切换
|
|
28745
|
+
switchText: "#FFFFFF",
|
|
28704
28746
|
// 计量箱(JX):深色主题黑底白字;浅色主题白底深框深字(随画布配套)
|
|
28705
28747
|
meterFill: "#000000",
|
|
28706
28748
|
meterText: "#FFFFFF",
|
|
@@ -28729,6 +28771,9 @@ const THEMES = {
|
|
|
28729
28771
|
cyan: "#0087B8",
|
|
28730
28772
|
gold: "#B8860B",
|
|
28731
28773
|
gray: "#9C9C9C",
|
|
28774
|
+
// 开关标签:浅色主题下箱体仍是深红 red(#C62828),此处保持浅色字
|
|
28775
|
+
// (白字对比度 ≈5.6:1;若改成深字,请连 red 一起调浅,否则只剩 ≈2.3:1 会发糊)
|
|
28776
|
+
switchText: "#FFFFFF",
|
|
28732
28777
|
meterFill: "#FFFFFF",
|
|
28733
28778
|
// 浅色主题:白底 + 深框深字(随白画布配套)
|
|
28734
28779
|
meterText: "#3A3A3A",
|
|
@@ -28932,6 +28977,19 @@ function withAlpha(color2, a2) {
|
|
|
28932
28977
|
}
|
|
28933
28978
|
const LW = 1.8;
|
|
28934
28979
|
const LW_HI = 2.2;
|
|
28980
|
+
function mixWhite(color2, k) {
|
|
28981
|
+
if (typeof color2 !== "string") return color2;
|
|
28982
|
+
const m = color2.match(/^#([0-9a-f]{6}|[0-9a-f]{3})$/i);
|
|
28983
|
+
if (!m) return color2;
|
|
28984
|
+
let hex2 = m[1];
|
|
28985
|
+
if (hex2.length === 3) hex2 = hex2.split("").map((h) => h + h).join("");
|
|
28986
|
+
const n = parseInt(hex2, 16);
|
|
28987
|
+
const mix = (v) => Math.round(v + (255 - v) * Math.max(0, Math.min(1, k)));
|
|
28988
|
+
const r = mix(n >> 16 & 255), g = mix(n >> 8 & 255), b = mix(n & 255);
|
|
28989
|
+
return `#${(r << 16 | g << 8 | b).toString(16).padStart(6, "0")}`;
|
|
28990
|
+
}
|
|
28991
|
+
const clampNum = (v, lo, hi) => v < lo ? lo : v > hi ? hi : v;
|
|
28992
|
+
const NO_HIT = { pointerEvents: "none" };
|
|
28935
28993
|
function drawHighlight(attributes, group) {
|
|
28936
28994
|
if (!attributes.highlight) return;
|
|
28937
28995
|
const [w, h] = attributes.size;
|
|
@@ -29025,7 +29083,7 @@ function _wrapLinesFixed(str2, chars2) {
|
|
|
29025
29083
|
if (line) lines.push(line);
|
|
29026
29084
|
return lines;
|
|
29027
29085
|
}
|
|
29028
|
-
function _drawWrappedTextFixed(group, str2, x, y, fontSize2, fill, chars2, lineGap = 1.3, weight = 400, align = "center") {
|
|
29086
|
+
function _drawWrappedTextFixed(group, str2, x, y, fontSize2, fill, chars2, lineGap = 1.3, weight = 400, align = "center", extra = null) {
|
|
29029
29087
|
if (!str2) return;
|
|
29030
29088
|
const lines = _wrapLinesFixed(str2, chars2);
|
|
29031
29089
|
if (!lines.length) return;
|
|
@@ -29034,6 +29092,7 @@ function _drawWrappedTextFixed(group, str2, x, y, fontSize2, fill, chars2, lineG
|
|
|
29034
29092
|
group.appendChild(
|
|
29035
29093
|
new Text({
|
|
29036
29094
|
style: {
|
|
29095
|
+
...extra || {},
|
|
29037
29096
|
text: lines[i],
|
|
29038
29097
|
x,
|
|
29039
29098
|
y: y + lineHeight2 * i,
|
|
@@ -29107,7 +29166,7 @@ function drawBreaker(attributes, group) {
|
|
|
29107
29166
|
}
|
|
29108
29167
|
group.appendChild(new Rect({ style: { x: bx, y: by, width: bw, height: bh, radius: r, fill: P.red, stroke: withAlpha(C2.white, 0.22), lineWidth: 1 } }));
|
|
29109
29168
|
if (attributes.labelText) {
|
|
29110
|
-
_drawWrappedText(group, attributes.labelText, 0, 0.6, 11.5,
|
|
29169
|
+
_drawWrappedText(group, attributes.labelText, 0, 0.6, 11.5, C2.switchText, bw - 8, 1.15, 700);
|
|
29111
29170
|
}
|
|
29112
29171
|
}
|
|
29113
29172
|
function drawCableTerminal(attributes, group) {
|
|
@@ -29154,20 +29213,33 @@ function cellFxAt(attributes, i) {
|
|
|
29154
29213
|
return fx && typeof fx === "object" ? fx[i] || null : null;
|
|
29155
29214
|
}
|
|
29156
29215
|
function drawCellGlowRings(group, cx, cy, baseR, g, t) {
|
|
29157
|
-
|
|
29158
|
-
|
|
29159
|
-
|
|
29160
|
-
|
|
29161
|
-
|
|
29162
|
-
|
|
29163
|
-
|
|
29164
|
-
|
|
29165
|
-
|
|
29166
|
-
|
|
29216
|
+
glowStack(group, cx, cy, baseR, {
|
|
29217
|
+
color: g.color,
|
|
29218
|
+
t: t == null ? g.t : t,
|
|
29219
|
+
spread: g.spread,
|
|
29220
|
+
opacity: g.opacity,
|
|
29221
|
+
width: g.width,
|
|
29222
|
+
level: g.level
|
|
29223
|
+
});
|
|
29224
|
+
}
|
|
29225
|
+
function cellBlinkOpacity(g) {
|
|
29226
|
+
if (!g || !g.blink) return 1;
|
|
29227
|
+
return 1 - g.blink * glowBlinkK(g.t == null ? 0 : g.t);
|
|
29228
|
+
}
|
|
29229
|
+
function drawCellGlowBackdrop(group, cx, cy, meterW, meterH, g) {
|
|
29230
|
+
if (!g) return;
|
|
29231
|
+
glowBackdrop(group, cx, cy, meterW, meterH, {
|
|
29232
|
+
color: g.color,
|
|
29233
|
+
t: g.t,
|
|
29234
|
+
spread: g.spread != null ? g.spread : 14,
|
|
29235
|
+
level: g.level,
|
|
29236
|
+
blink: g.blink
|
|
29237
|
+
});
|
|
29167
29238
|
}
|
|
29168
29239
|
function drawCellHighlight(group, cx, cy, baseR, hl) {
|
|
29169
29240
|
group.appendChild(new Circle({
|
|
29170
29241
|
style: {
|
|
29242
|
+
...NO_HIT,
|
|
29171
29243
|
cx,
|
|
29172
29244
|
cy,
|
|
29173
29245
|
r: baseR + 3,
|
|
@@ -29183,7 +29255,7 @@ function drawCellNote(group, cx, cy, baseR, note) {
|
|
|
29183
29255
|
const color2 = note.color || C2.gold;
|
|
29184
29256
|
const top = !note.position || note.position === "top";
|
|
29185
29257
|
const y = top ? cy - baseR - 5 - size / 2 : cy + baseR + 6 + size / 2;
|
|
29186
|
-
_drawWrappedTextFixed(group, note.text, cx, y, size, color2, 6, 1.15, 600, "center");
|
|
29258
|
+
_drawWrappedTextFixed(group, note.text, cx, y, size, color2, 6, 1.15, 600, "center", NO_HIT);
|
|
29187
29259
|
}
|
|
29188
29260
|
function drawMeterBox(attributes, group) {
|
|
29189
29261
|
const [w, h] = attributes.size;
|
|
@@ -29205,6 +29277,8 @@ function drawMeterBox(attributes, group) {
|
|
|
29205
29277
|
const meterH = 26;
|
|
29206
29278
|
const cx = 0;
|
|
29207
29279
|
const cy = -1;
|
|
29280
|
+
const baseR = Math.max(12, meterH / 2 + 2);
|
|
29281
|
+
if (fx && fx.glow) drawCellGlowBackdrop(cellGroup, cx, cy, meterW, meterH, fx.glow);
|
|
29208
29282
|
if (sel || hover) {
|
|
29209
29283
|
const ring = new Rect({
|
|
29210
29284
|
style: {
|
|
@@ -29221,9 +29295,10 @@ function drawMeterBox(attributes, group) {
|
|
|
29221
29295
|
markCell(ring);
|
|
29222
29296
|
cellGroup.appendChild(ring);
|
|
29223
29297
|
}
|
|
29298
|
+
const faceStart = cellGroup.children.length;
|
|
29224
29299
|
drawMeterFace(cellGroup, cx, cy, meterW, meterH, lineColor, markCell, 0);
|
|
29300
|
+
const faceEnd = cellGroup.children.length;
|
|
29225
29301
|
if (fx) {
|
|
29226
|
-
const baseR = Math.max(12, meterH / 2 + 2);
|
|
29227
29302
|
if (fx.hl) drawCellHighlight(cellGroup, cx, cy, baseR, fx.hl);
|
|
29228
29303
|
if (fx.note && fx.note.text) drawCellNote(cellGroup, cx, cy, baseR, fx.note);
|
|
29229
29304
|
if (fx.glow) drawCellGlowRings(cellGroup, cx, cy, baseR, fx.glow, fx.glow.t || 0);
|
|
@@ -29235,6 +29310,13 @@ function drawMeterBox(attributes, group) {
|
|
|
29235
29310
|
if (fx && fx.pulse && fx.pulse.opacity != null && fx.pulse.opacity < 1) {
|
|
29236
29311
|
cellGroup.style.opacity = fx.pulse.opacity;
|
|
29237
29312
|
}
|
|
29313
|
+
const blinkOp0 = fx && fx.glow ? cellBlinkOpacity(fx.glow) : 1;
|
|
29314
|
+
if (blinkOp0 < 1) {
|
|
29315
|
+
for (let k = faceStart; k < faceEnd && k < cellGroup.children.length; k++) {
|
|
29316
|
+
const s2 = cellGroup.children[k].style;
|
|
29317
|
+
s2.opacity = (s2.opacity == null ? 1 : s2.opacity) * blinkOp0;
|
|
29318
|
+
}
|
|
29319
|
+
}
|
|
29238
29320
|
group.appendChild(cellGroup);
|
|
29239
29321
|
} else if (attributes._meterBoxMode === "grid" && attributes._customers) {
|
|
29240
29322
|
const frameColor = boxColor || C2.meterText;
|
|
@@ -29260,6 +29342,7 @@ function drawMeterBox(attributes, group) {
|
|
|
29260
29342
|
shape.__custBox = nodeId;
|
|
29261
29343
|
shape.__custIndex = i;
|
|
29262
29344
|
};
|
|
29345
|
+
const hitLayer = new Group({});
|
|
29263
29346
|
for (let i = 0; i < customers.length; i++) {
|
|
29264
29347
|
const row2 = Math.floor(i / cols);
|
|
29265
29348
|
const col = i % cols;
|
|
@@ -29271,6 +29354,7 @@ function drawMeterBox(attributes, group) {
|
|
|
29271
29354
|
const lineColor = sel ? C2.gold : hover ? C2.cyan : baseColor;
|
|
29272
29355
|
const fx = cellFxAt(attributes, i);
|
|
29273
29356
|
const cellGroup = new Group({});
|
|
29357
|
+
if (fx && fx.glow) drawCellGlowBackdrop(cellGroup, cx, cy, meterW, meterH, fx.glow);
|
|
29274
29358
|
if (sel || hover) {
|
|
29275
29359
|
cellGroup.appendChild(new Circle({
|
|
29276
29360
|
style: {
|
|
@@ -29284,7 +29368,9 @@ function drawMeterBox(attributes, group) {
|
|
|
29284
29368
|
}
|
|
29285
29369
|
}));
|
|
29286
29370
|
}
|
|
29371
|
+
const faceStart = cellGroup.children.length;
|
|
29287
29372
|
drawMeterFace(cellGroup, cx, cy, meterW, meterH, lineColor, markCell, i);
|
|
29373
|
+
const faceEnd = cellGroup.children.length;
|
|
29288
29374
|
if (fx) {
|
|
29289
29375
|
if (fx.hl) drawCellHighlight(cellGroup, cx, cy, hitR, fx.hl);
|
|
29290
29376
|
if (fx.note && fx.note.text) drawCellNote(cellGroup, cx, cy, hitR, fx.note);
|
|
@@ -29296,9 +29382,19 @@ function drawMeterBox(attributes, group) {
|
|
|
29296
29382
|
_drawWrappedTextFixed(cellGroup, name, cx, cy + meterH / 2 + 6.5, 6.5, lineColor, 4, 1.15, 500);
|
|
29297
29383
|
}
|
|
29298
29384
|
}
|
|
29299
|
-
const
|
|
29300
|
-
|
|
29301
|
-
|
|
29385
|
+
const hitCell = new Rect({
|
|
29386
|
+
style: {
|
|
29387
|
+
x: cx - cellW / 2 - METER_GAP / 2,
|
|
29388
|
+
y: cy - cellW / 2 - METER_GAP / 2,
|
|
29389
|
+
width: cellW + METER_GAP,
|
|
29390
|
+
height: cellH + METER_GAP,
|
|
29391
|
+
fill: "rgba(255,255,255,0.01)",
|
|
29392
|
+
stroke: "none",
|
|
29393
|
+
cursor: "pointer"
|
|
29394
|
+
}
|
|
29395
|
+
});
|
|
29396
|
+
markCell(hitCell, i);
|
|
29397
|
+
hitLayer.appendChild(hitCell);
|
|
29302
29398
|
if (showName) {
|
|
29303
29399
|
const name = customers[i].realConsName || customers[i].consName || "";
|
|
29304
29400
|
if (name) {
|
|
@@ -29313,14 +29409,22 @@ function drawMeterBox(attributes, group) {
|
|
|
29313
29409
|
}
|
|
29314
29410
|
});
|
|
29315
29411
|
markCell(hitName, i);
|
|
29316
|
-
|
|
29412
|
+
hitLayer.appendChild(hitName);
|
|
29317
29413
|
}
|
|
29318
29414
|
}
|
|
29319
29415
|
if (fx && fx.pulse && fx.pulse.opacity != null && fx.pulse.opacity < 1) {
|
|
29320
29416
|
cellGroup.style.opacity = fx.pulse.opacity;
|
|
29321
29417
|
}
|
|
29418
|
+
const blinkOp = fx && fx.glow ? cellBlinkOpacity(fx.glow) : 1;
|
|
29419
|
+
if (blinkOp < 1) {
|
|
29420
|
+
for (let k = faceStart; k < faceEnd && k < cellGroup.children.length; k++) {
|
|
29421
|
+
const s2 = cellGroup.children[k].style;
|
|
29422
|
+
s2.opacity = (s2.opacity == null ? 1 : s2.opacity) * blinkOp;
|
|
29423
|
+
}
|
|
29424
|
+
}
|
|
29322
29425
|
group.appendChild(cellGroup);
|
|
29323
29426
|
}
|
|
29427
|
+
group.appendChild(hitLayer);
|
|
29324
29428
|
} else {
|
|
29325
29429
|
const s2 = Math.min(w, h) || 21;
|
|
29326
29430
|
const ink = boxColor || C2.meterText;
|
|
@@ -29408,35 +29512,134 @@ const DRAWERS = {
|
|
|
29408
29512
|
other: drawUnknown
|
|
29409
29513
|
};
|
|
29410
29514
|
const _pulseState = /* @__PURE__ */ new Map();
|
|
29411
|
-
function
|
|
29412
|
-
|
|
29413
|
-
|
|
29414
|
-
|
|
29415
|
-
|
|
29416
|
-
|
|
29417
|
-
|
|
29418
|
-
|
|
29419
|
-
|
|
29420
|
-
|
|
29515
|
+
function pushGlowRing(group, cx, cy, r, lineWidth, strokeOpacity, color2, blur) {
|
|
29516
|
+
if (strokeOpacity <= 0.015 || lineWidth <= 0) return;
|
|
29517
|
+
const style = {
|
|
29518
|
+
...NO_HIT,
|
|
29519
|
+
cx,
|
|
29520
|
+
cy,
|
|
29521
|
+
r,
|
|
29522
|
+
stroke: color2,
|
|
29523
|
+
lineWidth,
|
|
29524
|
+
strokeOpacity,
|
|
29525
|
+
fill: "none",
|
|
29526
|
+
lineCap: "round"
|
|
29527
|
+
};
|
|
29528
|
+
if (blur > 0.5) {
|
|
29529
|
+
style.shadowColor = color2;
|
|
29530
|
+
style.shadowBlur = blur;
|
|
29531
|
+
}
|
|
29532
|
+
group.appendChild(new Circle({ style }));
|
|
29533
|
+
}
|
|
29534
|
+
function glowStack(group, cx, cy, baseR, g) {
|
|
29535
|
+
const color2 = g.color || "#00C8FF";
|
|
29536
|
+
const level = g.level > 0 ? g.level : 1;
|
|
29537
|
+
const tt = clampNum(g.t == null ? 0 : g.t, 0, 1);
|
|
29538
|
+
const spread = g.spread != null ? g.spread : 14;
|
|
29539
|
+
const maxOp = g.opacity == null ? 0.95 : g.opacity;
|
|
29540
|
+
const alpha = Math.min(1, maxOp * Math.pow(1 - tt, 1.1) * Math.min(1.5, level));
|
|
29421
29541
|
if (alpha <= 0.02) return;
|
|
29422
|
-
const r = baseR + spread *
|
|
29423
|
-
const lw = Math.max(1.
|
|
29424
|
-
group.
|
|
29425
|
-
|
|
29542
|
+
const r = baseR + spread * (1 - (1 - tt) * (1 - tt));
|
|
29543
|
+
const lw = Math.max(1.3, (g.width || 3.6) * level * (0.34 + 0.66 * (1 - tt)));
|
|
29544
|
+
pushGlowRing(group, cx, cy, r + spread * 1.1, lw * 0.4, alpha * 0.26, color2, 0);
|
|
29545
|
+
pushGlowRing(group, cx, cy, r + spread * 0.55, lw * 0.62, alpha * 0.5, color2, lw * 2.5);
|
|
29546
|
+
pushGlowRing(group, cx, cy, r, lw, alpha, color2, lw * 6);
|
|
29547
|
+
pushGlowRing(group, cx, cy, r, Math.max(1.1, lw * 0.34), Math.min(1, alpha * 1.05), mixWhite(color2, 0.62), lw * 2);
|
|
29548
|
+
}
|
|
29549
|
+
function glowBackdrop(group, x, y, w, h, g) {
|
|
29550
|
+
const color2 = g.color || "#00C8FF";
|
|
29551
|
+
const level = g.level > 0 ? g.level : 1;
|
|
29552
|
+
const tt = clampNum(g.t == null ? 0 : g.t, 0, 1);
|
|
29553
|
+
const spread = g.spread != null ? g.spread : Math.max(14, Math.min(w, h) * 0.7);
|
|
29554
|
+
const blink = g.blink || 0;
|
|
29555
|
+
const fade = Math.pow(1 - tt, 1.1);
|
|
29556
|
+
const bk = glowBlinkK(tt);
|
|
29557
|
+
const base = Math.min(0.6, level * (0.26 * fade + 0.5 * blink * bk));
|
|
29558
|
+
const aura = Math.min(0.45, level * (0.2 * fade + 0.42 * blink * bk));
|
|
29559
|
+
if (base <= 0.02 && aura <= 0.02) return;
|
|
29560
|
+
const rad2 = Math.max(3, Math.min(w, h) * 0.16);
|
|
29561
|
+
const blurPx = clampNum(Math.min(w, h) * 0.28, 4, 18) * level;
|
|
29562
|
+
group.appendChild(new Rect({
|
|
29563
|
+
style: {
|
|
29564
|
+
...NO_HIT,
|
|
29565
|
+
x: x - w / 2 - spread * 0.85,
|
|
29566
|
+
y: y - h / 2 - spread * 0.85,
|
|
29567
|
+
width: w + spread * 1.7,
|
|
29568
|
+
height: h + spread * 1.7,
|
|
29569
|
+
radius: rad2 + 4,
|
|
29570
|
+
fill: color2,
|
|
29571
|
+
fillOpacity: aura,
|
|
29572
|
+
stroke: "none",
|
|
29573
|
+
filter: `blur(${blurPx.toFixed(1)}px)`
|
|
29574
|
+
}
|
|
29426
29575
|
}));
|
|
29427
|
-
group.appendChild(new
|
|
29576
|
+
group.appendChild(new Rect({
|
|
29428
29577
|
style: {
|
|
29429
|
-
|
|
29430
|
-
|
|
29431
|
-
|
|
29432
|
-
|
|
29433
|
-
|
|
29434
|
-
|
|
29435
|
-
fill:
|
|
29436
|
-
|
|
29578
|
+
...NO_HIT,
|
|
29579
|
+
x: x - w / 2 - 2.5,
|
|
29580
|
+
y: y - h / 2 - 2.5,
|
|
29581
|
+
width: w + 5,
|
|
29582
|
+
height: h + 5,
|
|
29583
|
+
radius: rad2,
|
|
29584
|
+
fill: color2,
|
|
29585
|
+
fillOpacity: base,
|
|
29586
|
+
stroke: "none"
|
|
29437
29587
|
}
|
|
29438
29588
|
}));
|
|
29439
29589
|
}
|
|
29590
|
+
function glowBlinkK(t) {
|
|
29591
|
+
return 0.5 - 0.5 * Math.cos((t || 0) * Math.PI * 2);
|
|
29592
|
+
}
|
|
29593
|
+
function glowParams(attributes) {
|
|
29594
|
+
const color2 = attributes._glowColor;
|
|
29595
|
+
if (!color2) return null;
|
|
29596
|
+
const [w, h] = attributes.size || [40, 40];
|
|
29597
|
+
const t = clampNum(attributes._glowT == null ? 0 : attributes._glowT, 0, 1);
|
|
29598
|
+
const level = attributes._glowLevel > 0 ? attributes._glowLevel : 1;
|
|
29599
|
+
const spread = attributes._glowSpread != null ? attributes._glowSpread : clampNum(Math.min(w, h) * 0.7, 16, 46);
|
|
29600
|
+
return {
|
|
29601
|
+
color: color2,
|
|
29602
|
+
t,
|
|
29603
|
+
w,
|
|
29604
|
+
h,
|
|
29605
|
+
level,
|
|
29606
|
+
baseR: Math.max(w, h) / 2 + 3,
|
|
29607
|
+
spread,
|
|
29608
|
+
maxOp: attributes._glowOpacity == null ? 0.95 : attributes._glowOpacity,
|
|
29609
|
+
lw0: attributes._glowWidth || 5.6,
|
|
29610
|
+
// 主环初始线宽(可调,默认 5.6)
|
|
29611
|
+
blink: attributes._glowBlink || 0
|
|
29612
|
+
// 整体闪烁强度(0=关;setNodeGlow blink 参数)
|
|
29613
|
+
};
|
|
29614
|
+
}
|
|
29615
|
+
function drawGlowBackdrop(attributes, group) {
|
|
29616
|
+
const p = glowParams(attributes);
|
|
29617
|
+
if (!p) return;
|
|
29618
|
+
glowBackdrop(group, 0, 0, p.w, p.h, {
|
|
29619
|
+
color: p.color,
|
|
29620
|
+
t: p.t,
|
|
29621
|
+
spread: p.spread,
|
|
29622
|
+
level: p.level,
|
|
29623
|
+
blink: p.blink
|
|
29624
|
+
});
|
|
29625
|
+
}
|
|
29626
|
+
function nodeBlinkOpacity(attributes) {
|
|
29627
|
+
const blink = attributes._glowBlink;
|
|
29628
|
+
if (!blink) return 1;
|
|
29629
|
+
return 1 - blink * glowBlinkK(attributes._glowT == null ? 0 : attributes._glowT);
|
|
29630
|
+
}
|
|
29631
|
+
function drawGlow(attributes, group) {
|
|
29632
|
+
const p = glowParams(attributes);
|
|
29633
|
+
if (!p) return;
|
|
29634
|
+
glowStack(group, 0, 0, p.baseR, {
|
|
29635
|
+
color: p.color,
|
|
29636
|
+
t: p.t,
|
|
29637
|
+
spread: p.spread,
|
|
29638
|
+
opacity: p.maxOp,
|
|
29639
|
+
width: p.lw0,
|
|
29640
|
+
level: p.level
|
|
29641
|
+
});
|
|
29642
|
+
}
|
|
29440
29643
|
class SvgSymbolNode extends g6.BaseNode {
|
|
29441
29644
|
drawKeyShape(attributes, container) {
|
|
29442
29645
|
const [w, h] = attributes.size;
|
|
@@ -29466,7 +29669,10 @@ class SvgSymbolNode extends g6.BaseNode {
|
|
|
29466
29669
|
const target = rot ? new Group({ style: { transform: `rotate(${rot}deg)` } }) : key;
|
|
29467
29670
|
if (rot) key.appendChild(target);
|
|
29468
29671
|
const draw = DRAWERS[attributes.cat] || drawUnknown;
|
|
29672
|
+
drawGlowBackdrop(attributes, target);
|
|
29673
|
+
const symStart = (target.children || []).length;
|
|
29469
29674
|
draw(attributes, target);
|
|
29675
|
+
const symEnd = (target.children || []).length;
|
|
29470
29676
|
drawGlow(attributes, target);
|
|
29471
29677
|
drawHighlight(attributes, target);
|
|
29472
29678
|
drawAnnotation(attributes, target);
|
|
@@ -29484,6 +29690,15 @@ class SvgSymbolNode extends g6.BaseNode {
|
|
|
29484
29690
|
for (const child of items) child.style.opacity = op;
|
|
29485
29691
|
}
|
|
29486
29692
|
}
|
|
29693
|
+
const blinkOp = nodeBlinkOpacity(attributes);
|
|
29694
|
+
if (blinkOp < 1) {
|
|
29695
|
+
const kids = target.children || [];
|
|
29696
|
+
for (let i = symStart; i < symEnd && i < kids.length; i++) {
|
|
29697
|
+
const s2 = kids[i].style;
|
|
29698
|
+
const base = s2.opacity == null ? 1 : s2.opacity;
|
|
29699
|
+
s2.opacity = base * blinkOp;
|
|
29700
|
+
}
|
|
29701
|
+
}
|
|
29487
29702
|
return key;
|
|
29488
29703
|
}
|
|
29489
29704
|
}
|
|
@@ -29581,6 +29796,56 @@ const _sfc_main$2 = {
|
|
|
29581
29796
|
function cellFromShape(shape) {
|
|
29582
29797
|
return shape && shape.__custBox != null && shape.__custIndex != null ? { nodeId: shape.__custBox, index: shape.__custIndex } : null;
|
|
29583
29798
|
}
|
|
29799
|
+
function cellIndexAtPoint(nodeId, evt) {
|
|
29800
|
+
const st = styleOf(nodeId);
|
|
29801
|
+
if (!st || st._meterBoxMode !== "grid" || !Array.isArray(st._customers) || !st._customers.length) return null;
|
|
29802
|
+
const c = evt && (evt.canvas || evt.viewport) || {};
|
|
29803
|
+
if (c.x == null || c.y == null || st.x == null || st.y == null) return null;
|
|
29804
|
+
let lx = c.x - st.x;
|
|
29805
|
+
let ly = c.y - st.y;
|
|
29806
|
+
const rot = (st.rotate || 0) * Math.PI / 180;
|
|
29807
|
+
if (rot) {
|
|
29808
|
+
const cos = Math.cos(-rot);
|
|
29809
|
+
const sin = Math.sin(-rot);
|
|
29810
|
+
const nx = lx * cos - ly * sin;
|
|
29811
|
+
const ny = lx * sin + ly * cos;
|
|
29812
|
+
lx = nx;
|
|
29813
|
+
ly = ny;
|
|
29814
|
+
}
|
|
29815
|
+
const cols = st._meterBoxCols || Math.min(st._customers.length, MAX_COLS);
|
|
29816
|
+
const cellW = METER_CELL_W;
|
|
29817
|
+
const cellH = st._meterBoxShowName ? METER_CELL_H : METER_CELL_W;
|
|
29818
|
+
const rows = st._meterBoxRows || Math.ceil(st._customers.length / cols);
|
|
29819
|
+
const gridW = cols * cellW + (cols - 1) * METER_GAP;
|
|
29820
|
+
const gridH = rows * cellH + (rows - 1) * METER_GAP;
|
|
29821
|
+
const col = Math.floor((lx + gridW / 2) / (cellW + METER_GAP));
|
|
29822
|
+
const row2 = Math.floor((ly + gridH / 2) / (cellH + METER_GAP));
|
|
29823
|
+
if (col < 0 || col >= cols || row2 < 0 || row2 >= rows) return null;
|
|
29824
|
+
const i = row2 * cols + col;
|
|
29825
|
+
return i < st._customers.length ? i : null;
|
|
29826
|
+
}
|
|
29827
|
+
const DEBUG_CELL = typeof location !== "undefined" && /[?&]debugCell\b/.test(location.search);
|
|
29828
|
+
function dbgCell(tag, detail) {
|
|
29829
|
+
if (DEBUG_CELL) console.log("[cell-debug]", tag, detail);
|
|
29830
|
+
}
|
|
29831
|
+
function nodeIdOfShape(shape) {
|
|
29832
|
+
if (!shape || !nodeByIdMap) return null;
|
|
29833
|
+
let el = shape;
|
|
29834
|
+
for (let hops = 0; el && hops < 16; hops++) {
|
|
29835
|
+
if (el.id && nodeByIdMap.has(el.id)) return el.id;
|
|
29836
|
+
el = el.parentElement;
|
|
29837
|
+
}
|
|
29838
|
+
return null;
|
|
29839
|
+
}
|
|
29840
|
+
function resolveCell(evt, shape, nodeIdHint, allowBboxFallback = true) {
|
|
29841
|
+
const direct = cellFromShape(shape);
|
|
29842
|
+
if (direct) return direct;
|
|
29843
|
+
let nid = nodeIdHint || nodeIdOfShape(shape);
|
|
29844
|
+
if (!nid && allowBboxFallback) nid = hitTestNodeAtCanvas(evt);
|
|
29845
|
+
if (!nid) return null;
|
|
29846
|
+
const idx = cellIndexAtPoint(nid, evt);
|
|
29847
|
+
return idx == null ? null : { nodeId: nid, index: idx };
|
|
29848
|
+
}
|
|
29584
29849
|
function neighborsOf(id2) {
|
|
29585
29850
|
const upstream = [];
|
|
29586
29851
|
const downstream = [];
|
|
@@ -29818,14 +30083,21 @@ const _sfc_main$2 = {
|
|
|
29818
30083
|
graph.on("node:click", (evt) => {
|
|
29819
30084
|
const id2 = evt.target.id;
|
|
29820
30085
|
if (!id2) return;
|
|
29821
|
-
const cell =
|
|
29822
|
-
|
|
30086
|
+
const cell = resolveCell(evt, evt.originalTarget, id2);
|
|
30087
|
+
dbgCell("node:click", {
|
|
30088
|
+
id: id2,
|
|
30089
|
+
shape: evt.originalTarget && evt.originalTarget.nodeName,
|
|
30090
|
+
mark: cellFromShape(evt.originalTarget),
|
|
30091
|
+
cell,
|
|
30092
|
+
canvas: evt.canvas
|
|
30093
|
+
});
|
|
30094
|
+
if (cell && customersOf(id2) && cell.nodeId === id2) {
|
|
29823
30095
|
selectCustomerWithInfo(id2, cell.index);
|
|
29824
30096
|
return;
|
|
29825
30097
|
}
|
|
29826
30098
|
routeNodeTap(id2);
|
|
29827
30099
|
});
|
|
29828
|
-
function
|
|
30100
|
+
function hitTestNodeAtCanvas2(evt) {
|
|
29829
30101
|
const c = evt && (evt.canvas || evt.viewport) || {};
|
|
29830
30102
|
const cx = c.x, cy = c.y;
|
|
29831
30103
|
if (cx == null || cy == null) return null;
|
|
@@ -29875,8 +30147,14 @@ const _sfc_main$2 = {
|
|
|
29875
30147
|
api._emit("edge:click", { edgeId: id2, source: src, target: tgt });
|
|
29876
30148
|
});
|
|
29877
30149
|
graph.on("canvas:click", (evt) => {
|
|
29878
|
-
const hitId =
|
|
30150
|
+
const hitId = hitTestNodeAtCanvas2(evt);
|
|
29879
30151
|
if (hitId) {
|
|
30152
|
+
const cell = resolveCell(evt, null, hitId);
|
|
30153
|
+
dbgCell("canvas:click", { hitId, cell, canvas: evt.canvas });
|
|
30154
|
+
if (cell && cell.nodeId === hitId && customersOf(hitId)) {
|
|
30155
|
+
selectCustomerWithInfo(hitId, cell.index);
|
|
30156
|
+
return;
|
|
30157
|
+
}
|
|
29880
30158
|
routeNodeTap(hitId);
|
|
29881
30159
|
return;
|
|
29882
30160
|
}
|
|
@@ -29898,7 +30176,7 @@ const _sfc_main$2 = {
|
|
|
29898
30176
|
const gCanvas = graph.getCanvas && graph.getCanvas();
|
|
29899
30177
|
const doc = gCanvas && gCanvas.document;
|
|
29900
30178
|
if (doc) {
|
|
29901
|
-
doc.addEventListener("pointermove", (e2) => setCellHover(
|
|
30179
|
+
doc.addEventListener("pointermove", (e2) => setCellHover(resolveCell(e2, e2 && e2.target, null, false)));
|
|
29902
30180
|
}
|
|
29903
30181
|
hoverLeaveHandler = () => setCellHover(null);
|
|
29904
30182
|
container.value.addEventListener("pointerleave", hoverLeaveHandler);
|
|
@@ -30038,7 +30316,7 @@ const _sfc_main$2 = {
|
|
|
30038
30316
|
};
|
|
30039
30317
|
}
|
|
30040
30318
|
};
|
|
30041
|
-
const TopoGraph = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-
|
|
30319
|
+
const TopoGraph = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-a4a4c398"]]);
|
|
30042
30320
|
const _hoisted_1$1 = ["data-theme"];
|
|
30043
30321
|
const _hoisted_2$1 = { class: "panel-head" };
|
|
30044
30322
|
const _hoisted_3$1 = {
|
|
@@ -30411,7 +30689,7 @@ const _sfc_main = {
|
|
|
30411
30689
|
}
|
|
30412
30690
|
};
|
|
30413
30691
|
const DistanceTop10 = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-438b6017"]]);
|
|
30414
|
-
const VERSION = "0.1.
|
|
30692
|
+
const VERSION = "0.1.10";
|
|
30415
30693
|
const DESCRIPTION = "配电台区单线图拓扑成图引擎";
|
|
30416
30694
|
exports.DESCRIPTION = DESCRIPTION;
|
|
30417
30695
|
exports.DistanceTop10 = DistanceTop10;
|