export default () => { const { $getCollection } = useLibraryStore() // 创建及修改收藏夹 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 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`) 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 } }) $getCollection() return { data, error } } // 查询会话是否被收藏 const findRecordCollection = async (c_id) => { const { data, error } = await useRequest(`/v1/collection/item/check/${c_id}`) return { data, error } } const deleteThread = async (ids) => { const { data, error } = await useRequest('/v1/chat/completion/remove', { method: 'post', body: ids }) return { data, error } } const getRepoStars = async (params) => { /* url githuburl 多个使用逗号分割 per 数据统计粒度,day,week,month,默认是用week day_period 查询周期天,默认365 */ const { data, error } = await useRequest('/v1/repo/stars', { params }) if (error.value) return [] return data.value.data } return { setOrUpdateCollection, deleteCollection, saveCollection, findCollection, deleteCollectionRecord, findRecordCollection, deleteThread, getRepoStars } }