所有 Personal Access Tokens
共 ${rows.length} 个(生效中 ${activeCount},已吊销/过期 ${revokedCount})
${flashHtml}import { THEME_CSS, escapeHtml, escapeAttr, tabNavHTML } from "../render/layout"; import { parsePatIpAllowlist, type PatWithUser, type UserRow } from "../store"; interface Flash { kind: "ok" | "err"; msg: string; } function statusBadge(row: PatWithUser): string { if (row.revoked_at) return `已吊销`; if (row.expires_at && Date.parse(row.expires_at) < Date.now()) { return `已过期`; } return `生效中`; } function parseScopes(raw: string): string[] { try { const v = JSON.parse(raw); return Array.isArray(v) ? v.filter((x) => typeof x === "string") : []; } catch { return []; } } export function buildAdminTokensPage( viewer: UserRow, rows: PatWithUser[], flash: Flash | null, ): string { const flashHtml = flash ? `
| 名称 | 用户 | token | scopes | IP | 状态 | 最近使用 | 创建 | 操作 |
|---|---|---|---|---|---|---|---|---|
| ${escapeHtml(r.name)} | ${escapeHtml(r.user_login)} ${ownerNote} ${userBadges.join(" ")} | …${escapeHtml(r.token_last_eight)} |
${scopes} | ${ipCell} | ${statusBadge(r)} | ${lastUsed} | ${escapeHtml(r.created_at.slice(0, 10))} | ${ revoked ? "" : `` } |
共 ${rows.length} 个(生效中 ${activeCount},已吊销/过期 ${revokedCount})
${flashHtml}