@flexem/fc-gui 3.0.0-alpha.116 → 3.0.0-alpha.118
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 +46 -66
- 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 +7 -5
- package/elements/shared/text/text-state-element.d.ts +0 -1
- package/elements/shared/text/text-state-element.js +39 -61
- package/elements/shared/text/text-state-element.metadata.json +1 -1
- package/package.json +1 -1
|
@@ -35316,6 +35316,7 @@ class readable_element_ReadableElement extends conditional_enable_element_Condit
|
|
|
35316
35316
|
});
|
|
35317
35317
|
}
|
|
35318
35318
|
reportValueChanged(value) {
|
|
35319
|
+
var _a, _b, _c, _d;
|
|
35319
35320
|
Object(lodash["forEach"])(this.elementStates, elementState => {
|
|
35320
35321
|
if (elementState.variableName === value.variableName || elementState.variableName === value.systemName) {
|
|
35321
35322
|
elementState.state = value.state;
|
|
@@ -35329,20 +35330,21 @@ class readable_element_ReadableElement extends conditional_enable_element_Condit
|
|
|
35329
35330
|
}
|
|
35330
35331
|
if (value.systemName === '设备状态') {
|
|
35331
35332
|
let name = value.customStatus;
|
|
35332
|
-
const language = window.abp.localization.currentCulture.name;
|
|
35333
|
+
const language = ((_b = (_a = window.abp.localization) === null || _a === void 0 ? void 0 : _a.currentCulture) === 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);
|
|
35334
|
+
const isChinese = language === 'zh-Hans' || language === 'zh';
|
|
35333
35335
|
if (!name) {
|
|
35334
35336
|
switch (value.state) {
|
|
35335
35337
|
case 1:
|
|
35336
|
-
name =
|
|
35338
|
+
name = isChinese ? '在线' : 'Online';
|
|
35337
35339
|
break;
|
|
35338
35340
|
case 3:
|
|
35339
|
-
name =
|
|
35341
|
+
name = isChinese ? '离线' : 'Offline';
|
|
35340
35342
|
break;
|
|
35341
35343
|
case 4:
|
|
35342
|
-
name =
|
|
35344
|
+
name = isChinese ? '告警' : 'Alarming';
|
|
35343
35345
|
break;
|
|
35344
35346
|
case 5:
|
|
35345
|
-
name =
|
|
35347
|
+
name = isChinese ? '未绑定' : 'Unbound';
|
|
35346
35348
|
break;
|
|
35347
35349
|
default:
|
|
35348
35350
|
}
|
|
@@ -38892,7 +38894,6 @@ class text_element_TextElement extends conditional_dynamic_display_element_Condi
|
|
|
38892
38894
|
|
|
38893
38895
|
// CONCATENATED MODULE: ./.tmp/elements/shared/text/text-state-element.ts
|
|
38894
38896
|
|
|
38895
|
-
|
|
38896
38897
|
class text_state_element_TextStateElement {
|
|
38897
38898
|
constructor(textStates, width, height, logger, version, faultFlickers) {
|
|
38898
38899
|
this.textStates = textStates;
|
|
@@ -38916,7 +38917,7 @@ class text_state_element_TextStateElement {
|
|
|
38916
38917
|
return;
|
|
38917
38918
|
}
|
|
38918
38919
|
const content = textState.text.content;
|
|
38919
|
-
if (content === '') {
|
|
38920
|
+
if (content === '' || content == null) {
|
|
38920
38921
|
this.removeForeignObjectlement();
|
|
38921
38922
|
return;
|
|
38922
38923
|
}
|
|
@@ -38926,72 +38927,51 @@ class text_state_element_TextStateElement {
|
|
|
38926
38927
|
this.logger.debug('The font is undefined.');
|
|
38927
38928
|
return;
|
|
38928
38929
|
}
|
|
38929
|
-
const
|
|
38930
|
-
|
|
38931
|
-
|
|
38932
|
-
|
|
38933
|
-
|
|
38930
|
+
const textElement = this.getforeignObjectElement();
|
|
38931
|
+
// 清空旧内容
|
|
38932
|
+
textElement.textContent = '';
|
|
38933
|
+
// 设置 text-anchor 和 dominant-baseline
|
|
38934
|
+
textElement.setAttribute('text-anchor', 'middle');
|
|
38935
|
+
textElement.setAttribute('dominant-baseline', 'middle');
|
|
38936
|
+
textElement.setAttribute('pointer-events', 'auto');
|
|
38937
|
+
// 拆分换行
|
|
38938
|
+
const lines = content.split('\n');
|
|
38939
|
+
const fontSize = parseInt(font.fontSize, 10);
|
|
38940
|
+
const lineHeight = fontSize + 4;
|
|
38941
|
+
// 总高度 = 行数 * 行高
|
|
38942
|
+
const totalHeight = lines.length * lineHeight;
|
|
38943
|
+
// 调整文本整体垂直居中(通过 dy)
|
|
38944
|
+
const startY = (this.height / 2) - (totalHeight / 2) + (lineHeight / 2);
|
|
38945
|
+
// 添加每行文本
|
|
38946
|
+
for (let i = 0; i < lines.length; i++) {
|
|
38947
|
+
const tspan = document.createElementNS('http://www.w3.org/2000/svg', 'tspan');
|
|
38948
|
+
tspan.setAttribute('x', (this.width / 2).toString());
|
|
38949
|
+
tspan.setAttribute('y', startY + i * lineHeight + 'px');
|
|
38950
|
+
tspan.textContent = lines[i].replace(/ /g, '\u00A0');
|
|
38951
|
+
tspan.setAttribute('font-size', font.fontSize);
|
|
38952
|
+
tspan.setAttribute('fill', font.color);
|
|
38953
|
+
tspan.setAttribute('font-family', font.fontFamily);
|
|
38954
|
+
tspan.setAttribute('font-weight', font.isBold ? 'bold' : 'normal');
|
|
38955
|
+
tspan.setAttribute('font-style', font.isItalic ? 'italic' : 'normal');
|
|
38956
|
+
tspan.setAttribute('text-decoration', font.isUnderline ? 'underline' : 'none');
|
|
38957
|
+
tspan.setAttribute('text-anchor', 'middle');
|
|
38958
|
+
tspan.setAttribute('dominant-baseline', 'middle');
|
|
38959
|
+
textElement.appendChild(tspan);
|
|
38960
|
+
}
|
|
38961
|
+
this.doFaultFlicker(textElement, stateId);
|
|
38934
38962
|
}
|
|
38935
38963
|
getforeignObjectElement() {
|
|
38936
38964
|
if (!this.textElement) {
|
|
38937
|
-
this.textElement = document.createElementNS('http://www.w3.org/2000/svg', '
|
|
38938
|
-
this.textElement.setAttribute('
|
|
38939
|
-
this.textElement.setAttribute('
|
|
38965
|
+
this.textElement = document.createElementNS('http://www.w3.org/2000/svg', 'text');
|
|
38966
|
+
this.textElement.setAttribute('x', (this.width / 2).toString());
|
|
38967
|
+
this.textElement.setAttribute('y', (this.height / 2).toString());
|
|
38968
|
+
this.textElement.setAttribute('text-anchor', 'middle');
|
|
38969
|
+
this.textElement.setAttribute('dominant-baseline', 'middle');
|
|
38970
|
+
this.textElement.setAttribute('pointer-events', 'auto'); // 确保能接收事件
|
|
38940
38971
|
this._element.appendChild(this.textElement);
|
|
38941
38972
|
}
|
|
38942
38973
|
return this.textElement;
|
|
38943
38974
|
}
|
|
38944
|
-
createNewForeignObjectText(content, font) {
|
|
38945
|
-
if (font && !font.fontFamily.includes(',msyh')) {
|
|
38946
|
-
font.fontFamily += ',msyh';
|
|
38947
|
-
}
|
|
38948
|
-
const bodyDiv = document.createElement('div');
|
|
38949
|
-
bodyDiv.style.textAlign = font.textAlign ? font.textAlign : 'center';
|
|
38950
|
-
bodyDiv.style.userSelect = 'none';
|
|
38951
|
-
bodyDiv.style.display = 'table-cell';
|
|
38952
|
-
bodyDiv.style.verticalAlign = 'middle';
|
|
38953
|
-
if (Object(lodash["isNil"])(content)) {
|
|
38954
|
-
content = '';
|
|
38955
|
-
}
|
|
38956
|
-
let textArray = content.toString().split('\n');
|
|
38957
|
-
textArray = textArray.map(item => {
|
|
38958
|
-
return item.toString().replace(/\s/g, ' ');
|
|
38959
|
-
});
|
|
38960
|
-
const fragment = document.createDocumentFragment();
|
|
38961
|
-
for (let index = 0; index < textArray.length; index++) {
|
|
38962
|
-
const textDiv = document.createElement('div');
|
|
38963
|
-
textDiv.innerHTML = textArray[index] ? textArray[index] : ' ';
|
|
38964
|
-
let fontString = '';
|
|
38965
|
-
if (font.isItalic) {
|
|
38966
|
-
fontString += 'italic ';
|
|
38967
|
-
}
|
|
38968
|
-
if (font.isBold) {
|
|
38969
|
-
fontString += 'bold ';
|
|
38970
|
-
}
|
|
38971
|
-
textDiv.style.wordBreak = 'break-word';
|
|
38972
|
-
textDiv.style.color = font.color;
|
|
38973
|
-
let lineHeight = 0;
|
|
38974
|
-
lineHeight = parseInt(font.fontSize, 10) + 5;
|
|
38975
|
-
fontString += font.fontSize + 'px/' + lineHeight + 'px ' + font.fontFamily;
|
|
38976
|
-
textDiv.style.font = fontString;
|
|
38977
|
-
if (font.isUnderline) {
|
|
38978
|
-
textDiv.style.textDecoration = 'underline';
|
|
38979
|
-
}
|
|
38980
|
-
fragment.appendChild(textDiv);
|
|
38981
|
-
}
|
|
38982
|
-
bodyDiv.appendChild(fragment);
|
|
38983
|
-
const contentDiv = document.createElement('div');
|
|
38984
|
-
contentDiv.style.display = 'table';
|
|
38985
|
-
contentDiv.style.width = '100%';
|
|
38986
|
-
contentDiv.style.height = '100%';
|
|
38987
|
-
contentDiv.appendChild(bodyDiv);
|
|
38988
|
-
const containerDiv = document.createElement('div');
|
|
38989
|
-
containerDiv.style.overflow = 'hidden';
|
|
38990
|
-
containerDiv.style.width = this.width.toString() + 'px';
|
|
38991
|
-
containerDiv.style.height = this.height.toString() + 'px';
|
|
38992
|
-
containerDiv.appendChild(contentDiv);
|
|
38993
|
-
return containerDiv;
|
|
38994
|
-
}
|
|
38995
38975
|
removeForeignObjectlement() {
|
|
38996
38976
|
if (this.textElement) {
|
|
38997
38977
|
this._element.removeChild(this.textElement);
|