From 451726e09ad87c267fa165fe901e6e22cbf266ba Mon Sep 17 00:00:00 2001 From: YokiiroBW Date: Mon, 6 Jul 2026 12:20:49 +0800 Subject: [PATCH] =?UTF-8?q?UI=E5=A4=A7=E9=A1=B9=EF=BC=9A=E8=90=BD=E5=9C=B0?= =?UTF-8?q?=E6=98=9F=E5=9B=BE=E5=AF=BC=E8=88=AA=E9=A1=B5=20S130-S145?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 10 +- frontend/plugin-page/src/App.vue | 597 ++- frontend/standalone-web/src/App.vue | 5304 +++++++------------ pages/imagestudio/assets/index-C0aY_abH.js | 17 + pages/imagestudio/assets/index-Cm8RTiWQ.css | 1 + pages/imagestudio/assets/index-DZQuAVR1.js | 17 - pages/imagestudio/assets/index-jAALYl6p.css | 1 - pages/imagestudio/index.html | 4 +- web/assets/index-BQ7BbeZ6.js | 17 - web/assets/index-Cg5YCyx1.css | 1 - web/assets/index-DKLXPqVI.js | 17 + web/assets/index-DwR729Bj.css | 1 + web/index.html | 4 +- 13 files changed, 2354 insertions(+), 3637 deletions(-) create mode 100644 pages/imagestudio/assets/index-C0aY_abH.js create mode 100644 pages/imagestudio/assets/index-Cm8RTiWQ.css delete mode 100644 pages/imagestudio/assets/index-DZQuAVR1.js delete mode 100644 pages/imagestudio/assets/index-jAALYl6p.css delete mode 100644 web/assets/index-BQ7BbeZ6.js delete mode 100644 web/assets/index-Cg5YCyx1.css create mode 100644 web/assets/index-DKLXPqVI.js create mode 100644 web/assets/index-DwR729Bj.css diff --git a/README.md b/README.md index 61bc060..01b12a5 100644 --- a/README.md +++ b/README.md @@ -11,11 +11,11 @@ ImageStudio 是一个给 AstrBot 使用的角色资产与生图工作台插件 - 查看任务队列、失败任务、死信队列、生成日志、错误日志和审计日志。 - 探测 OpenAI 兼容生图接口的能力,保存模型/路线能力档案。 - 默认使用 SQLite;在配置 PostgreSQL 后可以切换到 PG 数据库。 -- 提供 AstrBot 插件卡片概览页,也提供独立工作台入口。 +- 提供 AstrBot 插件卡片概览页,也提供独立的星图导航工作台入口。 ## 怎么打开 -在 AstrBot 插件页面打开 ImageStudio 时,默认看到的是轻量概览页:它用于确认插件状态、队列、最近任务、权限和快捷入口。 +在 AstrBot 插件页面打开 ImageStudio 时,默认看到的是轻量星图概览页:它用于确认插件状态、队列、最近图片和快捷入口。 完整工作台在概览页的“工作台”入口里,路径由 AstrBot 挂载到: @@ -25,9 +25,11 @@ ImageStudio 是一个给 AstrBot 使用的角色资产与生图工作台插件 ## 当前 UI 状态 -插件卡片页目前是概览页,这是有意保留的轻量入口,不代表后端功能只有这一页。 +插件卡片页目前是轻量入口,这是有意保留的 AstrBot 内嵌页面,不代表后端功能只有这一页。 -完整工作台代码已经包含概览、角色、工作流、素材、衣橱、队列、能力探测、日志和设置等模块。后续还需要继续做 UI 体验整理、布局打磨和更顺手的操作流。 +独立工作台已经切换为星图导航页:左侧图标导航用于切换概览、生成、队列、图库、角色、素材、设置和日志;顶部提供功能搜索、日夜主题、通知和调色盘;主区域聚合当前队列、最近图片、智能工作建议和右侧性能监控。 + +当前导航页已接入 `dashboard/summary`、`jobs`、`logs/generation` 和 `logs/errors` 等真实接口,并为接口失败、空队列、无图片和日志为空的情况提供可读状态。后续详情页会继续沿用这套导航入口接入更完整的生成、图库、角色和设置操作流。 ## 配置说明 diff --git a/frontend/plugin-page/src/App.vue b/frontend/plugin-page/src/App.vue index e7d79aa..ce16d8a 100644 --- a/frontend/plugin-page/src/App.vue +++ b/frontend/plugin-page/src/App.vue @@ -3,79 +3,37 @@ 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 { DashboardImage, DashboardSummary } from "../../shared/types/dashboard" import type { UiAction } from "../../shared/types/ui" +interface QuickLink { + label: string + href: string +} + const bootstrap = ref(null) const dashboard = ref(null) const uiActions = ref([]) const loading = ref(true) const error = ref("") -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", - quickLinks: "\u5feb\u6377\u5165\u53e3", - openJobs: "\u961f\u5217", - openLogs: "\u65e5\u5fd7", - openSettings: "\u8bbe\u7f6e", - openMaterials: "\u7d20\u6750", - enabled: "\u5df2\u5f00\u542f", - disabled: "\u672a\u5f00\u542f", -} as const - -const statusLabels: Record = { - loading: "\u52a0\u8f7d\u4e2d", - running: "\u8fd0\u884c\u4e2d", - created: "\u5df2\u521b\u5efa", - pending: "\u7b49\u5f85\u4e2d", - queued: "\u6392\u961f\u4e2d", - completed: "\u5df2\u5b8c\u6210", - succeeded: "\u5df2\u6210\u529f", - failed: "\u5931\u8d25", - cancelled: "\u5df2\u53d6\u6d88", - dead_letter: "\u6b7b\u4fe1", -} - -const permissionLabels: Record = { - can_read: "\u8bfb\u53d6", - can_write: "\u5199\u5165", - can_manage_config: "\u914d\u7f6e\u7ba1\u7406", - can_manage_materials: "\u7d20\u6750\u7ba1\u7406", - can_retry_tasks: "\u91cd\u8bd5\u4efb\u52a1", -} - -const featureLabels: Record = { - quick_profile: "\u5feb\u901f\u5efa\u6863", - workspace: "\u5de5\u4f5c\u53f0", - material_library: "\u7d20\u6750\u5e93", - wardrobe: "\u8863\u6a71", - api_discovery: "\u80fd\u529b\u63a2\u6d4b", - private_companion_integration: "\u79c1\u4f34\u63d2\u4ef6\u96c6\u6210", -} - const workbenchUrl = computed(() => `${bootstrap.value?.api_base ?? ""}/web`) -const quickLinks = computed(() => { - const actionLinks = uiActions.value.map(actionToLink).filter((link): link is { label: string; href: string } => Boolean(link)) - return actionLinks.length ? actionLinks : fallbackQuickLinks() -}) const queueTotal = computed(() => { const queue = dashboard.value?.queue return queue ? queue.pending + queue.running + queue.failed + queue.dead_letter : 0 }) +const recentImages = computed(() => dashboard.value?.recent_images.slice(0, 4) ?? []) +const quickLinks = computed(() => { + const actionLinks = uiActions.value.map(actionToLink).filter((link): link is QuickLink => Boolean(link)) + return actionLinks.length ? actionLinks : fallbackQuickLinks() +}) +const metrics = computed(() => [ + { label: "服务状态", value: statusLabel(dashboard.value?.plugin_status ?? "loading") }, + { label: "队列", value: String(queueTotal.value) }, + { label: "运行中", value: String(dashboard.value?.queue.running ?? 0) }, + { label: "失败", value: String(dashboard.value?.queue.failed ?? 0) }, + { label: "存储", value: formatBytes(dashboard.value?.storage.total_bytes ?? 0) }, +]) onMounted(load) @@ -95,33 +53,22 @@ async function load() { uiActions.value = [] } } catch (err) { - error.value = err instanceof Error ? err.message : text.loadFailed + 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` -} - -function workbenchViewUrl(view: string) { - return `${workbenchUrl.value}?view=${encodeURIComponent(view)}` -} - -function fallbackQuickLinks() { +function fallbackQuickLinks(): QuickLink[] { return [ - { label: text.openJobs, href: workbenchViewUrl("jobs") }, - { label: text.openLogs, href: workbenchViewUrl("logs") }, - { label: text.openSettings, href: workbenchViewUrl("settings") }, - { label: text.openMaterials, href: workbenchViewUrl("materials") }, + { label: "队列", href: workbenchViewUrl("queue") }, + { label: "图库", href: workbenchViewUrl("gallery") }, + { label: "日志", href: workbenchViewUrl("logs") }, + { label: "设置", href: workbenchViewUrl("settings") }, ] } -function actionToLink(action: UiAction) { +function actionToLink(action: UiAction): QuickLink | null { if (!bootstrap.value) return null if (action.action_type === "open_workbench") { return { label: actionLabel(action), href: String(action.payload.url || workbenchUrl.value) } @@ -133,128 +80,133 @@ function actionToLink(action: UiAction) { return null } +function workbenchViewUrl(view: string) { + return `${workbenchUrl.value}?view=${encodeURIComponent(view)}` +} + function actionLabel(action: UiAction) { const labels: Record = { - open_workbench: text.workbench, - quick_profile: text.profiles, - open_logs: text.openLogs, - open_settings: text.openSettings, + open_workbench: "工作台", + quick_profile: "角色", + open_logs: "日志", + open_settings: "设置", } return labels[action.action_id] ?? action.label } -function statusLabel(value: unknown) { - const key = String(value || "").trim() - return statusLabels[key] ?? key +function statusLabel(value: string) { + const labels: Record = { + loading: "加载中", + running: "运行中", + degraded: "降级", + stopped: "已停止", + } + return labels[value] ?? value } -function permissionLabel(value: unknown) { - const key = String(value || "").trim() - return permissionLabels[key] ?? key +function imageTitle(image: DashboardImage) { + return image.node_id || image.workflow_id || image.profile_id || shortId(image.image_id) } -function featureLabel(value: unknown) { - const key = String(value || "").trim() - return featureLabels[key] ?? key +function imageUrl(image: DashboardImage) { + return image.thumbnail_url || image.image_url || "" +} + +function shortId(value: string) { + return value.length > 10 ? `${value.slice(0, 6)}...${value.slice(-4)}` : value +} + +function formatBytes(value: number) { + 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` } @@ -262,192 +214,265 @@ function featureLabel(value: unknown) { .plugin-page-shell { box-sizing: border-box; min-height: 100vh; - padding: 24px; - color: #1d2430; - background: #f4f6f8; + padding: 22px; + color: #171923; + background: + linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px), + linear-gradient(180deg, #151820 0%, #242730 100%); + background-size: 78px 78px, auto; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; } -.topbar, -.activity { - display: grid; - gap: 16px; - grid-template-columns: minmax(0, 1fr) auto; - align-items: start; +* { + box-sizing: border-box; +} + +:global(body) { + margin: 0; +} + +:global(#app) { + min-height: 100vh; } h1, h2, -p { +p, +dl, +dd { margin: 0; } +.topbar, +.brand, +.actions { + display: flex; + align-items: center; + gap: 12px; +} + +.topbar { + justify-content: space-between; + color: #ffffff; +} + +.brand { + min-width: 0; +} + +.brand > span { + display: grid; + place-items: center; + width: 44px; + height: 44px; + border-radius: 8px; + color: #5a61d6; + background: #ffffff; + font-weight: 800; +} + +.brand div { + min-width: 0; +} + h1 { - font-size: 24px; - font-weight: 700; + overflow: hidden; + font-size: 22px; + text-overflow: ellipsis; + white-space: nowrap; } h2 { - font-size: 14px; + font-size: 20px; } p, -small, +span, +dt, .empty { - color: #667085; + color: #6f7785; } -.actions { - display: flex; - gap: 8px; - align-items: center; +.topbar p { + color: rgba(255, 255, 255, 0.68); } button, -a.primary { +a.primary, +.quick-links a { + display: inline-flex; + align-items: center; + justify-content: center; min-height: 36px; - padding: 0 14px; - border: 1px solid #c7d0da; + border: 1px solid rgba(255, 255, 255, 0.16); border-radius: 6px; - color: #1d2430; - background: #ffffff; + padding: 0 14px; + color: #ffffff; + background: rgba(255, 255, 255, 0.1); font: inherit; text-decoration: none; cursor: pointer; } +button:disabled { + cursor: wait; + opacity: 0.68; +} + a.primary { - display: inline-flex; - align-items: center; - border-color: #256f5b; - color: #ffffff; - background: #256f5b; + border-color: #7668e8; + background: #7668e8; } -.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, +.panel, +.summary-strip article { + border: 1px solid rgba(32, 41, 56, 0.14); + border-radius: 8px; + background: #f8f7f2; + box-shadow: 0 18px 45px rgba(9, 13, 29, 0.2); } .notice { margin-top: 18px; padding: 14px; - border: 1px solid #d6dde6; - border-radius: 8px; - background: #ffffff; } -.metrics { +.notice.bad { + border-color: rgba(212, 71, 95, 0.34); + color: #9e1f3b; +} + +.summary-strip { display: grid; grid-template-columns: repeat(5, minmax(120px, 1fr)); gap: 12px; - margin-top: 20px; + margin-top: 18px; } -article, -.activity > div { - border: 1px solid #d6dde6; - border-radius: 8px; - background: #ffffff; -} - -article { +.summary-strip article { display: grid; gap: 8px; padding: 16px; } -article span { - color: #667085; - font-size: 13px; -} - -article strong { +.summary-strip strong { font-size: 24px; } -.activity { - grid-template-columns: repeat(2, minmax(0, 1fr)); - margin-top: 16px; -} - -.activity > div { - padding: 16px; -} - -.quick-links { - margin-top: 16px; - padding: 16px; - border: 1px solid #d6dde6; - border-radius: 8px; - background: #ffffff; -} - -.quick-links > div { - display: flex; - flex-wrap: wrap; - gap: 8px; +.content-grid { + display: grid; + grid-template-columns: minmax(220px, 0.8fr) minmax(280px, 1.1fr) minmax(220px, 0.8fr); + gap: 12px; margin-top: 12px; } -.quick-links a { - display: inline-flex; - align-items: center; - min-height: 34px; - padding: 0 12px; - border: 1px solid #c7d0da; - border-radius: 6px; - color: #1d2430; - background: #ffffff; - text-decoration: none; -} - -ul { +.panel { display: grid; - gap: 10px; - margin: 12px 0 0; - padding: 0; - list-style: none; + align-content: start; + gap: 14px; + min-width: 0; + padding: 16px; } -li { +.queue-panel { + border-color: rgba(221, 173, 54, 0.42); +} + +.image-panel { + border-color: rgba(238, 111, 54, 0.38); +} + +.links-panel { + border-color: rgba(118, 104, 232, 0.38); +} + +.panel header span { + font-size: 12px; + font-weight: 700; +} + +dl { + display: grid; + gap: 8px; +} + +dl div { display: flex; justify-content: space-between; gap: 12px; - min-width: 0; + padding-top: 8px; + border-top: 1px solid rgba(32, 41, 56, 0.12); } -li span, -li small { +dd { + font-weight: 800; +} + +.image-grid { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: 10px; +} + +.image-grid article { + display: grid; + gap: 7px; + min-width: 0; + padding: 8px; + border: 1px solid rgba(32, 41, 56, 0.12); + border-radius: 8px; + background: #ebe9e2; +} + +.thumb { + display: grid; + place-items: center; + aspect-ratio: 4 / 3; + overflow: hidden; + border-radius: 8px; + color: #6f7785; + background: linear-gradient(135deg, rgba(118, 104, 232, 0.18), transparent), #ffffff; + font-weight: 800; +} + +.thumb img { + width: 100%; + height: 100%; + object-fit: cover; +} + +.image-grid strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } -@media (max-width: 820px) { - .topbar, - .activity { +.quick-links { + display: grid; + gap: 8px; +} + +.quick-links a { + justify-content: flex-start; + color: #171923; + background: #ebe9e2; +} + +@media (max-width: 900px) { + .topbar { + align-items: flex-start; + flex-direction: column; + } + + .summary-strip, + .content-grid { grid-template-columns: 1fr; } .actions { flex-wrap: wrap; } - - .metrics { - grid-template-columns: repeat(2, minmax(0, 1fr)); - } } diff --git a/frontend/standalone-web/src/App.vue b/frontend/standalone-web/src/App.vue index 289e151..c467ec7 100644 --- a/frontend/standalone-web/src/App.vue +++ b/frontend/standalone-web/src/App.vue @@ -1,3532 +1,2222 @@