2026-07-05 09:24:00 +08:00
|
|
|
<script setup lang="ts">
|
|
|
|
|
import { computed, onMounted, ref } from "vue"
|
|
|
|
|
import { endpoints } from "../../shared/api/endpoints"
|
|
|
|
|
import { getJson } from "../../shared/api/client"
|
|
|
|
|
import type { UiBootstrap } from "../../shared/types/bootstrap"
|
|
|
|
|
import type { DashboardSummary } from "../../shared/types/dashboard"
|
|
|
|
|
|
|
|
|
|
const bootstrap = ref<UiBootstrap | null>(null)
|
|
|
|
|
const dashboard = ref<DashboardSummary | null>(null)
|
|
|
|
|
const loading = ref(true)
|
|
|
|
|
const error = ref("")
|
|
|
|
|
|
2026-07-05 15:10:49 +08:00
|
|
|
const text = {
|
|
|
|
|
loadFailed: "\u52a0\u8f7d\u5931\u8d25",
|
|
|
|
|
loading: "\u52a0\u8f7d\u4e2d",
|
|
|
|
|
refresh: "\u5237\u65b0",
|
|
|
|
|
workbench: "\u5de5\u4f5c\u53f0",
|
|
|
|
|
profiles: "\u89d2\u8272",
|
|
|
|
|
queue: "\u961f\u5217",
|
|
|
|
|
running: "\u8fd0\u884c\u4e2d",
|
|
|
|
|
failed: "\u5931\u8d25",
|
|
|
|
|
storage: "\u5b58\u50a8",
|
|
|
|
|
recentImages: "\u6700\u8fd1\u56fe\u7247",
|
|
|
|
|
recentJobs: "\u4efb\u52a1",
|
|
|
|
|
emptyImages: "\u6682\u65e0\u56fe\u7247",
|
|
|
|
|
emptyJobs: "\u6682\u65e0\u4efb\u52a1",
|
|
|
|
|
permissions: "\u6743\u9650",
|
|
|
|
|
features: "\u529f\u80fd",
|
|
|
|
|
enabled: "\u5df2\u5f00\u542f",
|
|
|
|
|
disabled: "\u672a\u5f00\u542f",
|
|
|
|
|
} as const
|
|
|
|
|
|
2026-07-05 09:24:00 +08:00
|
|
|
const workbenchUrl = computed(() => `${bootstrap.value?.api_base ?? ""}/web`)
|
|
|
|
|
const queueTotal = computed(() => {
|
|
|
|
|
const queue = dashboard.value?.queue
|
|
|
|
|
return queue ? queue.pending + queue.running + queue.failed + queue.dead_letter : 0
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
onMounted(load)
|
|
|
|
|
|
|
|
|
|
async function load() {
|
|
|
|
|
loading.value = true
|
|
|
|
|
error.value = ""
|
|
|
|
|
try {
|
|
|
|
|
const [bootstrapData, dashboardData] = await Promise.all([
|
|
|
|
|
getJson<UiBootstrap>(endpoints.uiBootstrap),
|
|
|
|
|
getJson<DashboardSummary>(endpoints.dashboardSummary),
|
|
|
|
|
])
|
|
|
|
|
bootstrap.value = bootstrapData
|
|
|
|
|
dashboard.value = dashboardData
|
|
|
|
|
} catch (err) {
|
2026-07-05 15:10:49 +08:00
|
|
|
error.value = err instanceof Error ? err.message : text.loadFailed
|
2026-07-05 09:24:00 +08:00
|
|
|
} finally {
|
|
|
|
|
loading.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function formatBytes(value = 0) {
|
|
|
|
|
if (value < 1024) return `${value} B`
|
|
|
|
|
if (value < 1024 * 1024) return `${(value / 1024).toFixed(1)} KB`
|
|
|
|
|
if (value < 1024 * 1024 * 1024) return `${(value / 1024 / 1024).toFixed(1)} MB`
|
|
|
|
|
return `${(value / 1024 / 1024 / 1024).toFixed(1)} GB`
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
2026-07-04 22:51:52 +08:00
|
|
|
<template>
|
|
|
|
|
<main class="plugin-page-shell">
|
2026-07-05 09:24:00 +08:00
|
|
|
<header class="topbar">
|
|
|
|
|
<div>
|
|
|
|
|
<h1>{{ bootstrap?.display_name ?? "ImageStudio" }}</h1>
|
|
|
|
|
<p>{{ bootstrap?.dashboard_user ?? "AstrBot" }}</p>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="actions">
|
|
|
|
|
<span class="status" :data-state="dashboard?.plugin_status ?? 'loading'">
|
|
|
|
|
{{ dashboard?.plugin_status ?? "loading" }}
|
|
|
|
|
</span>
|
2026-07-05 15:10:49 +08:00
|
|
|
<button type="button" @click="load">{{ text.refresh }}</button>
|
|
|
|
|
<a v-if="bootstrap" class="primary" :href="workbenchUrl" target="_blank" rel="noreferrer">
|
|
|
|
|
{{ text.workbench }}
|
|
|
|
|
</a>
|
2026-07-05 09:24:00 +08:00
|
|
|
</div>
|
|
|
|
|
</header>
|
|
|
|
|
|
|
|
|
|
<section v-if="error" class="notice">{{ error }}</section>
|
2026-07-05 15:10:49 +08:00
|
|
|
<section v-else-if="loading" class="notice">{{ text.loading }}</section>
|
2026-07-05 09:24:00 +08:00
|
|
|
|
|
|
|
|
<section v-else class="metrics" aria-label="ImageStudio dashboard">
|
|
|
|
|
<article>
|
2026-07-05 15:10:49 +08:00
|
|
|
<span>{{ text.profiles }}</span>
|
2026-07-05 09:24:00 +08:00
|
|
|
<strong>{{ dashboard?.active_profiles ?? 0 }}</strong>
|
|
|
|
|
</article>
|
|
|
|
|
<article>
|
2026-07-05 15:10:49 +08:00
|
|
|
<span>{{ text.queue }}</span>
|
2026-07-05 09:24:00 +08:00
|
|
|
<strong>{{ queueTotal }}</strong>
|
|
|
|
|
</article>
|
|
|
|
|
<article>
|
2026-07-05 15:10:49 +08:00
|
|
|
<span>{{ text.running }}</span>
|
2026-07-05 09:24:00 +08:00
|
|
|
<strong>{{ dashboard?.queue.running ?? 0 }}</strong>
|
|
|
|
|
</article>
|
|
|
|
|
<article>
|
2026-07-05 15:10:49 +08:00
|
|
|
<span>{{ text.failed }}</span>
|
2026-07-05 09:24:00 +08:00
|
|
|
<strong>{{ dashboard?.queue.failed ?? 0 }}</strong>
|
|
|
|
|
</article>
|
|
|
|
|
<article>
|
2026-07-05 15:10:49 +08:00
|
|
|
<span>{{ text.storage }}</span>
|
2026-07-05 09:24:00 +08:00
|
|
|
<strong>{{ formatBytes(dashboard?.storage.total_bytes) }}</strong>
|
|
|
|
|
</article>
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class="activity">
|
|
|
|
|
<div>
|
2026-07-05 15:10:49 +08:00
|
|
|
<h2>{{ text.recentImages }}</h2>
|
2026-07-05 09:24:00 +08:00
|
|
|
<ul>
|
|
|
|
|
<li v-for="image in dashboard?.recent_images ?? []" :key="String((image as any).image_id)">
|
|
|
|
|
<span>{{ (image as any).image_id }}</span>
|
|
|
|
|
<small>{{ (image as any).created_at }}</small>
|
|
|
|
|
</li>
|
2026-07-05 15:10:49 +08:00
|
|
|
<li v-if="!dashboard?.recent_images?.length" class="empty">{{ text.emptyImages }}</li>
|
2026-07-05 09:24:00 +08:00
|
|
|
</ul>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
2026-07-05 15:10:49 +08:00
|
|
|
<h2>{{ text.recentJobs }}</h2>
|
2026-07-05 09:24:00 +08:00
|
|
|
<ul>
|
|
|
|
|
<li v-for="job in dashboard?.recent_jobs ?? []" :key="String((job as any).task_id)">
|
|
|
|
|
<span>{{ (job as any).task_id }}</span>
|
|
|
|
|
<small>{{ (job as any).status }}</small>
|
|
|
|
|
</li>
|
2026-07-05 15:10:49 +08:00
|
|
|
<li v-if="!dashboard?.recent_jobs?.length" class="empty">{{ text.emptyJobs }}</li>
|
|
|
|
|
</ul>
|
|
|
|
|
</div>
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section v-if="bootstrap" class="activity">
|
|
|
|
|
<div>
|
|
|
|
|
<h2>{{ text.permissions }}</h2>
|
|
|
|
|
<ul>
|
|
|
|
|
<li v-for="(value, key) in bootstrap.permissions" :key="key">
|
|
|
|
|
<span>{{ key }}</span>
|
|
|
|
|
<small>{{ value ? text.enabled : text.disabled }}</small>
|
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<h2>{{ text.features }}</h2>
|
|
|
|
|
<ul>
|
|
|
|
|
<li v-for="(value, key) in bootstrap.feature_flags" :key="key">
|
|
|
|
|
<span>{{ key }}</span>
|
|
|
|
|
<small>{{ value ? text.enabled : text.disabled }}</small>
|
|
|
|
|
</li>
|
2026-07-05 09:24:00 +08:00
|
|
|
</ul>
|
|
|
|
|
</div>
|
|
|
|
|
</section>
|
2026-07-04 22:51:52 +08:00
|
|
|
</main>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
.plugin-page-shell {
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
min-height: 100vh;
|
|
|
|
|
padding: 24px;
|
2026-07-05 09:24:00 +08:00
|
|
|
color: #1d2430;
|
|
|
|
|
background: #f4f6f8;
|
2026-07-04 22:51:52 +08:00
|
|
|
font-family:
|
|
|
|
|
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-05 09:24:00 +08:00
|
|
|
.topbar,
|
|
|
|
|
.activity {
|
|
|
|
|
display: grid;
|
|
|
|
|
gap: 16px;
|
|
|
|
|
grid-template-columns: minmax(0, 1fr) auto;
|
|
|
|
|
align-items: start;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
h1,
|
|
|
|
|
h2,
|
|
|
|
|
p {
|
|
|
|
|
margin: 0;
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-04 22:51:52 +08:00
|
|
|
h1 {
|
|
|
|
|
font-size: 24px;
|
|
|
|
|
font-weight: 700;
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-05 09:24:00 +08:00
|
|
|
h2 {
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
p,
|
|
|
|
|
small,
|
|
|
|
|
.empty {
|
|
|
|
|
color: #667085;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.actions {
|
|
|
|
|
display: flex;
|
|
|
|
|
gap: 8px;
|
|
|
|
|
align-items: center;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
button,
|
|
|
|
|
a.primary {
|
|
|
|
|
min-height: 36px;
|
|
|
|
|
padding: 0 14px;
|
|
|
|
|
border: 1px solid #c7d0da;
|
|
|
|
|
border-radius: 6px;
|
|
|
|
|
color: #1d2430;
|
|
|
|
|
background: #ffffff;
|
|
|
|
|
font: inherit;
|
|
|
|
|
text-decoration: none;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
a.primary {
|
|
|
|
|
display: inline-flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
border-color: #256f5b;
|
|
|
|
|
color: #ffffff;
|
|
|
|
|
background: #256f5b;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.status {
|
|
|
|
|
display: inline-flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
min-height: 28px;
|
|
|
|
|
padding: 0 10px;
|
|
|
|
|
border-radius: 999px;
|
|
|
|
|
color: #245347;
|
|
|
|
|
background: #dff3eb;
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.status[data-state="loading"] {
|
|
|
|
|
color: #6b4f1d;
|
|
|
|
|
background: #f7e7c5;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.notice {
|
|
|
|
|
margin-top: 18px;
|
|
|
|
|
padding: 14px;
|
|
|
|
|
border: 1px solid #d6dde6;
|
|
|
|
|
border-radius: 8px;
|
|
|
|
|
background: #ffffff;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.metrics {
|
|
|
|
|
display: grid;
|
|
|
|
|
grid-template-columns: repeat(5, minmax(120px, 1fr));
|
|
|
|
|
gap: 12px;
|
|
|
|
|
margin-top: 20px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
article,
|
|
|
|
|
.activity > div {
|
|
|
|
|
border: 1px solid #d6dde6;
|
|
|
|
|
border-radius: 8px;
|
|
|
|
|
background: #ffffff;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
article {
|
|
|
|
|
display: grid;
|
|
|
|
|
gap: 8px;
|
|
|
|
|
padding: 16px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
article span {
|
|
|
|
|
color: #667085;
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
article strong {
|
|
|
|
|
font-size: 24px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.activity {
|
|
|
|
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
|
|
|
margin-top: 16px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.activity > div {
|
|
|
|
|
padding: 16px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ul {
|
|
|
|
|
display: grid;
|
|
|
|
|
gap: 10px;
|
|
|
|
|
margin: 12px 0 0;
|
|
|
|
|
padding: 0;
|
|
|
|
|
list-style: none;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
li {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
gap: 12px;
|
|
|
|
|
min-width: 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
li span,
|
|
|
|
|
li small {
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@media (max-width: 820px) {
|
|
|
|
|
.topbar,
|
|
|
|
|
.activity {
|
|
|
|
|
grid-template-columns: 1fr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.actions {
|
|
|
|
|
flex-wrap: wrap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.metrics {
|
|
|
|
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
|
|
|
}
|
2026-07-04 22:51:52 +08:00
|
|
|
}
|
|
|
|
|
</style>
|