export function buildIssueUrl({ repo, label, title, body = "" } = {}) { if (!repo) throw new Error("repo is required, e.g. 'owner/name'"); const params = new URLSearchParams(); if (label) params.set("labels", label); if (title) params.set("title", title); if (body) params.set("body", body); const qs = params.toString(); return `https://github.com/${repo}/issues/new${qs ? "?" + qs : ""}`; } export function appendEntry(ledger, entry) { return { ...ledger, entries: [...(ledger.entries ?? []), entry] }; } export function markReverted(ledger, issueNum, at) { return { ...ledger, entries: (ledger.entries ?? []).map((e) => e.issue === issueNum ? { ...e, status: "reverted", updatedAt: at } : e ), }; } const STATUS_LABEL = { queued: "排队中", working: "处理中", deployed: "已上线", failed: "失败", reverted: "已回滚", }; function escapeHtml(s) { return String(s ?? "").replace(/[&<>"]/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """ }[c])); } export function renderDashboard(ledger, { repo }) { const rows = (ledger.entries ?? []) .slice() .reverse() .map((e) => { const repoPath = repo.split("/").map(encodeURIComponent).join("/"); const commitCell = e.commit ? `${escapeHtml(String(e.commit).slice(0, 7))}` : "—"; const revertUrl = buildIssueUrl({ repo, label: "revert", title: `revert: #${e.issue}`, body: `回滚 #${e.issue} 引入的改动(commit ${e.commit ?? "?"})。`, }); const canRevert = e.commit && e.status === "deployed"; const revertCell = canRevert ? `回滚` : "—"; return `
每条访客建议从提交到上线的记录。新建议出现在最上面。
| # | 建议 | Claude 做了什么 | commit | 状态 | 更新时间 | 操作 |
|---|