@flexem/fc-gui 3.0.0-alpha.138 → 3.0.0-alpha.139
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.
|
@@ -39411,6 +39411,30 @@ class text_state_element_TextStateElement {
|
|
|
39411
39411
|
*/
|
|
39412
39412
|
getDisplayText(stateId, defaultContent) {
|
|
39413
39413
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
39414
|
+
// 如果 defaultContent 是多语种对象,优先使用(覆盖文本库)
|
|
39415
|
+
if (defaultContent && typeof defaultContent === 'object' && defaultContent.cultures) {
|
|
39416
|
+
const currentLanguageId = (_c = (_b = (_a = this.guiContext) === null || _a === void 0 ? void 0 : _a.getCurrentLanguageId) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : null;
|
|
39417
|
+
const defaultLanguage = ((_d = this.languageService) === null || _d === void 0 ? void 0 : _d.getDefaultLanguage()) || 'zh-CN';
|
|
39418
|
+
let targetLanguage;
|
|
39419
|
+
if (currentLanguageId === null || currentLanguageId === undefined) {
|
|
39420
|
+
targetLanguage = defaultLanguage;
|
|
39421
|
+
}
|
|
39422
|
+
else {
|
|
39423
|
+
const currentLanguage = (_f = (_e = this.guiContext) === null || _e === void 0 ? void 0 : _e.getLanguageCultureById) === null || _f === void 0 ? void 0 : _f.call(_e, currentLanguageId);
|
|
39424
|
+
targetLanguage = currentLanguage || defaultLanguage;
|
|
39425
|
+
}
|
|
39426
|
+
if (defaultContent.cultures[targetLanguage]) {
|
|
39427
|
+
return defaultContent.cultures[targetLanguage];
|
|
39428
|
+
}
|
|
39429
|
+
else if (this.allowEmpty) {
|
|
39430
|
+
return '';
|
|
39431
|
+
}
|
|
39432
|
+
else {
|
|
39433
|
+
const language = ((_j = (_h = (_g = window.abp) === null || _g === void 0 ? void 0 : _g.localization) === null || _h === void 0 ? void 0 : _h.currentLanguage) === null || _j === void 0 ? void 0 : _j.name) || 'zh-Hans';
|
|
39434
|
+
const isChinese = language === 'zh-Hans' || language === 'zh';
|
|
39435
|
+
return isChinese ? '文本' : 'Text';
|
|
39436
|
+
}
|
|
39437
|
+
}
|
|
39414
39438
|
// 检查是否使用文本库
|
|
39415
39439
|
if (this.textLibrarySetting && this.textLibrarySetting.labelType === 'textLibrary') {
|
|
39416
39440
|
const textLibraryId = this.textLibrarySetting.selectedTextLibraryItem;
|
|
@@ -39422,17 +39446,17 @@ class text_state_element_TextStateElement {
|
|
|
39422
39446
|
const textEntry = textLibraryData.data.find(entry => entry.value === stateId.toString());
|
|
39423
39447
|
if (textEntry) {
|
|
39424
39448
|
// 获取当前语种ID
|
|
39425
|
-
const currentLanguageId = (
|
|
39449
|
+
const currentLanguageId = (_m = (_l = (_k = this.guiContext) === null || _k === void 0 ? void 0 : _k.getCurrentLanguageId) === null || _l === void 0 ? void 0 : _l.call(_k)) !== null && _m !== void 0 ? _m : null;
|
|
39426
39450
|
// 确定要使用的语种代码(culture)
|
|
39427
39451
|
let targetLanguage;
|
|
39428
|
-
const defaultLanguage = ((
|
|
39452
|
+
const defaultLanguage = ((_o = this.languageService) === null || _o === void 0 ? void 0 : _o.getDefaultLanguage()) || 'zh-CN';
|
|
39429
39453
|
if (currentLanguageId === null || currentLanguageId === undefined) {
|
|
39430
39454
|
// 设备未设置当前语种,使用默认语种
|
|
39431
39455
|
targetLanguage = defaultLanguage;
|
|
39432
39456
|
}
|
|
39433
39457
|
else {
|
|
39434
39458
|
// 设备已设置当前语种,获取对应的语种代码
|
|
39435
|
-
const currentLanguage = (
|
|
39459
|
+
const currentLanguage = (_q = (_p = this.guiContext) === null || _p === void 0 ? void 0 : _p.getLanguageCultureById) === null || _q === void 0 ? void 0 : _q.call(_p, currentLanguageId);
|
|
39436
39460
|
if (currentLanguage) {
|
|
39437
39461
|
// 直接使用设备设置的语种,不再fallback
|
|
39438
39462
|
targetLanguage = currentLanguage;
|
|
@@ -39451,58 +39475,12 @@ class text_state_element_TextStateElement {
|
|
|
39451
39475
|
return '';
|
|
39452
39476
|
}
|
|
39453
39477
|
}
|
|
39454
|
-
// 文本库中未找到对应的状态ID(可能是"其他"状态)
|
|
39455
|
-
// 继续检查 defaultContent 中是否有多语种数据
|
|
39456
39478
|
}
|
|
39457
39479
|
}
|
|
39458
|
-
// 文本库模式下,如果文本库中没有找到数据,继续尝试从 defaultContent 获取
|
|
39459
|
-
// 这样可以支持"其他"状态的多语种显示
|
|
39460
39480
|
}
|
|
39461
|
-
//
|
|
39462
|
-
if (defaultContent) {
|
|
39463
|
-
|
|
39464
|
-
if (typeof defaultContent === 'object' && defaultContent.cultures) {
|
|
39465
|
-
// 新格式:多语种对象
|
|
39466
|
-
// 获取当前语种ID
|
|
39467
|
-
const currentLanguageId = (_j = (_h = (_g = this.guiContext) === null || _g === void 0 ? void 0 : _g.getCurrentLanguageId) === null || _h === void 0 ? void 0 : _h.call(_g)) !== null && _j !== void 0 ? _j : null;
|
|
39468
|
-
// 确定要使用的语种代码(culture)
|
|
39469
|
-
let targetLanguage;
|
|
39470
|
-
const defaultLanguage = ((_k = this.languageService) === null || _k === void 0 ? void 0 : _k.getDefaultLanguage()) || 'zh-CN';
|
|
39471
|
-
if (currentLanguageId === null || currentLanguageId === undefined) {
|
|
39472
|
-
// 设备未设置当前语种,使用默认语种
|
|
39473
|
-
targetLanguage = defaultLanguage;
|
|
39474
|
-
}
|
|
39475
|
-
else {
|
|
39476
|
-
// 设备已设置当前语种,获取对应的语种代码
|
|
39477
|
-
const currentLanguage = (_m = (_l = this.guiContext) === null || _l === void 0 ? void 0 : _l.getLanguageCultureById) === null || _m === void 0 ? void 0 : _m.call(_l, currentLanguageId);
|
|
39478
|
-
if (currentLanguage) {
|
|
39479
|
-
targetLanguage = currentLanguage;
|
|
39480
|
-
}
|
|
39481
|
-
else {
|
|
39482
|
-
targetLanguage = defaultLanguage;
|
|
39483
|
-
}
|
|
39484
|
-
}
|
|
39485
|
-
// 返回对应语种的文本
|
|
39486
|
-
// 如果没有对应语种的内容:
|
|
39487
|
-
// - allowEmpty=true(开关指示灯):返回空字符串
|
|
39488
|
-
// - allowEmpty=false(文本元件):返回默认文本
|
|
39489
|
-
if (defaultContent.cultures[targetLanguage]) {
|
|
39490
|
-
return defaultContent.cultures[targetLanguage];
|
|
39491
|
-
}
|
|
39492
|
-
else if (this.allowEmpty) {
|
|
39493
|
-
return '';
|
|
39494
|
-
}
|
|
39495
|
-
else {
|
|
39496
|
-
// 获取当前语言环境,显示默认文本
|
|
39497
|
-
const language = ((_q = (_p = (_o = window.abp) === null || _o === void 0 ? void 0 : _o.localization) === null || _p === void 0 ? void 0 : _p.currentLanguage) === null || _q === void 0 ? void 0 : _q.name) || 'zh-Hans';
|
|
39498
|
-
const isChinese = language === 'zh-Hans' || language === 'zh';
|
|
39499
|
-
return isChinese ? '文本' : 'Text';
|
|
39500
|
-
}
|
|
39501
|
-
}
|
|
39502
|
-
else if (typeof defaultContent === 'string') {
|
|
39503
|
-
// 旧格式:字符串
|
|
39504
|
-
return defaultContent;
|
|
39505
|
-
}
|
|
39481
|
+
// 处理字符串格式的 defaultContent
|
|
39482
|
+
if (typeof defaultContent === 'string') {
|
|
39483
|
+
return defaultContent;
|
|
39506
39484
|
}
|
|
39507
39485
|
return '';
|
|
39508
39486
|
}
|