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

delete thread

上级 4193fcde
......@@ -9,9 +9,11 @@
</UDropdown>
</template>
<script setup>
import { IConfirm } from '#components';
const { $openLibrarySelect } = useLibraryStore()
const { deleteCollectionRecord } = useCollectionRequest()
const { deleteCollectionRecord, deleteThread } = useCollectionRequest()
const Layout = inject('Layout')
const modal = useModal()
const props = defineProps({
collection_id: {
type: [String, Number],
......@@ -22,6 +24,7 @@ const props = defineProps({
default: ''
}
})
const emit = defineEmits(['delete'])
const actionItems = computed(() => {
let items
if (props.collection_id && props.c_id) {
......@@ -58,7 +61,21 @@ const actionItems = computed(() => {
}
items.push({
label: '删除主题',
icon: 'i-heroicons-trash'
icon: 'i-heroicons-trash',
click: async () => {
modal.open(IConfirm, {
title: '删除确认',
description: '确定要删除该主题吗?',
async onSuccess() {
modal.close()
await deleteThread([props.c_id])
emit('delete')
},
onCancel () {
modal.close()
}
})
}
})
return [items]
})
......
......@@ -17,6 +17,7 @@
<IActionThread
:collection_id="$selectCollectionId.length ? $selectCollectionId[0] : ''"
:c_id="state.id"
@delete="handleDeletedThread"
/>
<UButton
color="gray"
......@@ -171,4 +172,7 @@ function handleRemoveCollect (data) {
watch(()=> Layout.removeCollectData, (data) => {
if (data.value !== null) handleRemoveCollect(data)
}, { deep: true })
function handleDeletedThread () {
navigateTo('/')
}
</script>
\ No newline at end of file
......@@ -54,12 +54,21 @@ export default () => {
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 }
}
return {
setOrUpdateCollection,
deleteCollection,
saveCollection,
findCollection,
deleteCollectionRecord,
findRecordCollection
findRecordCollection,
deleteThread
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册