feat(i18n): key runtime status text

This commit is contained in:
youzini
2026-06-05 10:58:21 +00:00
parent 24a02459dc
commit ef341dc9b9
9 changed files with 217 additions and 55 deletions

View File

@@ -3,6 +3,7 @@
// Extracted from index.js so the notice wording/contract can be tested by
// direct import instead of slicing index.js. Side effects are delivered through
// an injected updateStageNotice, so this module holds no global state.
import { t } from "../i18n/index.js";
/**
* Emits the "history changed" stage notice (persistent + busy), without a
@@ -17,8 +18,11 @@ export function notifyHistoryDirtyNotice({ dirtyFrom, reason, updateStageNotice
if (typeof updateStageNotice !== "function") return;
updateStageNotice(
"history",
"检测到楼层历史变化",
`将从楼层 ${dirtyFrom} 之后自动恢复${reason ? `\n${reason}` : ""}`,
t("history.notice.dirty.title"),
t("history.notice.dirty.detail", {
dirtyFrom,
reasonText: reason ? t("history.notice.dirty.reasonSuffix", { reason }) : "",
}),
"warning",
{
persist: true,

View File

@@ -66,6 +66,8 @@ import {
normalizeMaintenanceExecutionMode,
} from "../runtime/concurrency.js";
import {
formatUiStatusMeta,
formatUiStatusText,
hydrateI18n,
setLocale,
t,
@@ -4727,7 +4729,7 @@ function _refreshDashboard() {
.join(" · ")
: "暂无恢复记录",
);
_setText("bme-status-last-extract", extractionStatus.meta || "尚未执行提取");
_setText("bme-status-last-extract", formatUiStatusMeta(extractionStatus) || t("status.initial.extraction.detail"));
_setText(
"bme-status-last-persist",
_formatDashboardPersistMeta(loadInfo, lastBatchStatus),
@@ -4737,9 +4739,9 @@ function _refreshDashboard() {
_formatBackgroundMaintenanceSummary(loadInfo?.backgroundMaintenance, lastBatchStatus),
);
_refreshPersistenceRepairUi(loadInfo, lastBatchStatus);
_setText("bme-status-last-vector", vectorStatus.meta || "尚未执行向量任务");
_setText("bme-status-last-vector", formatUiStatusMeta(vectorStatus) || t("status.initial.vector.detail"));
_setText("bme-status-authority-job", authorityJobUi.detail || authorityJobUi.label);
_setText("bme-status-last-recall", recallStatus.meta || "尚未执行召回");
_setText("bme-status-last-recall", formatUiStatusMeta(recallStatus) || t("status.initial.recall.detail"));
_refreshCognitionDashboard(graph);
_renderRecentList("bme-recent-extract", _getLastExtract?.() || []);
@@ -14307,8 +14309,8 @@ function _refreshRuntimeStatus() {
const runtimeStatus = _getRuntimeStatus?.() || {};
const graphPersistence = _getGraphPersistenceSnapshot?.() || {};
const upgradeState = graphPersistence.authorityUpgradeState || {};
const text = runtimeStatus.text || "待命";
const meta = runtimeStatus.meta || "准备就绪";
const text = formatUiStatusText(runtimeStatus) || t("status.idle");
const meta = formatUiStatusMeta(runtimeStatus) || t("status.initial.runtime.detail");
const upgradeText = upgradeState.text || graphPersistence.authorityUpgradeText || "";
const displayMeta = upgradeText ? `${meta} · ${upgradeText}` : meta;
_setText("bme-status-text", text);
@@ -14331,7 +14333,7 @@ function _syncFloatingBallWithRuntimeStatus() {
const status = _getRuntimeStatus?.() || {};
const level = String(status.level || "idle");
const fabStatus = level === "info" ? "idle" : level;
updateFloatingBallStatus(fabStatus, status.text || t("panel.entry.floatingTooltip"));
updateFloatingBallStatus(fabStatus, formatUiStatusText(status) || t("panel.entry.floatingTooltip"));
}
function _patchSettings(patch = {}, options = {}) {

View File

@@ -4,6 +4,7 @@
import { sanitizePlannerMessageText } from "../runtime/planner-tag-utils.js";
import { AUTHORITY_DIAGNOSTICS_MANIFEST_LIMIT } from "../maintenance/authority-diagnostics-bundle.js";
import { createAuthorityUpgradeState } from "../runtime/authority-upgrade-state.js";
import { createI18nStatus, t } from "../i18n/index.js";
// ═══════════════════════════════════════════════════════════
// 常量
@@ -21,6 +22,12 @@ export const BATCH_STAGE_SEVERITY = {
// ═══════════════════════════════════════════════════════════
export function createUiStatus(text = "待命", meta = "", level = "idle") {
if (text && typeof text === "object") {
return createI18nStatus({
...(text || {}),
level: text.level || level || "idle",
});
}
return {
text: String(text || "待命"),
meta: String(meta || ""),
@@ -439,15 +446,15 @@ export function normalizeStageNoticeLevel(level = "info") {
export function getStageNoticeTitle(stage) {
switch (stage) {
case "extraction":
return "ST-BME 提取";
return t("stageNotice.title.extraction");
case "vector":
return "ST-BME 向量";
return t("stageNotice.title.vector");
case "recall":
return "ST-BME 召回";
return t("stageNotice.title.recall");
case "history":
return "ST-BME 历史恢复";
return t("stageNotice.title.history");
default:
return "ST-BME";
return t("stageNotice.title.generic");
}
}