feat: add material library actions

这个提交存在于:
YokiiroBW 2026-07-05 13:15:14 +08:00
父节点 ed0ed578e8
当前提交 29ac4e6fff
共有 6 个文件被更改,包括 181 次插入 和 23 次删除

查看文件

@ -1,13 +1,13 @@
<script setup lang="ts">
import { computed, onMounted, ref } from "vue"
import { endpoints } from "../../shared/api/endpoints"
import { getJson, postJson } from "../../shared/api/client"
import { getJson, postJson, request } from "../../shared/api/client"
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 { Material, MaterialCategory, MaterialListResult } from "../../shared/types/material"
import type { ProfileListResult } from "../../shared/types/profile"
import type {
CurrentSettings,
@ -33,6 +33,17 @@ const text = {
noProfile: "\u672a\u9009\u62e9\u89d2\u8272",
noTags: "\u65e0\u6807\u7b7e",
noImage: "\u672a\u7ed1\u5b9a\u56fe\u7247",
create: "\u65b0\u5efa",
archive: "\u5f52\u6863",
recognize: "\u8bc6\u522b",
confirm: "\u786e\u8ba4",
name: "\u540d\u79f0",
imageUri: "\u56fe\u7247 URI",
tags: "\u6807\u7b7e",
category: "\u5206\u7c7b",
allCategories: "\u5168\u90e8\u5206\u7c7b",
materialCreated: "\u7d20\u6750\u5df2\u521b\u5efa",
materialArchived: "\u7d20\u6750\u5df2\u5f52\u6863",
dashboard: "\u8fd0\u884c\u6982\u89c8",
profiles: "\u89d2\u8272",
materials: "\u7d20\u6750\u5e93",
@ -124,6 +135,12 @@ const signedMedia = ref<MediaSignResult | null>(null)
const settingsDraft = ref("")
const settingsValidation = ref<ValidateSettingsResult | null>(null)
const settingsDiff = ref<DiffSettingsResult | null>(null)
const materialDraft = ref({
display_name: "",
image_uri: "",
tags: "",
category_id: "",
})
const lastOperation = ref("")
const loading = ref(true)
const busy = ref("")
@ -400,6 +417,67 @@ function signFirstMaterial() {
)
}
function resetMaterialDraft() {
materialDraft.value = {
display_name: "",
image_uri: "",
tags: "",
category_id: "",
}
}
function createMaterialDraft() {
return runOperation(
text.create,
async () => {
const material = await postJson<Material>(endpoints.materials, {
display_name: materialDraft.value.display_name,
image_uri: materialDraft.value.image_uri || undefined,
thumbnail_uri: materialDraft.value.image_uri || undefined,
category_id: materialDraft.value.category_id || undefined,
tags: splitCsv(materialDraft.value.tags),
recognition_status: materialDraft.value.image_uri ? "pending_recognition" : "pending_upload",
})
resetMaterialDraft()
lastOperation.value = text.materialCreated
return material
},
)
}
function recognizeMaterial(materialId: string) {
return runOperation(text.recognize, () => postJson<Material>(endpoints.materialRecognize(materialId)))
}
function confirmMaterial(material: Material) {
return runOperation(text.confirm, () =>
postJson<Material>(endpoints.materialConfirm(material.material_id), {
display_name: material.display_name,
prompt: material.prompt,
negative_prompt: material.negative_prompt,
tags: material.tags,
}),
)
}
function archiveMaterial(materialId: string) {
return runOperation(
text.archive,
async () => {
const material = await request<Material>(endpoints.material(materialId), { method: "DELETE" })
lastOperation.value = text.materialArchived
return material
},
)
}
function splitCsv(value: string) {
return value
.split(",")
.map((item) => item.trim())
.filter(Boolean)
}
function formatBytes(value = 0) {
if (value < 1024) return `${value} B`
if (value < 1024 * 1024) return `${(value / 1024).toFixed(1)} KB`
@ -512,13 +590,58 @@ function storageRootBytes(uriPrefix: string) {
</button>
</div>
</header>
<div class="form-grid">
<label>
<span>{{ text.name }}</span>
<input v-model="materialDraft.display_name" type="text" />
</label>
<label>
<span>{{ text.imageUri }}</span>
<input v-model="materialDraft.image_uri" type="text" placeholder="storage://materials/example.png" />
</label>
<label>
<span>{{ text.category }}</span>
<select v-model="materialDraft.category_id">
<option value="">{{ text.allCategories }}</option>
<option
v-for="category in materialCategories"
:key="category.category_id"
:value="category.category_id"
>
{{ category.name }}
</option>
</select>
</label>
<label>
<span>{{ text.tags }}</span>
<input v-model="materialDraft.tags" type="text" placeholder="daily, top" />
</label>
<button type="button" :disabled="Boolean(busy) || !materialDraft.display_name" @click="createMaterialDraft">
{{ text.create }}
</button>
</div>
<ul>
<li v-for="material in materials?.items ?? []" :key="material.material_id">
<div>
<strong>{{ material.display_name }}</strong>
<small>{{ material.image_uri ?? text.noImage }}</small>
</div>
<span class="badge">{{ material.recognition_status }}</span>
<div class="inline-actions">
<span class="badge">{{ material.recognition_status }}</span>
<button type="button" :disabled="Boolean(busy)" @click="recognizeMaterial(material.material_id)">
{{ text.recognize }}
</button>
<button
type="button"
:disabled="Boolean(busy) || material.recognition_status === 'confirmed'"
@click="confirmMaterial(material)"
>
{{ text.confirm }}
</button>
<button type="button" :disabled="Boolean(busy)" @click="archiveMaterial(material.material_id)">
{{ text.archive }}
</button>
</div>
</li>
<li v-if="!materials?.items.length" class="empty">{{ text.emptyMaterials }}</li>
</ul>
@ -1006,6 +1129,41 @@ textarea {
font: 12px/1.5 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}
.form-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 10px;
margin-top: 14px;
padding: 12px;
border: 1px solid #eef1f5;
border-radius: 8px;
background: #fbfcfd;
}
label {
display: grid;
gap: 5px;
min-width: 0;
}
label span {
color: #667085;
font-size: 12px;
}
input,
select {
box-sizing: border-box;
width: 100%;
min-height: 34px;
border: 1px solid #c7d0da;
border-radius: 6px;
padding: 0 10px;
color: #1b2430;
background: #ffffff;
font: inherit;
}
ul {
display: grid;
gap: 10px;

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

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

查看文件

@ -1 +0,0 @@
.web-shell[data-v-ec65c5ac]{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-ec65c5ac],.inspector[data-v-ec65c5ac]{background:#fff}.sidebar[data-v-ec65c5ac]{border-right:1px solid #d9e0e8;padding:20px}.inspector[data-v-ec65c5ac]{border-left:1px solid #d9e0e8;padding:20px}.brand[data-v-ec65c5ac]{display:grid;gap:4px;margin-bottom:24px}.brand strong[data-v-ec65c5ac]{font-size:19px}.brand span[data-v-ec65c5ac],p[data-v-ec65c5ac],dt[data-v-ec65c5ac],.empty[data-v-ec65c5ac],small[data-v-ec65c5ac]{color:#667085}nav[data-v-ec65c5ac]{display:grid;gap:6px}button[data-v-ec65c5ac]{min-height:36px;border:1px solid #c7d0da;border-radius:6px;color:#1b2430;background:#fff;font:inherit;text-align:center;cursor:pointer}button[data-v-ec65c5ac]:disabled{cursor:wait;opacity:.62}nav button[data-v-ec65c5ac]{border-color:transparent;background:transparent;text-align:left;padding:0 10px}button.active[data-v-ec65c5ac]{border-color:#b8d8cf;color:#164f43;background:#e5f4ef}.workspace[data-v-ec65c5ac]{min-width:0;padding:24px}.topbar[data-v-ec65c5ac],.list-view header[data-v-ec65c5ac],.toolbar[data-v-ec65c5ac],.inline-actions[data-v-ec65c5ac]{display:flex;gap:12px;align-items:center}.topbar[data-v-ec65c5ac],.list-view header[data-v-ec65c5ac]{justify-content:space-between}.actions[data-v-ec65c5ac],.inline-actions[data-v-ec65c5ac]{flex-wrap:wrap;justify-content:flex-end}.topbar button[data-v-ec65c5ac],.toolbar button[data-v-ec65c5ac],.list-view header button[data-v-ec65c5ac],.inline-actions button[data-v-ec65c5ac]{padding:0 14px}h1[data-v-ec65c5ac],h2[data-v-ec65c5ac],p[data-v-ec65c5ac],dl[data-v-ec65c5ac],dd[data-v-ec65c5ac]{margin:0}h1[data-v-ec65c5ac]{min-height:30px;font-size:26px}h2[data-v-ec65c5ac]{font-size:15px}.notice[data-v-ec65c5ac],article[data-v-ec65c5ac],.list-view[data-v-ec65c5ac],.editor-panel[data-v-ec65c5ac],pre[data-v-ec65c5ac]{border:1px solid #d9e0e8;border-radius:8px;background:#fff}.notice[data-v-ec65c5ac]{margin-top:18px;padding:14px}.error[data-v-ec65c5ac]{border-color:#f0b4b4;color:#8a1f1f;background:#fff7f7}.dashboard-grid[data-v-ec65c5ac],.split-view[data-v-ec65c5ac]{display:grid;gap:12px;margin-top:18px}.dashboard-grid[data-v-ec65c5ac]{grid-template-columns:repeat(4,minmax(130px,1fr))}.split-view[data-v-ec65c5ac]{grid-template-columns:repeat(2,minmax(0,1fr))}article[data-v-ec65c5ac]{display:grid;gap:8px;padding:16px}article span[data-v-ec65c5ac]{color:#667085;font-size:13px}article strong[data-v-ec65c5ac]{font-size:24px}.list-view[data-v-ec65c5ac],.logs-view[data-v-ec65c5ac],.settings-view[data-v-ec65c5ac]{margin-top:18px}.split-view .list-view[data-v-ec65c5ac],.logs-view .list-view[data-v-ec65c5ac]{margin-top:0}.list-view[data-v-ec65c5ac]{padding:16px}.editor-panel[data-v-ec65c5ac]{display:grid;gap:12px;margin-top:12px;padding:16px}.editor-panel header[data-v-ec65c5ac]{display:flex;justify-content:space-between;gap:12px;min-width:0}textarea[data-v-ec65c5ac]{box-sizing:border-box;width:100%;min-height:300px;resize:vertical;border:1px solid #c7d0da;border-radius:6px;padding:12px;color:#1b2430;background:#fbfcfd;font:12px/1.5 ui-monospace,SFMono-Regular,Consolas,Liberation Mono,monospace}ul[data-v-ec65c5ac]{display:grid;gap:10px;margin:14px 0 0;padding:0;list-style:none}li[data-v-ec65c5ac]{display:flex;justify-content:space-between;gap:12px;min-width:0;padding:10px 0;border-top:1px solid #eef1f5}li[data-v-ec65c5ac]:first-child{border-top:0}li>div[data-v-ec65c5ac]{display:grid;gap:3px;min-width:0}li strong[data-v-ec65c5ac],li span[data-v-ec65c5ac],li small[data-v-ec65c5ac]{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.badge[data-v-ec65c5ac]{align-self:center;max-width:180px;border-radius:999px;padding:4px 9px;color:#1f4d62;background:#e5f1f7;font-size:12px}.toolbar[data-v-ec65c5ac]{justify-content:flex-start;margin:18px 0 12px}.settings-sections[data-v-ec65c5ac]{display:grid;grid-template-columns:repeat(3,minmax(120px,1fr));gap:12px}pre[data-v-ec65c5ac]{overflow:auto;max-height:420px;margin:12px 0 0;padding:14px;font-size:12px;line-height:1.5}dl[data-v-ec65c5ac]{display:grid;gap:12px;margin:14px 0 24px}dl div[data-v-ec65c5ac]{display:flex;justify-content:space-between}@media(max-width:1160px){.web-shell[data-v-ec65c5ac]{grid-template-columns:190px minmax(0,1fr)}.inspector[data-v-ec65c5ac]{display:none}}@media(max-width:820px){.web-shell[data-v-ec65c5ac]{grid-template-columns:1fr}.sidebar[data-v-ec65c5ac]{border-right:0;border-bottom:1px solid #d9e0e8}nav[data-v-ec65c5ac]{grid-template-columns:repeat(4,minmax(0,1fr))}nav button[data-v-ec65c5ac]{text-align:center}.dashboard-grid[data-v-ec65c5ac],.split-view[data-v-ec65c5ac],.settings-sections[data-v-ec65c5ac]{grid-template-columns:1fr}.topbar[data-v-ec65c5ac],.list-view header[data-v-ec65c5ac]{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-hovnaFZS.js"></script>
<link rel="stylesheet" crossorigin href="/api/v1/plugins/extensions/astrbot_plugin_imagestudio/web/assets/index-ChK1ouSS.css">
<script type="module" crossorigin src="/api/v1/plugins/extensions/astrbot_plugin_imagestudio/web/assets/index-BYQHrko-.js"></script>
<link rel="stylesheet" crossorigin href="/api/v1/plugins/extensions/astrbot_plugin_imagestudio/web/assets/index-CRHbO3Gr.css">
<div id="app"></div>