提交 d1d64c48 编写于 作者: D DebugIsFalse

fix: 更新收藏编辑操作

上级 e53943f7
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
</UModal> </UModal>
</template> </template>
<script setup> <script setup>
const { $isLibraryCreateOpen } = storeToRefs(useLibraryStore()) const { $isLibraryCreateOpen, $collection } = storeToRefs(useLibraryStore())
const { $closeLibraryCreate, $getCollection } = useLibraryStore() const { $closeLibraryCreate, $getCollection } = useLibraryStore()
const { setOrUpdateCollection } = useCollectionRequest() const { setOrUpdateCollection } = useCollectionRequest()
const props = defineProps({ const props = defineProps({
...@@ -98,12 +98,34 @@ function handleCloseModal () { ...@@ -98,12 +98,34 @@ function handleCloseModal () {
if (!props.id) $isLibraryCreateOpen.value = false if (!props.id) $isLibraryCreateOpen.value = false
else updateVisible.value = false else updateVisible.value = false
} }
function handleUpdate () { async function handleUpdate () {
if (loading.value) return
loading.value = true
const { error } = await setOrUpdateCollection({
id: Number(props.id),
name: title.value,
description: description.value
})
loading.value = false
if (error.value) return
handleCloseModal()
$getCollection()
}
function handleFillInfo () {
const collection =$collection.value
const id = Number(props.id)
const { name, description:currentDes } = collection.find(item => item.id === id)
if (name) {
title.value = name
description.value = currentDes
}
} }
function openUpdate () { function openUpdate () {
updateVisible.value = true updateVisible.value = true
// todo 获取合集数据 // todo 获取合集数据
if (props.id) {
handleFillInfo()
}
} }
defineExpose({ defineExpose({
openUpdate openUpdate
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册