兼容中文审计动作并保留未知类型兜底

This commit is contained in:
xuans 2026-09-24 23:37:50 +08:00
parent 0405bb3d90
commit d2e3cc2a52
2 changed files with 15 additions and 0 deletions

View File

@ -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);
}

View File

@ -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(""));
});