diff --git a/frontend/src/views/Dashboard/Dashboard.js b/frontend/src/views/Dashboard/Dashboard.js index 3b9e635..eb45b34 100644 --- a/frontend/src/views/Dashboard/Dashboard.js +++ b/frontend/src/views/Dashboard/Dashboard.js @@ -303,6 +303,9 @@ export function useDashboard() { } function auditActionLabel(value) { + if (typeof value === "string" && /\p{Script=Han}/u.test(value)) { + return value.trim(); + } return displayLabel(auditActionLabels, value); } diff --git a/frontend/src/views/Dashboard/Dashboard.test.js b/frontend/src/views/Dashboard/Dashboard.test.js index 3ee7382..5b45e65 100644 --- a/frontend/src/views/Dashboard/Dashboard.test.js +++ b/frontend/src/views/Dashboard/Dashboard.test.js @@ -151,3 +151,15 @@ test("关闭管理设置会停止 DNS 等待计时器", async (t) => { pending.resolve(verifiedResponse()); await task; }); + +test("auditActionLabel", async (t) => { + const { state } = await setup(t, () => verifiedResponse()); + const localized = state.auditActionLabels.settings_update; + assert.equal(state.auditActionLabel(localized), localized); + assert.equal(state.auditActionLabel(` ${localized} `), localized); + assert.equal(state.auditActionLabel("settings_update"), localized); + assert.equal(state.auditActionLabel("unmapped_action"), state.taskTypeLabel("unmapped_action")); + assert.equal(state.auditActionLabel(null), state.taskTypeLabel(null)); + assert.equal(state.auditActionLabel(undefined), state.taskTypeLabel(undefined)); + assert.equal(state.auditActionLabel(""), state.taskTypeLabel("")); +}); \ No newline at end of file