feat: enhance hidden domains serialization and UI representation

- Updated `serialize_active_domains` to include both active and inactive hidden domains, adding an `is_open` property for each domain.
- Modified `StatusBar` and `StatusWidget` components to reflect the new domain state, displaying appropriate labels and colors based on the activation status.
- Adjusted localization files for English and Chinese to align with the updated hidden domain features.
This commit is contained in:
bridge
2026-02-01 12:26:43 +08:00
parent d53d5885c0
commit 07dacb8876
6 changed files with 47 additions and 27 deletions

View File

@@ -173,26 +173,40 @@ manager = ConnectionManager()
def serialize_active_domains(world: World) -> List[dict]:
"""序列化当前开启的秘境列表"""
"""序列化所有秘境列表(包括开启和未开启的)"""
domains_data = []
if not world or not world.gathering_manager:
return []
# 找到 HiddenDomain 实例
hidden_domain_gathering = None
for gathering in world.gathering_manager.gatherings:
# Check by class name to avoid circular imports
if gathering.__class__.__name__ == "HiddenDomain":
# Accessing _active_domains safely
active_domains = getattr(gathering, "_active_domains", [])
for d in active_domains:
domains_data.append({
"id": d.id,
"name": d.name,
"desc": d.desc,
# Use str() to trigger Realm.__str__ which returns translated text
"max_realm": str(d.max_realm),
"danger_prob": d.danger_prob,
"drop_prob": d.drop_prob
})
hidden_domain_gathering = gathering
break
if hidden_domain_gathering:
# 获取所有配置(假设 _load_configs 开销不大,或者已缓存)
# 这里为了确保获取最新状态,重新加载配置
# 注意:访问受保护方法 _load_configs
all_configs = hidden_domain_gathering._load_configs()
# 获取当前开启的 ID 集合
active_ids = {d.id for d in hidden_domain_gathering._active_domains}
for d in all_configs:
is_open = d.id in active_ids
domains_data.append({
"id": d.id,
"name": d.name,
"desc": d.desc,
"max_realm": str(d.max_realm),
"danger_prob": d.danger_prob,
"drop_prob": d.drop_prob,
"is_open": is_open
})
return domains_data
def serialize_events_for_client(events: List[Event]) -> List[dict]:

View File

@@ -19,14 +19,13 @@ const phenomenonColor = computed(() => {
})
const domainLabel = computed(() => {
const count = store.activeDomains.length;
return count > 0
? t('game.status_bar.hidden_domain.label_active', { count })
: t('game.status_bar.hidden_domain.label');
return t('game.status_bar.hidden_domain.label');
});
const domainColor = computed(() => {
return store.activeDomains.length > 0 ? '#fa8c16' : '#666'; // 有秘境时亮橙色,否则灰
// 如果有任意一个秘境是开启状态,则亮
const anyOpen = store.activeDomains.some(d => d.is_open);
return anyOpen ? '#fa8c16' : '#666'; // 有开启亮橙色,全关闭灰色
});
function getRarityColor(rarity: string) {

View File

@@ -52,9 +52,13 @@ const emit = defineEmits(['trigger-click'])
<n-list v-if="items.length > 0" hoverable clickable>
<n-list-item v-for="item in items" :key="item.id">
<div class="domain-item">
<div class="domain-item" :class="{ 'is-closed': !item.is_open }">
<div class="d-header">
<span class="d-name">{{ item.name }}</span>
<div class="d-title-group">
<span class="d-name">{{ item.name }}</span>
<n-tag v-if="!item.is_open" size="small" :bordered="false" class="d-status closed">未开启</n-tag>
<n-tag v-else size="small" :bordered="false" type="success" class="d-status open">开启中</n-tag>
</div>
<n-tag size="small" :bordered="false" type="warning" class="d-tag">
{{ item.max_realm }}
</n-tag>
@@ -92,9 +96,13 @@ const emit = defineEmits(['trigger-click'])
}
.domain-item { padding: 4px 0; }
.domain-item.is-closed { opacity: 0.5; filter: grayscale(0.8); }
.d-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.d-title-group { display: flex; align-items: center; gap: 8px; }
.d-name { font-weight: bold; color: #fadb14; font-size: 14px; }
.d-tag { font-size: 10px; height: 18px; line-height: 18px; }
.d-status { font-size: 10px; height: 18px; line-height: 18px; padding: 0 4px; }
.d-desc { font-size: 12px; color: #aaa; margin-bottom: 8px; line-height: 1.4; }
.d-stats { display: flex; gap: 12px; font-size: 12px; color: #888; }
.empty-state { padding: 20px; }

View File

@@ -233,9 +233,8 @@
"author_github": "Github",
"hidden_domain": {
"label": "[Hidden Domain]",
"label_active": "[Domain Opened: {count}]",
"title": "Opened Hidden Domains",
"empty": "No hidden domains currently open",
"title": "Hidden Domains List",
"empty": "No hidden domains data",
"danger": "Danger",
"drop": "Fortune"
}

View File

@@ -233,9 +233,8 @@
"author_github": "Github仓库",
"hidden_domain": {
"label": "[秘境]",
"label_active": "[秘境开启: {count}]",
"title": "当前开启秘境",
"empty": "当前暂无秘境开启",
"title": "秘境列表",
"empty": "暂无秘境数据",
"danger": "凶险",
"drop": "机缘"
}

View File

@@ -193,6 +193,7 @@ export interface HiddenDomainInfo {
max_realm: string; // 限制境界
danger_prob: number; // 凶险度 (0.0 - 1.0)
drop_prob: number; // 机缘度 (0.0 - 1.0)
is_open: boolean; // 是否开启
}
// --- 事件 (Events) ---