提交 9a7f07cf 编写于 作者: D DebugIsFalse

fix: 修改事件名称

上级 afaab892
......@@ -53,7 +53,7 @@
<script setup>
const { $isLibraryCreateOpen } = storeToRefs(useLibraryStore())
const { $closeLibraryCreate } = useLibraryStore()
const { setOrUpdateFavorites } = useFavorites()
const { setOrUpdateFavorites } = useCollectionRequest()
const title = ref('')
const description = ref('')
const loading = ref(false)
......@@ -63,7 +63,7 @@ function handleClose () {
async function handleCreate () {
if (loading.value) return
loading.value = true
const { data, error } = await setOrUpdateFavorites({
const { error } = await setOrUpdateFavorites({
name: title.value,
description: description.value
})
......
......@@ -13,6 +13,7 @@
</div>
</template>
<div class="flex flex-col gap-4">
{{ collection }}
<UButton
leading-icon="i-heroicons-plus-20-solid"
label="创建新集合"
......@@ -47,6 +48,9 @@
<script setup>
const { $isLibrarySelectOpen } = storeToRefs(useLibraryStore())
const { $openLibrarySelect, $closeLibrarySelect, $openLibraryCreate } = useLibraryStore()
const { getCollection } = useCollectionRequest()
// 收藏夹数据
const collection = ref([])
function handleClose () {
$closeLibrarySelect()
}
......@@ -57,4 +61,11 @@ function handleOpenCreate () {
handleClose()
$openLibraryCreate()
}
async function getCollectionData () {
collection.value = await getCollection()
}
watch(() => $isLibrarySelectOpen.value, () => {
getCollectionData()
})
</script>
export default () => {
// 创建及修改收藏夹
const setOrUpdateFavorites = async (body) => {
const setOrUpdateCollection = async (body) => {
/*
* id number 非必须 有ID参数是修改,没有ID则为新增
* name string 非必须
......@@ -14,8 +14,8 @@ export default () => {
})
return { data, error }
}
// 收藏夹列表
const getFavorites = async () => {
// 集合列表
const getCollection = async () => {
const { data, error } = await useRequest('/v1/collection/list', {
method: 'get'
})
......@@ -25,14 +25,14 @@ export default () => {
return data.value.data || []
}
// 删除收藏夹
const deleteFavorite = async (collection_id) => {
const deleteCollection = async (collection_id) => {
const {data, error} = await useRequest(`/v1/collection/${collection_id}/remove`, {
method: 'post'
})
return { data, error }
}
// 将会话添加到收藏夹
const saveFavorite = async (body) => {
const saveCollection = async (body) => {
// collection_id number 收藏夹ID
// c_id string 会话ID
const {data, error} = await useRequest(`/v1/collection/item/add`, {
......@@ -42,7 +42,7 @@ export default () => {
return { data, error }
}
// 查询收藏夹会话列表
const findFavorite = async (collection_id) => {
const findCollection = async (collection_id) => {
const {data, error} = await useRequest(`/v1/collection/${collection_id}/items`, {
method: 'post',
body
......@@ -50,7 +50,7 @@ export default () => {
return { data, error }
}
// 删除收藏夹会话
const deleteFavoriteCollection = async (collection_id, c_id) => {
const deleteCollectionRecord = async (collection_id, c_id) => {
const {data, error} = await useRequest(`/v1/collection/item/delete`, {
method: 'post',
body: { collection_id, c_id }
......@@ -58,19 +58,19 @@ export default () => {
return { data, error }
}
// 查询会话是否被收藏
const findCollectionFavorites = async (c_id) => {
const findRecordCollection = async (c_id) => {
const {data, error} = await useRequest(`/v1/collection/item/check/${c_id}`, {
method: 'get'
})
return { data, error }
}
return {
getFavorites,
setOrUpdateFavorites,
deleteFavorite,
saveFavorite,
findFavorite,
deleteFavoriteCollection,
findCollectionFavorites
getCollection,
setOrUpdateCollection,
deleteCollection,
saveCollection,
findCollection,
deleteCollectionRecord,
findRecordCollection
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册