@flexem/fc-gui 3.0.0-alpha.146 → 3.0.0-alpha.148
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/bundles/@flexem/fc-gui.umd.js +57 -28
- package/bundles/@flexem/fc-gui.umd.js.map +1 -1
- package/bundles/@flexem/fc-gui.umd.min.js +1 -1
- package/bundles/@flexem/fc-gui.umd.min.js.map +1 -1
- package/elements/base/readable-element.js +5 -4
- package/elements/scroll-alarm/scroll-alarm-element.d.ts +2 -0
- package/elements/scroll-alarm/scroll-alarm-element.js +52 -24
- package/elements/scroll-alarm/scroll-alarm-element.metadata.json +1 -1
- package/package.json +1 -1
|
@@ -35386,19 +35386,20 @@ class readable_element_ReadableElement extends conditional_enable_element_Condit
|
|
|
35386
35386
|
let name = value.customStatus;
|
|
35387
35387
|
const language = ((_b = (_a = window.abp.localization) === null || _a === void 0 ? void 0 : _a.currentLanguage) === null || _b === void 0 ? void 0 : _b.name) || ((_d = (_c = this.localization.localizationService) === null || _c === void 0 ? void 0 : _c.translate) === null || _d === void 0 ? void 0 : _d.currentLang);
|
|
35388
35388
|
const isChinese = language === 'zh-Hans' || language === 'zh';
|
|
35389
|
+
const isTraditionalChinese = language === 'zh-Hant' || language === 'zh-TW' || language === 'zh-tw';
|
|
35389
35390
|
if (!name) {
|
|
35390
35391
|
switch (value.state) {
|
|
35391
35392
|
case 1:
|
|
35392
|
-
name = isChinese ? '在线' : 'Online';
|
|
35393
|
+
name = isTraditionalChinese ? '線上' : (isChinese ? '在线' : 'Online');
|
|
35393
35394
|
break;
|
|
35394
35395
|
case 3:
|
|
35395
|
-
name = isChinese ? '离线' : 'Offline';
|
|
35396
|
+
name = isTraditionalChinese ? '離線' : (isChinese ? '离线' : 'Offline');
|
|
35396
35397
|
break;
|
|
35397
35398
|
case 4:
|
|
35398
|
-
name = isChinese ? '告警' : 'Alarming';
|
|
35399
|
+
name = isTraditionalChinese ? '告警' : (isChinese ? '告警' : 'Alarming');
|
|
35399
35400
|
break;
|
|
35400
35401
|
case 5:
|
|
35401
|
-
name = isChinese ? '未绑定' : 'Unbound';
|
|
35402
|
+
name = isTraditionalChinese ? '未綁定' : (isChinese ? '未绑定' : 'Unbound');
|
|
35402
35403
|
break;
|
|
35403
35404
|
default:
|
|
35404
35405
|
}
|
|
@@ -42526,9 +42527,9 @@ class scroll_alarm_element_ScrollAlarmElement extends conditional_dynamic_displa
|
|
|
42526
42527
|
clipPath.setAttribute('id', clipId);
|
|
42527
42528
|
const clipRect = document.createElementNS('http://www.w3.org/2000/svg', 'rect');
|
|
42528
42529
|
clipRect.setAttribute('x', '2');
|
|
42529
|
-
clipRect.setAttribute('y', '
|
|
42530
|
+
clipRect.setAttribute('y', '1');
|
|
42530
42531
|
clipRect.setAttribute('width', (elementWidth - 4).toString());
|
|
42531
|
-
clipRect.setAttribute('height', elementHeight.toString());
|
|
42532
|
+
clipRect.setAttribute('height', (elementHeight - 2).toString());
|
|
42532
42533
|
clipPath.appendChild(clipRect);
|
|
42533
42534
|
defs.appendChild(clipPath);
|
|
42534
42535
|
this.$element[0].appendChild(defs);
|
|
@@ -42558,8 +42559,10 @@ class scroll_alarm_element_ScrollAlarmElement extends conditional_dynamic_displa
|
|
|
42558
42559
|
_createSvgTextNode(textContent) {
|
|
42559
42560
|
const elementHeight = this.model.size.height;
|
|
42560
42561
|
const fa = this._buildFontAttrs();
|
|
42562
|
+
const g = document.createElementNS('http://www.w3.org/2000/svg', 'g');
|
|
42561
42563
|
const text = document.createElementNS('http://www.w3.org/2000/svg', 'text');
|
|
42562
|
-
|
|
42564
|
+
const textY = elementHeight / 2;
|
|
42565
|
+
text.setAttribute('y', textY.toString());
|
|
42563
42566
|
text.setAttribute('dominant-baseline', 'central');
|
|
42564
42567
|
text.setAttribute('fill', fa.color);
|
|
42565
42568
|
text.setAttribute('font-size', fa.fontSize.toString());
|
|
@@ -42570,11 +42573,41 @@ class scroll_alarm_element_ScrollAlarmElement extends conditional_dynamic_displa
|
|
|
42570
42573
|
if (fa.isItalic) {
|
|
42571
42574
|
text.setAttribute('font-style', 'italic');
|
|
42572
42575
|
}
|
|
42576
|
+
// 不使用 SVG text-decoration,避免跨平台下划线位置不一致(Chrome/Android 与 iOS Safari 渲染差异)
|
|
42577
|
+
text.textContent = textContent;
|
|
42578
|
+
g.appendChild(text);
|
|
42573
42579
|
if (fa.isUnderline) {
|
|
42574
|
-
|
|
42580
|
+
// dominant-baseline: central 下,基线约在 textY + fontSize*0.35
|
|
42581
|
+
// 下划线紧贴文字底部(基线下 fontSize*0.1),再加 2px 间距避免与字形粘连
|
|
42582
|
+
// stroke-width 随字号缩放,参照浏览器标准约 fontSize/14,最小 1px
|
|
42583
|
+
const lineY = textY + Math.round(fa.fontSize * 0.35) + Math.round(fa.fontSize * 0.1) + 2;
|
|
42584
|
+
const strokeWidth = Math.max(1, Math.round(fa.fontSize / 14));
|
|
42585
|
+
const underline = document.createElementNS('http://www.w3.org/2000/svg', 'line');
|
|
42586
|
+
underline.setAttribute('y1', lineY.toString());
|
|
42587
|
+
underline.setAttribute('y2', lineY.toString());
|
|
42588
|
+
underline.setAttribute('x1', '0');
|
|
42589
|
+
underline.setAttribute('x2', '0'); // 宽度在 append 后由 _updateUnderlineWidth 设置
|
|
42590
|
+
underline.setAttribute('stroke', fa.color);
|
|
42591
|
+
underline.setAttribute('stroke-width', strokeWidth.toString());
|
|
42592
|
+
underline.setAttribute('class', 'text-underline');
|
|
42593
|
+
g.appendChild(underline);
|
|
42594
|
+
}
|
|
42595
|
+
return g;
|
|
42596
|
+
}
|
|
42597
|
+
_getSvgTextWidth(g) {
|
|
42598
|
+
const text = g.querySelector('text');
|
|
42599
|
+
if (!text) {
|
|
42600
|
+
return 100;
|
|
42601
|
+
}
|
|
42602
|
+
return text.getComputedTextLength
|
|
42603
|
+
? text.getComputedTextLength()
|
|
42604
|
+
: (text.getBBox ? text.getBBox().width : 100);
|
|
42605
|
+
}
|
|
42606
|
+
_updateUnderlineWidth(g, width) {
|
|
42607
|
+
const underline = g.querySelector('line.text-underline');
|
|
42608
|
+
if (underline) {
|
|
42609
|
+
underline.setAttribute('x2', width.toString());
|
|
42575
42610
|
}
|
|
42576
|
-
text.textContent = textContent;
|
|
42577
|
-
return text;
|
|
42578
42611
|
}
|
|
42579
42612
|
renderNewPage(pageData) {
|
|
42580
42613
|
const GAP = 80;
|
|
@@ -42606,11 +42639,10 @@ class scroll_alarm_element_ScrollAlarmElement extends conditional_dynamic_displa
|
|
|
42606
42639
|
contentParts.push(stateMap[alarm.state] || (isChinese ? '触发/未确认' : 'Triggered/Unconfirmed'));
|
|
42607
42640
|
}
|
|
42608
42641
|
const textNode = this._createSvgTextNode(contentParts.join(' '));
|
|
42609
|
-
textNode.setAttribute('
|
|
42642
|
+
textNode.setAttribute('transform', `translate(${xOffset}, 0)`);
|
|
42610
42643
|
this.allAlarmsContainer.appendChild(textNode);
|
|
42611
|
-
const textWidth = textNode
|
|
42612
|
-
|
|
42613
|
-
: (textNode.getBBox ? textNode.getBBox().width : 100);
|
|
42644
|
+
const textWidth = this._getSvgTextWidth(textNode);
|
|
42645
|
+
this._updateUnderlineWidth(textNode, textWidth);
|
|
42614
42646
|
xOffset += textWidth + GAP;
|
|
42615
42647
|
pageWidth += (pageWidth > 0 ? GAP : 0) + textWidth;
|
|
42616
42648
|
});
|
|
@@ -42621,10 +42653,9 @@ class scroll_alarm_element_ScrollAlarmElement extends conditional_dynamic_displa
|
|
|
42621
42653
|
const GAP = 80;
|
|
42622
42654
|
let x = 0;
|
|
42623
42655
|
Array.from(this.allAlarmsContainer.children).forEach(node => {
|
|
42624
|
-
node.setAttribute('
|
|
42625
|
-
const w = node
|
|
42626
|
-
|
|
42627
|
-
: (node.getBBox ? node.getBBox().width : 100);
|
|
42656
|
+
node.setAttribute('transform', `translate(${x}, 0)`);
|
|
42657
|
+
const w = this._getSvgTextWidth(node);
|
|
42658
|
+
this._updateUnderlineWidth(node, w);
|
|
42628
42659
|
x += w + GAP;
|
|
42629
42660
|
});
|
|
42630
42661
|
const newTotal = x > 0 ? x - GAP : 0;
|
|
@@ -42641,14 +42672,13 @@ class scroll_alarm_element_ScrollAlarmElement extends conditional_dynamic_displa
|
|
|
42641
42672
|
elementsToRemove.forEach(el => {
|
|
42642
42673
|
this.allAlarmsContainer.removeChild(el);
|
|
42643
42674
|
});
|
|
42644
|
-
//
|
|
42675
|
+
// g 元素的 transform 从 0 重排(DOM删除后剩余节点要重新编排位置)
|
|
42645
42676
|
const GAP = 80;
|
|
42646
42677
|
let x = 0;
|
|
42647
42678
|
Array.from(this.allAlarmsContainer.children).forEach(node => {
|
|
42648
|
-
node.setAttribute('
|
|
42649
|
-
const w = node
|
|
42650
|
-
|
|
42651
|
-
: (node.getBBox ? node.getBBox().width : 100);
|
|
42679
|
+
node.setAttribute('transform', `translate(${x}, 0)`);
|
|
42680
|
+
const w = this._getSvgTextWidth(node);
|
|
42681
|
+
this._updateUnderlineWidth(node, w);
|
|
42652
42682
|
x += w + GAP;
|
|
42653
42683
|
});
|
|
42654
42684
|
// currentLeft 补偿被移除页的宽度(含 gap),保持视觉位置不变
|
|
@@ -42858,14 +42888,13 @@ class scroll_alarm_element_ScrollAlarmElement extends conditional_dynamic_displa
|
|
|
42858
42888
|
}
|
|
42859
42889
|
// 创建 SVG text 节点(与真实运行模式一致,不依赖 foreignObject)
|
|
42860
42890
|
const textNode = this._createSvgTextNode(textParts.join(' '));
|
|
42861
|
-
textNode.setAttribute('
|
|
42891
|
+
textNode.setAttribute('transform', 'translate(0, 0)');
|
|
42862
42892
|
this.currentLeft = this.model.size.width;
|
|
42863
42893
|
this.allAlarmsContainer.setAttribute('transform', `translate(${this.currentLeft}, 0)`);
|
|
42864
42894
|
this.allAlarmsContainer.appendChild(textNode);
|
|
42865
|
-
// SVG text
|
|
42866
|
-
const textWidth = textNode
|
|
42867
|
-
|
|
42868
|
-
: (textNode.getBBox ? textNode.getBBox().width : 200);
|
|
42895
|
+
// SVG text 宽度通过内部 text 元素的 getComputedTextLength 获取
|
|
42896
|
+
const textWidth = this._getSvgTextWidth(textNode);
|
|
42897
|
+
this._updateUnderlineWidth(textNode, textWidth);
|
|
42869
42898
|
this.totalWidth = textWidth;
|
|
42870
42899
|
this.pageWidths.push(textWidth);
|
|
42871
42900
|
// 启动滚动(autoCycle 只控制是否循环,不控制是否滚动)
|