feat: add material category management
这个提交存在于:
父节点
34b9a6227a
当前提交
8c6c99d7ae
共有 9 个文件被更改,包括 126 次插入 和 23 次删除
|
|
@ -42,6 +42,7 @@ export const endpoints = {
|
||||||
storageStatus: "storage/status",
|
storageStatus: "storage/status",
|
||||||
mediaSign: "media/sign",
|
mediaSign: "media/sign",
|
||||||
materialCategories: "material-categories",
|
materialCategories: "material-categories",
|
||||||
|
materialCategory: (categoryId: string) => `material-categories/${categoryId}`,
|
||||||
materials: "materials",
|
materials: "materials",
|
||||||
material: (materialId: string) => `materials/${materialId}`,
|
material: (materialId: string) => `materials/${materialId}`,
|
||||||
materialRecognize: (materialId: string) => `materials/${materialId}/recognize`,
|
materialRecognize: (materialId: string) => `materials/${materialId}/recognize`,
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,8 @@ const text = {
|
||||||
unselect: "\u53d6\u9009",
|
unselect: "\u53d6\u9009",
|
||||||
recognize: "\u8bc6\u522b",
|
recognize: "\u8bc6\u522b",
|
||||||
confirm: "\u786e\u8ba4",
|
confirm: "\u786e\u8ba4",
|
||||||
|
edit: "\u7f16\u8f91",
|
||||||
|
update: "\u66f4\u65b0",
|
||||||
name: "\u540d\u79f0",
|
name: "\u540d\u79f0",
|
||||||
identity: "\u8eab\u4efd",
|
identity: "\u8eab\u4efd",
|
||||||
personality: "\u6027\u683c",
|
personality: "\u6027\u683c",
|
||||||
|
|
@ -123,6 +125,11 @@ const text = {
|
||||||
imageDeleted: "\u56fe\u7247\u5df2\u5220\u9664",
|
imageDeleted: "\u56fe\u7247\u5df2\u5220\u9664",
|
||||||
currentBranch: "\u5f53\u524d\u5206\u652f",
|
currentBranch: "\u5f53\u524d\u5206\u652f",
|
||||||
materialCategories: "\u7d20\u6750\u5206\u7c7b",
|
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",
|
materialItems: "\u7d20\u6750\u6761\u76ee",
|
||||||
emptyCategories: "\u6682\u65e0\u5206\u7c7b",
|
emptyCategories: "\u6682\u65e0\u5206\u7c7b",
|
||||||
emptyMaterials: "\u6682\u65e0\u7d20\u6750",
|
emptyMaterials: "\u6682\u65e0\u7d20\u6750",
|
||||||
|
|
@ -264,6 +271,12 @@ const materialDraft = ref({
|
||||||
tags: "",
|
tags: "",
|
||||||
category_id: "",
|
category_id: "",
|
||||||
})
|
})
|
||||||
|
const categoryDraft = ref({
|
||||||
|
category_id: "",
|
||||||
|
name: "",
|
||||||
|
category_type: "material",
|
||||||
|
sort_order: 0,
|
||||||
|
})
|
||||||
const wardrobeDraft = ref({
|
const wardrobeDraft = ref({
|
||||||
material_id: "",
|
material_id: "",
|
||||||
wardrobe_category: "top",
|
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() {
|
function resetMaterialDraft() {
|
||||||
materialDraft.value = {
|
materialDraft.value = {
|
||||||
display_name: "",
|
display_name: "",
|
||||||
|
|
@ -1406,13 +1482,39 @@ function storageRootBytes(uriPrefix: string) {
|
||||||
<h2>{{ text.materialCategories }}</h2>
|
<h2>{{ text.materialCategories }}</h2>
|
||||||
<span>{{ materialCategories.length }}</span>
|
<span>{{ materialCategories.length }}</span>
|
||||||
</header>
|
</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>
|
<ul>
|
||||||
<li v-for="category in materialCategories" :key="category.category_id">
|
<li v-for="category in materialCategories" :key="category.category_id">
|
||||||
<div>
|
<div>
|
||||||
<strong>{{ category.name }}</strong>
|
<strong>{{ category.name }}</strong>
|
||||||
<small>{{ category.category_type }}</small>
|
<small>{{ category.category_type }}</small>
|
||||||
</div>
|
</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>
|
||||||
<li v-if="!materialCategories.length" class="empty">{{ text.emptyCategories }}</li>
|
<li v-if="!materialCategories.length" class="empty">{{ text.emptyCategories }}</li>
|
||||||
</ul>
|
</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">
|
<link rel="stylesheet" crossorigin href="/assets/index-KxvCyOGk.css">
|
||||||
<div id="app"></div>
|
<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>
|
<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-j0ue-P67.css">
|
<link rel="stylesheet" crossorigin href="/api/v1/plugins/extensions/astrbot_plugin_imagestudio/web/assets/index-BIieFzP4.css">
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
|
|
|
||||||
正在加载…
添加表格
在新工单中引用