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

fix: 修改事件名称

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