export default () => { // 创建及修改收藏夹 const setOrUpdateCollection = async (body) => { /* * id number 非必须 有ID参数是修改,没有ID则为新增 * name string 非必须 * is_public number 非必须 * description string * */ const {data, error} = await useRequest('/v1/collection/merge', { method: 'post', body }) 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`, { method: 'post' }) return { data, error } } // 将会话添加到收藏夹 const saveCollection = async (body) => { // collection_id number 收藏夹ID // c_id string 会话ID const {data, error} = await useRequest(`/v1/collection/item/add`, { method: 'post', body }) return { data, error } } // 查询收藏夹会话列表 const findCollection = async (collection_id) => { const {data, error} = await useRequest(`/v1/collection/${collection_id}/items`, { method: 'get' }) if (error.value) { return [] } return data.value.data || [] } // 删除收藏夹会话 const deleteCollectionRecord = async (collection_id, c_id) => { const {data, error} = await useRequest(`/v1/collection/item/delete`, { method: 'post', body: { collection_id, c_id } }) return { data, error } } // 查询会话是否被收藏 const findRecordCollection = async (c_id) => { const {data, error} = await useRequest(`/v1/collection/item/check/${c_id}`, { method: 'get' }) return { data, error } } return { getCollection, setOrUpdateCollection, deleteCollection, saveCollection, findCollection, deleteCollectionRecord, findRecordCollection } }