feat: add logs and media preview panels

这个提交存在于:
YokiiroBW 2026-07-05 11:19:21 +08:00
父节点 e7ea442374
当前提交 01dac03ec7
共有 11 个文件被更改,包括 245 次插入 和 29 次删除

查看文件

@ -27,5 +27,10 @@ export const endpoints = {
apiDiscoveryProbeModel: "api-discovery/probe-model",
apiDiscoveryCapabilities: "api-discovery/capabilities",
apiDiscoveryManualOverride: "api-discovery/manual-override",
generationLogs: "logs/generation",
workflowLogs: "logs/workflows",
errorLogs: "logs/errors",
integrationLogs: "logs/integrations",
auditLogs: "security/audit-logs",
webManifest: "web/manifest",
} as const

查看文件

@ -0,0 +1,62 @@
export interface GenerationLog {
task_id: string
profile_id?: string | null
workflow_id?: string | null
node_id?: string | null
status: string
progress: number
error_message?: string | null
created_at: string
updated_at: string
}
export interface WorkflowLog {
history_id: string
profile_id: string
workflow_id: string
node_id?: string | null
image_id?: string | null
branch_name?: string | null
action: string
title?: string | null
created_at: string
}
export interface ErrorLog {
source: string
id: string
status: string
error_message?: string | null
created_at: string
}
export interface IntegrationLog {
integration_log_id: string
integration_name: string
action: string
status: string
error_message?: string | null
created_at: string
}
export interface AuditLog {
audit_id: string
request_id: string
actor_type: string
actor_id: string
action: string
target_type: string
target_id: string
before_snapshot?: unknown
after_snapshot?: unknown
metadata?: unknown
created_at: string
}
export interface LogBundle {
generation: GenerationLog[]
workflows: WorkflowLog[]
errors: ErrorLog[]
integrations: IntegrationLog[]
audit: AuditLog[]
}

查看文件

@ -8,3 +8,12 @@ export interface StorageStatus {
}>
total_bytes: number
}
export interface MediaSignResult {
uri: string
token: string
expires_at: number
url: string
content_type: string
size_bytes: number
}

查看文件

