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"
|
|
|
|
|
import type { JobListResult } from "../../shared/types/job"
|
|
|
|
|
import type { ProfileListResult } from "../../shared/types/profile"
|
|
|
|
|
import type { CurrentSettings, SettingsSchema } from "../../shared/types/settings"
|
|
|
|
|
import type { StorageStatus } from "../../shared/types/storage"
|
|
|
|
|
|
|
|
|
|
type ViewKey = "dashboard" | "profiles" | "jobs" | "settings"
|
|
|
|
|
|
|
|
|
|
const activeView = ref<ViewKey>("dashboard")
|
|
|
|
|
const bootstrap = ref<UiBootstrap | null>(null)
|
|
|
|
|
const dashboard = ref<DashboardSummary | null>(null)
|
|
|
|
|
const profiles = ref<ProfileListResult | null>(null)
|
|
|
|
|
const jobs = ref<JobListResult | null>(null)
|
|
|
|
|
const settingsSchema = ref<SettingsSchema | null>(null)
|
|
|
|
|
const currentSettings = ref<CurrentSettings | null>(null)
|
|
|
|
|
const storage = ref<StorageStatus | null>(null)
|
|
|
|
|
const loading = ref(true)
|
|
|
|
|
const error = ref("")
|
|
|
|
|
|
|
|
|
|
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, profileData, jobData, schemaData, settingsData, storageData] =
|
|
|
|
|
await Promise.all([
|
|
|
|
|
getJson<UiBootstrap>(endpoints.uiBootstrap),
|
|
|
|
|
getJson<DashboardSummary>(endpoints.dashboardSummary),
|
|
|
|
|
getJson<ProfileListResult>(endpoints.profiles, { page: 1, page_size: 20 }),
|
|
|
|
|
getJson<JobListResult>(endpoints.jobs, { page: 1, page_size: 20 }),
|
|
|
|
|
getJson<SettingsSchema>(endpoints.settingsSchema),
|
|
|
|
|
getJson<CurrentSettings>(endpoints.settingsCurrent),
|
|
|
|
|
getJson<StorageStatus>(endpoints.storageStatus),
|
|
|
|
|
])
|
|
|
|
|
bootstrap.value = bootstrapData
|
|
|
|
|
dashboard.value = dashboardData
|
|
|
|
|
profiles.value = profileData
|
|
|
|
|
jobs.value = jobData
|
|
|
|
|
settingsSchema.value = schemaData
|
|
|
|
|
currentSettings.value = settingsData
|
|
|
|
|
storage.value = storageData
|
|
|
|
|
} catch (err) {
|
|
|
|
|
error.value = err instanceof Error ? err.message : "加载失败"
|
|
|
|
|
} 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="web-shell">
|
|
|
|
|
<aside class="sidebar">
|
2026-07-05 09:24:00 +08:00
|
|
|
<div class="brand">
|
|
|
|
|
<strong>{{ bootstrap?.display_name ?? "ImageStudio" }}</strong>
|
|
|
|
|
<span>{{ bootstrap?.dashboard_user ?? "AstrBot" }}</span>
|
|
|
|
|
</div>
|
|
|
|
|
<nav>
|
|
|
|
|
<button type="button" :class="{ active: activeView === 'dashboard' }" @click="activeView = 'dashboard'">
|
|
|
|
|
概览
|
|
|
|
|
</button>
|
|
|
|
|
<button type="button" :class="{ active: activeView === 'profiles' }" @click="activeView = 'profiles'">
|
|
|
|
|
角色
|
|
|
|
|
</button>
|
|
|
|
|
<button type="button" :class="{ active: activeView === 'jobs' }" @click="activeView = 'jobs'">
|
|
|
|
|
队列
|
|
|
|
|
</button>
|
|
|
|
|
<button type="button" :class="{ active: activeView === 'settings' }" @click="activeView = 'settings'">
|
|
|
|
|
设置
|
|
|
|
|
</button>
|
|
|
|
|
</nav>
|
2026-07-04 22:51:52 +08:00
|
|
|
</aside>
|
2026-07-05 09:24:00 +08:00
|
|
|
|
2026-07-04 22:51:52 +08:00
|
|
|
<section class="workspace">
|
2026-07-05 09:24:00 +08:00
|
|
|
<header class="topbar">
|
|
|
|
|
<div>
|
|
|
|
|
<h1>{{ activeView === "dashboard" ? "ImageStudio" : "" }}</h1>
|
|
|
|
|
<p>{{ dashboard?.plugin_status ?? "loading" }}</p>
|
|
|
|
|
</div>
|
|
|
|
|
<button type="button" @click="load">刷新</button>
|
|
|
|
|
</header>
|
|
|
|
|
|
|
|
|
|
<section v-if="error" class="notice">{{ error }}</section>
|
|
|
|
|
<section v-else-if="loading" class="notice">加载中</section>
|
|
|
|
|
|
|
|
|
|
<template v-else>
|
|
|
|
|
<section v-if="activeView === 'dashboard'" class="dashboard-grid">
|
|
|
|
|
<article>
|
|
|
|
|
<span>角色</span>
|
|
|
|
|
<strong>{{ dashboard?.active_profiles ?? 0 }}</strong>
|
|
|
|
|
</article>
|
|
|
|
|
<article>
|
|
|
|
|
<span>队列</span>
|
|
|
|
|
<strong>{{ queueTotal }}</strong>
|
|
|
|
|
</article>
|
|
|
|
|
<article>
|
|
|
|
|
<span>存储</span>
|
|
|
|
|
<strong>{{ formatBytes(storage?.total_bytes ?? dashboard?.storage.total_bytes) }}</strong>
|
|
|
|
|
</article>
|
|
|
|
|
<article>
|
|
|
|
|
<span>图片</span>
|
|
|
|
|
<strong>{{ dashboard?.recent_images.length ?? 0 }}</strong>
|
|
|
|
|
</article>
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section v-if="activeView === 'profiles'" class="list-view">
|
|
|
|
|
<header>
|
|
|
|
|
<h2>角色</h2>
|
|
|
|
|
<span>{{ profiles?.total ?? 0 }}</span>
|
|
|
|
|
</header>
|
|
|
|
|
<ul>
|
|
|
|
|
<li v-for="profile in profiles?.items ?? []" :key="profile.profile_id">
|
|
|
|
|
<strong>{{ profile.name }}</strong>
|
|
|
|
|
<span>{{ profile.status }}</span>
|
|
|
|
|
</li>
|
|
|
|
|
<li v-if="!profiles?.items.length" class="empty">暂无角色</li>
|
|
|
|
|
</ul>
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section v-if="activeView === 'jobs'" class="list-view">
|
|
|
|
|
<header>
|
|
|
|
|
<h2>队列</h2>
|
|
|
|
|
<span>{{ jobs?.total ?? 0 }}</span>
|
|
|
|
|
</header>
|
|
|
|
|
<ul>
|
|
|
|
|
<li v-for="job in jobs?.items ?? []" :key="job.task_id">
|
|
|
|
|
<strong>{{ job.task_id }}</strong>
|
|
|
|
|
<span>{{ job.status }}</span>
|
|
|
|
|
</li>
|
|
|
|
|
<li v-if="!jobs?.items.length" class="empty">暂无任务</li>
|
|
|
|
|
</ul>
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section v-if="activeView === 'settings'" class="settings-view">
|
|
|
|
|
<div class="settings-sections">
|
|
|
|
|
<article v-for="section in settingsSchema?.sections ?? []" :key="section.key">
|
|
|
|
|
<h2>{{ section.title }}</h2>
|
|
|
|
|
<span>{{ section.fields.length }}</span>
|
|
|
|
|
</article>
|
|
|
|
|
</div>
|
|
|
|
|
<pre>{{ JSON.stringify(currentSettings?.config ?? {}, null, 2) }}</pre>
|
|
|
|
|
</section>
|
|
|
|
|
</template>
|
2026-07-04 22:51:52 +08:00
|
|
|
</section>
|
2026-07-05 09:24:00 +08:00
|
|
|
|
|
|
|
|
<aside class="inspector">
|
|
|
|
|
<h2>运行</h2>
|
|
|
|
|
<dl>
|
|
|
|
|
<div>
|
|
|
|
|
<dt>Pending</dt>
|
|
|
|
|
<dd>{{ dashboard?.queue.pending ?? 0 }}</dd>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<dt>Running</dt>
|
|
|
|
|
<dd>{{ dashboard?.queue.running ?? 0 }}</dd>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<dt>Failed</dt>
|
|
|
|
|
<dd>{{ dashboard?.queue.failed ?? 0 }}</dd>
|
|
|
|
|
</div>
|
|
|
|
|
</dl>
|
|
|
|
|
</aside>
|
2026-07-04 22:51:52 +08:00
|
|
|
</main>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
.web-shell {
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
display: grid;
|
2026-07-05 09:24:00 +08:00
|
|
|
grid-template-columns: 220px minmax(0, 1fr) 260px;
|
2026-07-04 22:51:52 +08:00
|
|
|
min-height: 100vh;
|
2026-07-05 09:24:00 +08:00
|
|
|
color: #1b2430;
|
|
|
|
|
background: #f5f6f8;
|
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
|
|
|
.sidebar,
|
|
|
|
|
.inspector {
|
2026-07-04 22:51:52 +08:00
|
|
|
background: #ffffff;
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-05 09:24:00 +08:00
|
|
|
.sidebar {
|
|
|
|
|
border-right: 1px solid #d9e0e8;
|
|
|
|
|
padding: 20px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.inspector {
|
|
|
|
|
border-left: 1px solid #d9e0e8;
|
|
|
|
|
padding: 20px;
|
2026-07-04 22:51:52 +08:00
|
|
|
}
|
|
|
|
|
|
2026-07-05 09:24:00 +08:00
|
|
|
.brand {
|
|
|
|
|
display: grid;
|
|
|
|
|
gap: 4px;
|
|
|
|
|
margin-bottom: 24px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.brand strong {
|
|
|
|
|
font-size: 19px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.brand span,
|
|
|
|
|
p,
|
|
|
|
|
dt,
|
|
|
|
|
.empty {
|
|
|
|
|
color: #667085;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nav {
|
|
|
|
|
display: grid;
|
|
|
|
|
gap: 6px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
button {
|
|
|
|
|
min-height: 36px;
|
|
|
|
|
border: 1px solid transparent;
|
|
|
|
|
border-radius: 6px;
|
|
|
|
|
color: #1b2430;
|
|
|
|
|
background: transparent;
|
|
|
|
|
font: inherit;
|
|
|
|
|
text-align: left;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nav button {
|
|
|
|
|
padding: 0 10px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
button.active {
|
|
|
|
|
border-color: #b8d8cf;
|
|
|
|
|
color: #164f43;
|
|
|
|
|
background: #e5f4ef;
|
2026-07-04 22:51:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.workspace {
|
2026-07-05 09:24:00 +08:00
|
|
|
min-width: 0;
|
|
|
|
|
padding: 24px;
|
2026-07-04 22:51:52 +08:00
|
|
|
}
|
|
|
|
|
|
2026-07-05 09:24:00 +08:00
|
|
|
.topbar {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
gap: 16px;
|
|
|
|
|
align-items: center;
|
2026-07-04 22:51:52 +08:00
|
|
|
}
|
|
|
|
|
|
2026-07-05 09:24:00 +08:00
|
|
|
.topbar button {
|
|
|
|
|
padding: 0 14px;
|
|
|
|
|
border-color: #c7d0da;
|
|
|
|
|
background: #ffffff;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
h1,
|
|
|
|
|
h2,
|
|
|
|
|
p,
|
|
|
|
|
dl,
|
|
|
|
|
dd {
|
2026-07-04 22:51:52 +08:00
|
|
|
margin: 0;
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-05 09:24:00 +08:00
|
|
|
h1 {
|
|
|
|
|
min-height: 30px;
|
|
|
|
|
font-size: 26px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
h2 {
|
|
|
|
|
font-size: 15px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.notice,
|
|
|
|
|
article,
|
|
|
|
|
.list-view,
|
|
|
|
|
pre {
|
|
|
|
|
border: 1px solid #d9e0e8;
|
|
|
|
|
border-radius: 8px;
|
|
|
|
|
background: #ffffff;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.notice {
|
|
|
|
|
margin-top: 18px;
|
|
|
|
|
padding: 14px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.dashboard-grid {
|
|
|
|
|
display: grid;
|
|
|
|
|
grid-template-columns: repeat(4, minmax(130px, 1fr));
|
|
|
|
|
gap: 12px;
|
|
|
|
|
margin-top: 18px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
article {
|
|
|
|
|
display: grid;
|
|
|
|
|
gap: 8px;
|
|
|
|
|
padding: 16px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
article span {
|
|
|
|
|
color: #667085;
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
article strong {
|
|
|
|
|
font-size: 24px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.list-view,
|
|
|
|
|
.settings-view {
|
|
|
|
|
margin-top: 18px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.list-view {
|
|
|
|
|
padding: 16px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.list-view header {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ul {
|
|
|
|
|
display: grid;
|
|
|
|
|
gap: 10px;
|
|
|
|
|
margin: 14px 0 0;
|
|
|
|
|
padding: 0;
|
|
|
|
|
list-style: none;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
li {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
gap: 12px;
|
|
|
|
|
min-width: 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
li strong,
|
|
|
|
|
li span {
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.settings-sections {
|
|
|
|
|
display: grid;
|
|
|
|
|
grid-template-columns: repeat(3, minmax(120px, 1fr));
|
|
|
|
|
gap: 12px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pre {
|
|
|
|
|
overflow: auto;
|
|
|
|
|
max-height: 420px;
|
|
|
|
|
margin: 12px 0 0;
|
|
|
|
|
padding: 14px;
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dl {
|
|
|
|
|
display: grid;
|
|
|
|
|
gap: 12px;
|
|
|
|
|
margin-top: 14px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dl div {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@media (max-width: 1100px) {
|
|
|
|
|
.web-shell {
|
|
|
|
|
grid-template-columns: 190px minmax(0, 1fr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.inspector {
|
|
|
|
|
display: none;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-04 22:51:52 +08:00
|
|
|
@media (max-width: 760px) {
|
|
|
|
|
.web-shell {
|
|
|
|
|
grid-template-columns: 1fr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.sidebar {
|
|
|
|
|
border-right: 0;
|
2026-07-05 09:24:00 +08:00
|
|
|
border-bottom: 1px solid #d9e0e8;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nav {
|
|
|
|
|
grid-template-columns: repeat(4, minmax(0, 1fr));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nav button {
|
|
|
|
|
text-align: center;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.dashboard-grid,
|
|
|
|
|
.settings-sections {
|
|
|
|
|
grid-template-columns: 1fr;
|
2026-07-04 22:51:52 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|