56 lines
1.3 KiB
JavaScript
56 lines
1.3 KiB
JavaScript
/* Status badge renderer (Bootstrap pill). */
|
|
|
|
import { escapeHtml } from "../utils.js";
|
|
|
|
const COLOR_MAP = {
|
|
// chapter / job statuses
|
|
pending: "secondary",
|
|
outlined: "info",
|
|
drafting: "warning",
|
|
done: "success",
|
|
reviewed: "primary",
|
|
running: "warning",
|
|
failed: "danger",
|
|
// novel statuses
|
|
planning: "secondary",
|
|
outlining: "info",
|
|
reviewing: "primary",
|
|
completed: "success",
|
|
// character statuses
|
|
alive: "success",
|
|
dead: "dark",
|
|
unknown: "secondary",
|
|
// foreshadowing statuses
|
|
planted: "info",
|
|
resolved: "success",
|
|
missed: "danger",
|
|
};
|
|
|
|
const LABEL_MAP = {
|
|
pending: "待处理",
|
|
outlined: "已列纲",
|
|
drafting: "写作中",
|
|
done: "已完成",
|
|
reviewed: "已审阅",
|
|
running: "运行中",
|
|
failed: "失败",
|
|
planning: "筹划中",
|
|
outlining: "大纲中",
|
|
reviewing: "审阅中",
|
|
completed: "完本",
|
|
alive: "存活",
|
|
dead: "死亡",
|
|
unknown: "未知",
|
|
planted: "已埋设",
|
|
resolved: "已回收",
|
|
missed: "已遗漏",
|
|
};
|
|
|
|
/** Return a badge HTML string for a status. */
|
|
export function statusBadge(status) {
|
|
const key = String(status || "pending");
|
|
const color = COLOR_MAP[key] || "secondary";
|
|
const label = LABEL_MAP[key] || key;
|
|
return `<span class="badge text-bg-${color}">${escapeHtml(label)}</span>`;
|
|
}
|