提交 c7150c80 编写于 作者: View Design's avatar View Design

Merge branch 'main' of gitcode.com:git_bot/ai-fe

...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
</div> </div>
<div class="flex gap-2"> <div class="flex gap-2">
<ClientOnly> <ClientOnly>
<UButton v-if="SM" color="gray" variant="ghost" leading-icon="i-heroicons-plus-20-solid">收藏</UButton> <UButton v-if="SM" @click="handleSave" color="gray" variant="ghost" leading-icon="i-heroicons-plus-20-solid">收藏</UButton>
</ClientOnly> </ClientOnly>
<UPopover v-model:open="isShareOpen"> <UPopover v-model:open="isShareOpen">
<UButton :leading-icon="isOpen ? 'i-heroicons-share-20-solid' : 'i-heroicons-lock-closed-20-solid'" @click="handleSetOpenState">分享</UButton> <UButton :leading-icon="isOpen ? 'i-heroicons-share-20-solid' : 'i-heroicons-lock-closed-20-solid'" @click="handleSetOpenState">分享</UButton>
...@@ -79,7 +79,7 @@ ...@@ -79,7 +79,7 @@
<script setup> <script setup>
const toast = useToast() const toast = useToast()
const route = useRoute() const route = useRoute()
const { $openLibrarySelect } = useLibraryStore() const { $openLibraryCreate, $openLibrarySelect } = useLibraryStore()
const props = defineProps({ const props = defineProps({
query: String, query: String,
isPublic: { isPublic: {
...@@ -132,7 +132,7 @@ async function handleSetOpenState() { ...@@ -132,7 +132,7 @@ async function handleSetOpenState() {
} }
} }
function handleOpenSelect () { function handleOpenSelect () {
$openLibrarySelect() $openLibrarySelect(route.params.id)
} }
defineExpose({ defineExpose({
isOpen, isOpen,
......
export default () => {
// 创建及修改收藏夹
const setAndUpdateFavorites = (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 getFavorites = async () => {
const { data, error } = await useRequest('/v1/collection/list', {
method: 'get'
})
if (!error.value) {
return []
}
return data.value.data || []
}
// 删除收藏夹
const deleteFavorite = async (collection_id) => {
const {data, error} = await useRequest(`/v1/collection/${collection_id}/remove`, {
method: 'post'
})
return { data, error }
}
// 将会话添加到收藏夹
const saveFavorite = 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 findFavorite = async (collection_id) => {
const {data, error} = await useRequest(`/v1/collection/${collection_id}/items`, {
method: 'post',
body
})
return { data, error }
}
// 删除收藏夹会话
const deleteFavoriteCollection = 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 findCollectionFavorites = async (c_id) => {
const {data, error} = await useRequest(`/v1/collection/item/check/${c_id}`, {
method: 'get'
})
return { data, error }
}
return {
getFavorites,
setAndUpdateFavorites,
deleteFavorite,
saveFavorite,
findFavorite,
deleteFavoriteCollection,
findCollectionFavorites
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册