From 43a6ddf4c040d0f7b9daabc8a779ba66f665e727 Mon Sep 17 00:00:00 2001 From: Aresn Date: Fri, 31 May 2024 11:18:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B6=E8=97=8F=E5=A4=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/i/library/Select.vue | 9 +++------ composables/useCollectionRequest.js | 17 ++--------------- pages/library/[id].vue | 12 +++++------- pages/library/index.vue | 13 ++++--------- stores/library.js | 11 ++++++++++- 5 files changed, 24 insertions(+), 38 deletions(-) diff --git a/components/i/library/Select.vue b/components/i/library/Select.vue index ae9104d..dea5e52 100644 --- a/components/i/library/Select.vue +++ b/components/i/library/Select.vue @@ -50,8 +50,8 @@ diff --git a/composables/useCollectionRequest.js b/composables/useCollectionRequest.js index 0558317..cf43a34 100644 --- a/composables/useCollectionRequest.js +++ b/composables/useCollectionRequest.js @@ -14,16 +14,6 @@ export default () => { }) return { data, error } } - // 合集列表 - const getCollection = async () => { - const { data, error } = await useRequest('/v1/collection/list', { - method: 'get' - }) - if (error.value) { - return [] - } - return data.value.data || [] - } // 删除收藏夹 const deleteCollection = async (collection_id) => { const {data, error} = await useRequest(`/v1/collection/${collection_id}/remove`, { @@ -43,7 +33,7 @@ export default () => { } // 查询收藏夹会话列表 const findCollection = async (collection_id) => { - const {data, error} = await useRequest(`/v1/collection/${collection_id}/items`, { method: 'get' }) + const {data, error} = await useRequest(`/v1/collection/${collection_id}/items`) if (error.value) { return [] } @@ -59,13 +49,10 @@ export default () => { } // 查询会话是否被收藏 const findRecordCollection = async (c_id) => { - const {data, error} = await useRequest(`/v1/collection/item/check/${c_id}`, { - method: 'get' - }) + const {data, error} = await useRequest(`/v1/collection/item/check/${c_id}`) return { data, error } } return { - getCollection, setOrUpdateCollection, deleteCollection, saveCollection, diff --git a/pages/library/[id].vue b/pages/library/[id].vue index 00e3f40..e6938c1 100644 --- a/pages/library/[id].vue +++ b/pages/library/[id].vue @@ -19,13 +19,14 @@ \ No newline at end of file diff --git a/pages/library/index.vue b/pages/library/index.vue index 175b859..6a97bc2 100644 --- a/pages/library/index.vue +++ b/pages/library/index.vue @@ -26,7 +26,7 @@
@@ -37,23 +37,18 @@
diff --git a/stores/library.js b/stores/library.js index 982c9f6..30d1cdf 100644 --- a/stores/library.js +++ b/stores/library.js @@ -6,6 +6,8 @@ export const useLibraryStore = defineStore('library', () => { const $selectThreadId = ref('') const $selectCollectionId = ref([]) + const $collection = ref([]) + function $openLibraryCreate () { $isLibraryCreateOpen.value = true } @@ -23,6 +25,11 @@ export const useLibraryStore = defineStore('library', () => { function $setSelectCollectionId (ids) { $selectCollectionId.value = ids } + + async function $getCollection () { + const { data } = await useRequest('/v1/collection/list') + $collection.value = data.value.data + } return { $selectThreadId, $isLibraryCreateOpen, @@ -32,6 +39,8 @@ export const useLibraryStore = defineStore('library', () => { $openLibrarySelect, $closeLibrarySelect, $selectCollectionId, - $setSelectCollectionId + $setSelectCollectionId, + $collection, + $getCollection } }) -- GitLab