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

132

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