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

132

上级 087bcd32
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
</template> </template>
<script setup> <script setup>
const { $openLibrarySelect } = useLibraryStore() const { $openLibrarySelect } = useLibraryStore()
const { deleteCollectionRecord } = useCollectionRequest()
const Layout = inject('Layout')
const props = defineProps({ const props = defineProps({
collection_id: { collection_id: {
type: [String, Number], type: [String, Number],
...@@ -33,7 +35,14 @@ const actionItems = computed(() => { ...@@ -33,7 +35,14 @@ const actionItems = computed(() => {
}, },
{ {
label: '从收藏中移除', label: '从收藏中移除',
icon: 'i-heroicons-x-mark' icon: 'i-heroicons-x-mark',
click: async () => {
await deleteCollectionRecord(props.collection_id, props.c_id)
Layout.handleRemoveCollectData({
collection_id: props.collection_id,
c_id: props.c_id
})
}
} }
] ]
} else { } else {
......
...@@ -81,10 +81,20 @@ function handleUpdateCollect (data) { ...@@ -81,10 +81,20 @@ function handleUpdateCollect (data) {
const { c_id } = data.value const { c_id } = data.value
if (c_id === thread.value.c_id) { if (c_id === thread.value.c_id) {
thread.value.collections = [data.value] thread.value.collections = [data.value]
Layout.clearCollectData() Layout.handleClearCollectData()
}
}
function handleRemoveCollect (data) {
const { c_id } = data.value
if (c_id === thread.value.c_id) {
thread.value.collections = []
Layout.handleClearRemoveCollectData()
} }
} }
watch(()=> Layout.selectCollectData, (data) => { watch(()=> Layout.selectCollectData, (data) => {
if (data.value !== null) handleUpdateCollect(data) if (data.value !== null) handleUpdateCollect(data)
}, { deep: true }) }, { deep: true })
watch(()=> Layout.removeCollectData, (data) => {
if (data.value !== null) handleRemoveCollect(data)
}, { deep: true })
</script> </script>
\ No newline at end of file
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
<script setup> <script setup>
const isOpenAside = ref(false) const isOpenAside = ref(false)
const selectCollectData = ref(null) const selectCollectData = ref(null)
const removeCollectData = ref(null)
function handleToggleAside () { function handleToggleAside () {
isOpenAside.value = !isOpenAside.value isOpenAside.value = !isOpenAside.value
} }
...@@ -44,12 +45,21 @@ function handleCloseAside () { ...@@ -44,12 +45,21 @@ function handleCloseAside () {
function handleCollectSuccess (data) { function handleCollectSuccess (data) {
selectCollectData.value = data selectCollectData.value = data
} }
function clearCollectData () { function handleClearCollectData () {
selectCollectData.value = null selectCollectData.value = null
} }
function handleRemoveCollectData (data) {
removeCollectData.value = data
}
function handleClearRemoveCollectData () {
removeCollectData.value = null
}
provide('Layout', { provide('Layout', {
handleCloseAside, handleCloseAside,
selectCollectData, selectCollectData,
clearCollectData handleClearCollectData,
removeCollectData,
handleRemoveCollectData,
handleClearRemoveCollectData
}) })
</script> </script>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册