feat: add material category management
这个提交存在于:
父节点
34b9a6227a
当前提交
8c6c99d7ae
共有 9 个文件被更改,包括 126 次插入 和 23 次删除
|
|
@ -42,6 +42,7 @@ export const endpoints = {
|
|||
storageStatus: "storage/status",
|
||||
mediaSign: "media/sign",
|
||||
materialCategories: "material-categories",
|
||||
materialCategory: (categoryId: string) => `material-categories/${categoryId}`,
|
||||
materials: "materials",
|
||||
material: (materialId: string) => `materials/${materialId}`,
|
||||
materialRecognize: (materialId: string) => `materials/${materialId}/recognize`,
|
||||
|
|
|
|||
|
|
@ -57,6 +57,8 @@ const text = {
|
|||
unselect: "\u53d6\u9009",
|
||||
recognize: "\u8bc6\u522b",
|
||||
confirm: "\u786e\u8ba4",
|
||||
edit: "\u7f16\u8f91",
|
||||
update: "\u66f4\u65b0",
|
||||
name: "\u540d\u79f0",
|
||||
identity: "\u8eab\u4efd",
|
||||
personality: "\u6027\u683c",
|
||||
|
|
@ -123,6 +125,11 @@ const text = {
|
|||
imageDeleted: "\u56fe\u7247\u5df2\u5220\u9664",
|
||||
currentBranch: "\u5f53\u524d\u5206\u652f",
|
||||
materialCategories: "\u7d20\u6750\u5206\u7c7b",
|
||||
categoryType: "\u5206\u7c7b\u7c7b\u578b",
|
||||
sortOrder: "\u6392\u5e8f",
|
||||
categoryCreated: "\u5206\u7c7b\u5df2\u521b\u5efa",
|
||||
categoryUpdated: "\u5206\u7c7b\u5df2\u66f4\u65b0",
|
||||
categoryDeleted: "\u5206\u7c7b\u5df2\u5220\u9664",
|
||||
materialItems: "\u7d20\u6750\u6761\u76ee",
|
||||
emptyCategories: "\u6682\u65e0\u5206\u7c7b",
|
||||
emptyMaterials: "\u6682\u65e0\u7d20\u6750",
|
||||
|
|
@ -264,6 +271,12 @@ const materialDraft = ref({
|
|||
tags: "",
|
||||
category_id: "",
|
||||
})
|
||||
const categoryDraft = ref({
|
||||
category_id: "",
|
||||
name: "",
|
||||
category_type: "material",
|
||||
sort_order: 0,
|
||||
})
|
||||
const wardrobeDraft = ref({
|
||||
material_id: "",
|
||||
wardrobe_category: "top",
|
||||
|
|
@ -1004,6 +1017,69 @@ function signFirstMaterial() {
|
|||
)
|
||||
}
|
||||
|
||||
function resetCategoryDraft() {
|
||||
categoryDraft.value = {
|
||||
category_id: "",
|
||||
name: "",
|
||||
category_type: "material",
|
||||
sort_order: 0,
|
||||
}
|
||||
}
|
||||
|
||||
function editCategoryDraft(category: MaterialCategory) {
|
||||
categoryDraft.value = {
|
||||
category_id: category.category_id,
|
||||
name: category.name,
|
||||
category_type: category.category_type,
|
||||
sort_order: category.sort_order,
|
||||
}
|
||||
}
|
||||
|
||||
function saveCategoryDraft() {
|
||||
const payload = {
|
||||
name: categoryDraft.value.name,
|
||||
category_type: categoryDraft.value.category_type,
|
||||
sort_order: Number(categoryDraft.value.sort_order) || 0,
|
||||
}
|
||||
if (categoryDraft.value.category_id) {
|
||||
return runOperation(
|
||||
text.update,
|
||||
async () => {
|
||||
const category = await request<MaterialCategory>(endpoints.materialCategory(categoryDraft.value.category_id), {
|
||||
method: "PUT",
|
||||
body: payload,
|
||||
})
|
||||
resetCategoryDraft()
|
||||
lastOperation.value = text.categoryUpdated
|
||||
return category
|
||||
},
|
||||
)
|
||||
}
|
||||
return runOperation(
|
||||
text.create,
|
||||
async () => {
|
||||
const category = await postJson<MaterialCategory>(endpoints.materialCategories, payload)
|
||||
resetCategoryDraft()
|
||||
lastOperation.value = text.categoryCreated
|
||||
return category
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
function deleteCategory(categoryId: string) {
|
||||
return runOperation(
|
||||
text.delete,
|
||||
async () => {
|
||||
const category = await request<MaterialCategory>(endpoints.materialCategory(categoryId), { method: "DELETE" })
|
||||
if (categoryDraft.value.category_id === categoryId) {
|
||||
resetCategoryDraft()
|
||||
}
|
||||
lastOperation.value = text.categoryDeleted
|
||||
return category
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
function resetMaterialDraft() {
|
||||
materialDraft.value = {
|
||||
display_name: "",
|
||||
|
|
@ -1406,13 +1482,39 @@ function storageRootBytes(uriPrefix: string) {
|
|||
<h2>{{ text.materialCategories }}</h2>
|
||||
<span>{{ materialCategories.length }}</span>
|
||||
</header>
|
||||
<div class="form-grid">
|
||||
<label>
|
||||
<span>{{ text.name }}</span>
|
||||
<input v-model="categoryDraft.name" type="text" />
|
||||
</label>
|
||||
<label>
|
||||
<span>{{ text.categoryType }}</span>
|
||||
<input v-model="categoryDraft.category_type" type="text" />
|
||||
</label>
|
||||
<label>
|
||||
<span>{{ text.sortOrder }}</span>
|
||||
<input v-model.number="categoryDraft.sort_order" type="number" />
|
||||
</label>
|
||||
<button type="button" :disabled="Boolean(busy) || !categoryDraft.name" @click="saveCategoryDraft">
|
||||
{{ categoryDraft.category_id ? text.update : text.create }}
|
||||
</button>
|
||||
<button type="button" :disabled="Boolean(busy)" @click="resetCategoryDraft">{{ text.reset }}</button>
|
||||
</div>
|
||||
<ul>
|
||||
<li v-for="category in materialCategories" :key="category.category_id">
|
||||
<div>
|
||||
<strong>{{ category.name }}</strong>
|
||||
<small>{{ category.category_type }}</small>
|
||||
</div>
|
||||
<span>{{ category.sort_order }}</span>
|
||||
<div class="inline-actions">
|
||||
<span>{{ category.sort_order }}</span>
|
||||
<button type="button" :disabled="Boolean(busy)" @click="editCategoryDraft(category)">
|
||||
{{ text.edit }}
|
||||
</button>
|
||||
<button type="button" :disabled="Boolean(busy)" @click="deleteCategory(category.category_id)">
|
||||
{{ text.delete }}
|
||||
</button>
|
||||
</div>
|
||||
</li>
|
||||
<li v-if="!materialCategories.length" class="empty">{{ text.emptyCategories }}</li>
|
||||
</ul>
|
||||
|
|
|
|||
文件差异因一行或多行过长而隐藏
|
|
@ -1,3 +1,3 @@
|
|||
<script type="module" crossorigin src="/assets/index-CE3k-RVU.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-B68-Ulnb.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-KxvCyOGk.css">
|
||||
<div id="app"></div>
|
||||
|
|
|
|||
文件差异因一行或多行过长而隐藏
17
web/assets/index-CHyJF1hX.js
普通文件
17
web/assets/index-CHyJF1hX.js
普通文件
文件差异因一行或多行过长而隐藏
文件差异因一行或多行过长而隐藏
文件差异因一行或多行过长而隐藏
|
|
@ -1,3 +1,3 @@
|
|||
<script type="module" crossorigin src="/api/v1/plugins/extensions/astrbot_plugin_imagestudio/web/assets/index-MqTalN3g.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/api/v1/plugins/extensions/astrbot_plugin_imagestudio/web/assets/index-j0ue-P67.css">
|
||||
<script type="module" crossorigin src="/api/v1/plugins/extensions/astrbot_plugin_imagestudio/web/assets/index-CHyJF1hX.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/api/v1/plugins/extensions/astrbot_plugin_imagestudio/web/assets/index-BIieFzP4.css">
|
||||
<div id="app"></div>
|
||||
|
|
|
|||
正在加载…
添加表格
在新工单中引用