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

delete thread

上级 4193fcde
...@@ -9,9 +9,11 @@ ...@@ -9,9 +9,11 @@
</UDropdown> </UDropdown>
</template> </template>
<script setup> <script setup>
import { IConfirm } from '#components';
const { $openLibrarySelect } = useLibraryStore() const { $openLibrarySelect } = useLibraryStore()
const { deleteCollectionRecord } = useCollectionRequest() const { deleteCollectionRecord, deleteThread } = useCollectionRequest()
const Layout = inject('Layout') const Layout = inject('Layout')
const modal = useModal()
const props = defineProps({ const props = defineProps({
collection_id: { collection_id: {
type: [String, Number], type: [String, Number],
...@@ -22,6 +24,7 @@ const props = defineProps({ ...@@ -22,6 +24,7 @@ const props = defineProps({
default: '' default: ''
} }
}) })
const emit = defineEmits(['delete'])
const actionItems = computed(() => { const actionItems = computed(() => {
let items let items
if (props.collection_id && props.c_id) { if (props.collection_id && props.c_id) {
...@@ -58,7 +61,21 @@ const actionItems = computed(() => { ...@@ -58,7 +61,21 @@ const actionItems = computed(() => {
} }
items.push({ items.push({
label: '删除主题', 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] return [items]
}) })
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
<IActionThread <IActionThread
:collection_id="$selectCollectionId.length ? $selectCollectionId[0] : ''" :collection_id="$selectCollectionId.length ? $selectCollectionId[0] : ''"
:c_id="state.id" :c_id="state.id"
@delete="handleDeletedThread"
/> />
<UButton <UButton
color="gray" color="gray"
...@@ -171,4 +172,7 @@ function handleRemoveCollect (data) { ...@@ -171,4 +172,7 @@ function handleRemoveCollect (data) {
watch(()=> Layout.removeCollectData, (data) => { watch(()=> Layout.removeCollectData, (data) => {
if (data.value !== null) handleRemoveCollect(data) if (data.value !== null) handleRemoveCollect(data)
}, { deep: true }) }, { deep: true })
function handleDeletedThread () {
navigateTo('/')
}
</script> </script>
\ No newline at end of file
...@@ -54,12 +54,21 @@ export default () => { ...@@ -54,12 +54,21 @@ export default () => {
const {data, error} = await useRequest(`/v1/collection/item/check/${c_id}`) const {data, error} = await useRequest(`/v1/collection/item/check/${c_id}`)
return { data, error } return { data, error }
} }
const deleteThread = async (ids) => {
const {data, error} = await useRequest('/v1/chat/completion/remove', {
method: 'post',
body: ids
})
return { data, error }
}
return { return {
setOrUpdateCollection, setOrUpdateCollection,
deleteCollection, deleteCollection,
saveCollection, saveCollection,
findCollection, findCollection,
deleteCollectionRecord, 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.
先完成此消息的编辑!
想要评论请 注册