提交 536008d9 编写于 作者: D DebugIsFalse

feature: 添加创建收藏夹接口

上级 dc621989
...@@ -41,7 +41,9 @@ ...@@ -41,7 +41,9 @@
<UButton <UButton
size="md" size="md"
label="创建" label="创建"
:loading="loading"
:disabled="!title" :disabled="!title"
@click="handleCreate"
/> />
</div> </div>
</template> </template>
...@@ -50,13 +52,23 @@ ...@@ -50,13 +52,23 @@
</template> </template>
<script setup> <script setup>
const { $isLibraryCreateOpen } = storeToRefs(useLibraryStore()) const { $isLibraryCreateOpen } = storeToRefs(useLibraryStore())
const { $openLibraryCreate, $closeLibraryCreate } = useLibraryStore() const { $closeLibraryCreate } = useLibraryStore()
const { setOrUpdateFavorites } = useFavorites()
const title = ref('') const title = ref('')
const description = ref('') const description = ref('')
const loading = ref(false)
function handleClose () { function handleClose () {
$closeLibraryCreate() $closeLibraryCreate()
} }
function handleOpen () { async function handleCreate () {
$openLibraryCreate if (loading.value) return
loading.value = true
const { data, error } = await setOrUpdateFavorites({
name: title.value,
description: description.value
})
loading.value = false
if (error.value) return
$closeLibraryCreate()
} }
</script> </script>
export default () => { export default () => {
// 创建及修改收藏夹 // 创建及修改收藏夹
const setAndUpdateFavorites = (body) => { const setOrUpdateFavorites = async (body) => {
/* /*
* id number 非必须 有ID参数是修改,没有ID则为新增 * id number 非必须 有ID参数是修改,没有ID则为新增
* name string 非必须 * name string 非必须
...@@ -66,7 +66,7 @@ export default () => { ...@@ -66,7 +66,7 @@ export default () => {
} }
return { return {
getFavorites, getFavorites,
setAndUpdateFavorites, setOrUpdateFavorites,
deleteFavorite, deleteFavorite,
saveFavorite, saveFavorite,
findFavorite, findFavorite,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册