From 158284703876df627f0855aa9664b4b2878849e1 Mon Sep 17 00:00:00 2001 From: Aresn Date: Fri, 31 May 2024 15:47:21 +0800 Subject: [PATCH] delte thread --- components/i/library/Thread.vue | 5 +++++ pages/library/[id].vue | 5 +++++ pages/library/index.vue | 6 ++++++ 3 files changed, 16 insertions(+) diff --git a/components/i/library/Thread.vue b/components/i/library/Thread.vue index 3bd3e70..bc55115 100644 --- a/components/i/library/Thread.vue +++ b/components/i/library/Thread.vue @@ -38,6 +38,7 @@ @@ -57,6 +58,7 @@ const props = defineProps({ default: false } }) +const emit = defineEmits(['delete']) const thread = computed(() => { if (!props.isItem) return props.item else { @@ -97,4 +99,7 @@ watch(()=> Layout.selectCollectData, (data) => { watch(()=> Layout.removeCollectData, (data) => { if (data.value !== null) handleRemoveCollect(data) }, { deep: true }) +function handleDeletedThread () { + emit('delete', thread.value.c_id) +} \ No newline at end of file diff --git a/pages/library/[id].vue b/pages/library/[id].vue index 6e9a371..c1dd184 100644 --- a/pages/library/[id].vue +++ b/pages/library/[id].vue @@ -15,6 +15,7 @@ :item="item" :key="item.id" is-item + @delete="handleDeletedThread" /> @@ -43,4 +44,8 @@ async function findCollectionData() { } await findCollectionData() await $getCollection() +function handleDeletedThread (c_id) { + const findIndex = themesTagList.value.findIndex(i => i.c_id === c_id) + if (findIndex >= 0) themesTagList.value.splice(findIndex, 1) +} \ No newline at end of file diff --git a/pages/library/index.vue b/pages/library/index.vue index 6a97bc2..06c8912 100644 --- a/pages/library/index.vue +++ b/pages/library/index.vue @@ -9,6 +9,7 @@ v-for="item in threads" :item="item" :key="item.c_id" + @delete="handleDeletedThread" /> @@ -51,4 +52,9 @@ async function getThreadData() { } await getThreadData() await $getCollection() + +function handleDeletedThread (c_id) { + const findIndex = threads.value.findIndex(i => i.c_id === c_id) + if (findIndex >= 0) threads.value.splice(findIndex, 1) +} -- GitLab