@ -6,6 +6,7 @@ import type { UiBootstrap } from "../../shared/types/bootstrap"
import type { DashboardSummary } from "../../shared/types/dashboard"
import type { ApiDialect, CapabilityProfile } from "../../shared/types/discovery"
import type { JobListResult } from "../../shared/types/job"
import type { LogBundle } from "../../shared/types/logs"
import type { MaterialCategory, MaterialListResult } from "../../shared/types/material"
import type { ProfileListResult } from "../../shared/types/profile"
import type {
@ -14,10 +15,10 @@ import type {
ReloadSettingsResult,
SettingsSchema,
} from "../../shared/types/settings"
import type { StorageStatus } from "../../shared/types/storage"
import type { MediaSignResult, StorageStatus } from "../../shared/types/storage"
import type { WardrobeItem, WardrobeMatchResult } from "../../shared/types/wardrobe"
type ViewKey = "dashboard" | "profiles" | "materials" | "wardrobe" | "jobs" | "discovery" | "settings"
type ViewKey = "dashboard" | "profiles" | "materials" | "wardrobe" | "jobs" | "discovery" | "logs" | "settings"
const activeView = ref<ViewKey>("dashboard")
const bootstrap = ref<UiBootstrap | null>(null)
@ -33,6 +34,8 @@ const wardrobe = ref<WardrobeItem[]>([])
const dialects = ref<ApiDialect[]>([])
const capabilities = ref<CapabilityProfile[]>([])
const wardrobeMatch = ref<WardrobeMatchResult | null>(null)
const logs = ref<LogBundle>({ generation: [], workflows: [], errors: [], integrations: [], audit: [] })
const signedMedia = ref<MediaSignResult | null>(null)
const lastOperation = ref("")
const loading = ref(true)
const busy = ref("")
@ -55,6 +58,7 @@ const activeTitle = computed(() => {
wardrobe: "角色衣橱",
jobs: "任务队列",
discovery: "能力探测",
logs: "日志审计",
settings: "设置",
}
return titles[activeView.value]
@ -103,6 +107,7 @@ async function load() {
dialects.value = dialectData
capabilities.value = capabilityData
await loadWardrobe(profileData.items[0]?.profile_id)
await loadLogs()
} catch (err) {
error.value = err instanceof Error ? err.message : "加载失败"
} finally {
@ -110,6 +115,27 @@ async function load() {
}
}
async function loadLogs() {
const [generation, workflows, errors, integrations, audit] = await Promise.allSettled([
getJson<LogBundle["generation"]>(endpoints.generationLogs, { limit: 12 }),
getJson<LogBundle["workflows"]>(endpoints.workflowLogs, { limit: 12 }),
getJson<LogBundle["errors"]>(endpoints.errorLogs, { limit: 12 }),
getJson<LogBundle["integrations"]>(endpoints.integrationLogs, { limit: 12 }),
getJson<LogBundle["audit"]>(endpoints.auditLogs, { limit: 12 }),
])
logs.value = {
generation: settledValue(generation),
workflows: settledValue(workflows),
errors: settledValue(errors),
integrations: settledValue(integrations),
audit: settledValue(audit),
}
}
function settledValue<T>(result: PromiseSettledResult<T[]>): T[] {
return result.status === "fulfilled" ? result.value : []
}
async function loadWardrobe(profileId?: string) {
if (!profileId) {
wardrobe.value = []
@ -196,6 +222,22 @@ function exportSettings() {
return runOperation("导出设置", () => getJson<ExportSettingsResult>(endpoints.settingsExport), false)
}
function signFirstMaterial() {
const uri = materials.value?.items.find((item) => item.image_uri?.startsWith("storage://"))?.image_uri
if (!uri) {
lastOperation.value = "没有可签名的素材图片"
return Promise.resolve()
}
return runOperation(
"签名素材",
async () => {
signedMedia.value = await getJson<MediaSignResult>(endpoints.mediaSign, { uri })
return signedMedia.value
},
false,
)
}
function formatBytes(value = 0) {
if (value < 1024) return `${value} B`
if (value < 1024 * 1024) return `${(value / 1024).toFixed(1)} KB`
@ -234,6 +276,9 @@ function storageRootBytes(uriPrefix: string) {
<button type="button" :class="{ active: activeView === 'discovery' }" @click="activeView = 'discovery'">
探测
</button>
<button type="button" :class="{ active: activeView === 'logs' }" @click="activeView = 'logs'">
日志
</button>
<button type="button" :class="{ active: activeView === 'settings' }" @click="activeView = 'settings'">
设置
</button>
@ -313,7 +358,10 @@ function storageRootBytes(uriPrefix: string) {
<div class="list-view">
<header>
<h2>素材条目</h2>
<span>{{ pendingRecognition }} 待确认</span>
<div class="inline-actions">
<span>{{ pendingRecognition }} 待确认</span>
<button type="button" :disabled="Boolean(busy)" @click="signFirstMaterial">签名首图</button>
</div>
</header>
<ul>
<li v-for="material in materials?.items ?? []" :key="material.material_id">
@ -325,6 +373,7 @@ function storageRootBytes(uriPrefix: string) {
</li>
<li v-if="!materials?.items.length" class="empty">暂无素材</li>
</ul>
<pre v-if="signedMedia">{{ JSON.stringify(signedMedia, null, 2) }}</pre>
</div>
</section>
@ -406,6 +455,95 @@ function storageRootBytes(uriPrefix: string) {
</div>
</section>
<section v-if="activeView === 'logs'" class="logs-view">
<div class="split-view">
<div class="list-view">
<header>
<h2>生成日志</h2>
<span>{{ logs.generation.length }}</span>
</header>
<ul>
<li v-for="item in logs.generation" :key="item.task_id">
<div>
<strong>{{ item.task_id }}</strong>
<small>{{ item.status }} · {{ item.progress }}%</small>
</div>
<span>{{ item.created_at }}</span>
</li>
<li v-if="!logs.generation.length" class="empty">暂无生成日志</li>
</ul>
</div>
<div class="list-view">
<header>
<h2>错误</h2>
<span>{{ logs.errors.length }}</span>
</header>
<ul>
<li v-for="item in logs.errors" :key="`${item.source}-${item.id}`">
<div>
<strong>{{ item.source }}</strong>
<small>{{ item.error_message ?? "无错误详情" }}</small>
</div>
<span class="badge">{{ item.status }}</span>
</li>
<li v-if="!logs.errors.length" class="empty">暂无错误</li>
</ul>
</div>
</div>
<div class="split-view">
<div class="list-view">
<header>
<h2>工作流</h2>
<span>{{ logs.workflows.length }}</span>
</header>
<ul>
<li v-for="item in logs.workflows" :key="item.history_id">
<div>
<strong>{{ item.action }}</strong>
<small>{{ item.title ?? item.workflow_id }}</small>
</div>
<span>{{ item.branch_name ?? "main" }}</span>
</li>
<li v-if="!logs.workflows.length" class="empty">暂无工作流日志</li>
</ul>
</div>
<div class="list-view">
<header>
<h2>集成</h2>
<span>{{ logs.integrations.length }}</span>
</header>
<ul>
<li v-for="item in logs.integrations" :key="item.integration_log_id">
<div>
<strong>{{ item.integration_name }}</strong>
<small>{{ item.action }}</small>
</div>
<span class="badge">{{ item.status }}</span>
</li>
<li v-if="!logs.integrations.length" class="empty">暂无集成日志</li>
</ul>
</div>
</div>
<div class="list-view">
<header>
<h2>审计</h2>
<span>{{ logs.audit.length }}</span>
</header>
<ul>
<li v-for="item in logs.audit" :key="item.audit_id">
<div>
<strong>{{ item.action }}</strong>
<small>{{ item.actor_type }} / {{ item.target_type }} / {{ item.target_id }}</small>
</div>
<span>{{ item.created_at }}</span>
</li>
<li v-if="!logs.audit.length" class="empty">暂无审计日志</li>
</ul>
</div>
</section>
<section v-if="activeView === 'settings'" class="settings-view">
<div class="toolbar">
<button type="button" :disabled="Boolean(busy)" @click="reloadSettings">重载</button>
@ -636,11 +774,13 @@ article strong {
}
.list-view,
.logs-view,
.settings-view {
margin-top: 18px;
}
.split-view .list-view {
.split-view .list-view,
.logs-view .list-view {
margin-top: 0;
}

查看文件

@ -1,3 +1,3 @@
<script type="module" crossorigin src="/assets/index-C3__Rxat.js"></script>
<script type="module" crossorigin src="/assets/index-CLV-WhF9.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-KxvCyOGk.css">
<div id="app"></div>

查看文件

@ -0,0 +1 @@
.web-shell[data-v-0ef32593]{box-sizing:border-box;display:grid;grid-template-columns:220px minmax(0,1fr) 260px;min-height:100vh;color:#1b2430;background:#f5f6f8;font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}.sidebar[data-v-0ef32593],.inspector[data-v-0ef32593]{background:#fff}.sidebar[data-v-0ef32593]{border-right:1px solid #d9e0e8;padding:20px}.inspector[data-v-0ef32593]{border-left:1px solid #d9e0e8;padding:20px}.brand[data-v-0ef32593]{display:grid;gap:4px;margin-bottom:24px}.brand strong[data-v-0ef32593]{font-size:19px}.brand span[data-v-0ef32593],p[data-v-0ef32593],dt[data-v-0ef32593],.empty[data-v-0ef32593],small[data-v-0ef32593]{color:#667085}nav[data-v-0ef32593]{display:grid;gap:6px}button[data-v-0ef32593]{min-height:36px;border:1px solid #c7d0da;border-radius:6px;color:#1b2430;background:#fff;font:inherit;text-align:center;cursor:pointer}button[data-v-0ef32593]:disabled{cursor:wait;opacity:.62}nav button[data-v-0ef32593]{border-color:transparent;background:transparent;text-align:left;padding:0 10px}button.active[data-v-0ef32593]{border-color:#b8d8cf;color:#164f43;background:#e5f4ef}.workspace[data-v-0ef32593]{min-width:0;padding:24px}.topbar[data-v-0ef32593],.list-view header[data-v-0ef32593],.toolbar[data-v-0ef32593],.inline-actions[data-v-0ef32593]{display:flex;gap:12px;align-items:center}.topbar[data-v-0ef32593],.list-view header[data-v-0ef32593]{justify-content:space-between}.actions[data-v-0ef32593],.inline-actions[data-v-0ef32593]{flex-wrap:wrap;justify-content:flex-end}.topbar button[data-v-0ef32593],.toolbar button[data-v-0ef32593],.list-view header button[data-v-0ef32593],.inline-actions button[data-v-0ef32593]{padding:0 14px}h1[data-v-0ef32593],h2[data-v-0ef32593],p[data-v-0ef32593],dl[data-v-0ef32593],dd[data-v-0ef32593]{margin:0}h1[data-v-0ef32593]{min-height:30px;font-size:26px}h2[data-v-0ef32593]{font-size:15px}.notice[data-v-0ef32593],article[data-v-0ef32593],.list-view[data-v-0ef32593],pre[data-v-0ef32593]{border:1px solid #d9e0e8;border-radius:8px;background:#fff}.notice[data-v-0ef32593]{margin-top:18px;padding:14px}.error[data-v-0ef32593]{border-color:#f0b4b4;color:#8a1f1f;background:#fff7f7}.dashboard-grid[data-v-0ef32593],.split-view[data-v-0ef32593]{display:grid;gap:12px;margin-top:18px}.dashboard-grid[data-v-0ef32593]{grid-template-columns:repeat(4,minmax(130px,1fr))}.split-view[data-v-0ef32593]{grid-template-columns:repeat(2,minmax(0,1fr))}article[data-v-0ef32593]{display:grid;gap:8px;padding:16px}article span[data-v-0ef32593]{color:#667085;font-size:13px}article strong[data-v-0ef32593]{font-size:24px}.list-view[data-v-0ef32593],.logs-view[data-v-0ef32593],.settings-view[data-v-0ef32593]{margin-top:18px}.split-view .list-view[data-v-0ef32593],.logs-view .list-view[data-v-0ef32593]{margin-top:0}.list-view[data-v-0ef32593]{padding:16px}ul[data-v-0ef32593]{display:grid;gap:10px;margin:14px 0 0;padding:0;list-style:none}li[data-v-0ef32593]{display:flex;justify-content:space-between;gap:12px;min-width:0;padding:10px 0;border-top:1px solid #eef1f5}li[data-v-0ef32593]:first-child{border-top:0}li>div[data-v-0ef32593]{display:grid;gap:3px;min-width:0}li strong[data-v-0ef32593],li span[data-v-0ef32593],li small[data-v-0ef32593]{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.badge[data-v-0ef32593]{align-self:center;max-width:180px;border-radius:999px;padding:4px 9px;color:#1f4d62;background:#e5f1f7;font-size:12px}.toolbar[data-v-0ef32593]{justify-content:flex-start;margin:18px 0 12px}.settings-sections[data-v-0ef32593]{display:grid;grid-template-columns:repeat(3,minmax(120px,1fr));gap:12px}pre[data-v-0ef32593]{overflow:auto;max-height:420px;margin:12px 0 0;padding:14px;font-size:12px;line-height:1.5}dl[data-v-0ef32593]{display:grid;gap:12px;margin:14px 0 24px}dl div[data-v-0ef32593]{display:flex;justify-content:space-between}@media(max-width:1160px){.web-shell[data-v-0ef32593]{grid-template-columns:190px minmax(0,1fr)}.inspector[data-v-0ef32593]{display:none}}@media(max-width:820px){.web-shell[data-v-0ef32593]{grid-template-columns:1fr}.sidebar[data-v-0ef32593]{border-right:0;border-bottom:1px solid #d9e0e8}nav[data-v-0ef32593]{grid-template-columns:repeat(4,minmax(0,1fr))}nav button[data-v-0ef32593]{text-align:center}.dashboard-grid[data-v-0ef32593],.split-view[data-v-0ef32593],.settings-sections[data-v-0ef32593]{grid-template-columns:1fr}.topbar[data-v-0ef32593],.list-view header[data-v-0ef32593]{align-items:flex-start;flex-direction:column}}

文件差异因一行或多行过长而隐藏

文件差异因一行或多行过长而隐藏

查看文件

@ -1 +0,0 @@
.web-shell[data-v-b270185f]{box-sizing:border-box;display:grid;grid-template-columns:220px minmax(0,1fr) 260px;min-height:100vh;color:#1b2430;background:#f5f6f8;font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}.sidebar[data-v-b270185f],.inspector[data-v-b270185f]{background:#fff}.sidebar[data-v-b270185f]{border-right:1px solid #d9e0e8;padding:20px}.inspector[data-v-b270185f]{border-left:1px solid #d9e0e8;padding:20px}.brand[data-v-b270185f]{display:grid;gap:4px;margin-bottom:24px}.brand strong[data-v-b270185f]{font-size:19px}.brand span[data-v-b270185f],p[data-v-b270185f],dt[data-v-b270185f],.empty[data-v-b270185f],small[data-v-b270185f]{color:#667085}nav[data-v-b270185f]{display:grid;gap:6px}button[data-v-b270185f]{min-height:36px;border:1px solid #c7d0da;border-radius:6px;color:#1b2430;background:#fff;font:inherit;text-align:center;cursor:pointer}button[data-v-b270185f]:disabled{cursor:wait;opacity:.62}nav button[data-v-b270185f]{border-color:transparent;background:transparent;text-align:left;padding:0 10px}button.active[data-v-b270185f]{border-color:#b8d8cf;color:#164f43;background:#e5f4ef}.workspace[data-v-b270185f]{min-width:0;padding:24px}.topbar[data-v-b270185f],.list-view header[data-v-b270185f],.toolbar[data-v-b270185f],.inline-actions[data-v-b270185f]{display:flex;gap:12px;align-items:center}.topbar[data-v-b270185f],.list-view header[data-v-b270185f]{justify-content:space-between}.actions[data-v-b270185f],.inline-actions[data-v-b270185f]{flex-wrap:wrap;justify-content:flex-end}.topbar button[data-v-b270185f],.toolbar button[data-v-b270185f],.list-view header button[data-v-b270185f],.inline-actions button[data-v-b270185f]{padding:0 14px}h1[data-v-b270185f],h2[data-v-b270185f],p[data-v-b270185f],dl[data-v-b270185f],dd[data-v-b270185f]{margin:0}h1[data-v-b270185f]{min-height:30px;font-size:26px}h2[data-v-b270185f]{font-size:15px}.notice[data-v-b270185f],article[data-v-b270185f],.list-view[data-v-b270185f],pre[data-v-b270185f]{border:1px solid #d9e0e8;border-radius:8px;background:#fff}.notice[data-v-b270185f]{margin-top:18px;padding:14px}.error[data-v-b270185f]{border-color:#f0b4b4;color:#8a1f1f;background:#fff7f7}.dashboard-grid[data-v-b270185f],.split-view[data-v-b270185f]{display:grid;gap:12px;margin-top:18px}.dashboard-grid[data-v-b270185f]{grid-template-columns:repeat(4,minmax(130px,1fr))}.split-view[data-v-b270185f]{grid-template-columns:repeat(2,minmax(0,1fr))}article[data-v-b270185f]{display:grid;gap:8px;padding:16px}article span[data-v-b270185f]{color:#667085;font-size:13px}article strong[data-v-b270185f]{font-size:24px}.list-view[data-v-b270185f],.settings-view[data-v-b270185f]{margin-top:18px}.split-view .list-view[data-v-b270185f]{margin-top:0}.list-view[data-v-b270185f]{padding:16px}ul[data-v-b270185f]{display:grid;gap:10px;margin:14px 0 0;padding:0;list-style:none}li[data-v-b270185f]{display:flex;justify-content:space-between;gap:12px;min-width:0;padding:10px 0;border-top:1px solid #eef1f5}li[data-v-b270185f]:first-child{border-top:0}li>div[data-v-b270185f]{display:grid;gap:3px;min-width:0}li strong[data-v-b270185f],li span[data-v-b270185f],li small[data-v-b270185f]{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.badge[data-v-b270185f]{align-self:center;max-width:180px;border-radius:999px;padding:4px 9px;color:#1f4d62;background:#e5f1f7;font-size:12px}.toolbar[data-v-b270185f]{justify-content:flex-start;margin:18px 0 12px}.settings-sections[data-v-b270185f]{display:grid;grid-template-columns:repeat(3,minmax(120px,1fr));gap:12px}pre[data-v-b270185f]{overflow:auto;max-height:420px;margin:12px 0 0;padding:14px;font-size:12px;line-height:1.5}dl[data-v-b270185f]{display:grid;gap:12px;margin:14px 0 24px}dl div[data-v-b270185f]{display:flex;justify-content:space-between}@media(max-width:1160px){.web-shell[data-v-b270185f]{grid-template-columns:190px minmax(0,1fr)}.inspector[data-v-b270185f]{display:none}}@media(max-width:820px){.web-shell[data-v-b270185f]{grid-template-columns:1fr}.sidebar[data-v-b270185f]{border-right:0;border-bottom:1px solid #d9e0e8}nav[data-v-b270185f]{grid-template-columns:repeat(4,minmax(0,1fr))}nav button[data-v-b270185f]{text-align:center}.dashboard-grid[data-v-b270185f],.split-view[data-v-b270185f],.settings-sections[data-v-b270185f]{grid-template-columns:1fr}.topbar[data-v-b270185f],.list-view header[data-v-b270185f]{align-items:flex-start;flex-direction:column}}

查看文件

@ -1,3 +1,3 @@
<script type="module" crossorigin src="/api/v1/plugins/extensions/astrbot_plugin_imagestudio/web/assets/index-ByLkWMta.js"></script>
<link rel="stylesheet" crossorigin href="/api/v1/plugins/extensions/astrbot_plugin_imagestudio/web/assets/index-Ds4SgEOP.css">
<script type="module" crossorigin src="/api/v1/plugins/extensions/astrbot_plugin_imagestudio/web/assets/index-BCNEksZg.js"></script>
<link rel="stylesheet" crossorigin href="/api/v1/plugins/extensions/astrbot_plugin_imagestudio/web/assets/index-B92QQGCh.css">
<div id="app"></div>