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

分享逻辑

上级 84bd4ad0
...@@ -98,31 +98,26 @@ function handleBlurTitle () { ...@@ -98,31 +98,26 @@ function handleBlurTitle () {
isEditTitle.value = false isEditTitle.value = false
emits('update-query', editTitle.value) emits('update-query', editTitle.value)
} }
function handleShare (isUpdate) { async function handleUpdateOpenState (state) {
const shareType = String(isOpen.value) const { data } = await useRequest(`/v1/chat/${route.params.id}/public/${state}`, { method: 'post' })
return isUpdate && useRequest(`/v1/chat/${route.params.id}/public/${shareType}`, { method: 'post' }) if (data.value) isOpen.value = state
} }
function handleUpdateOpenState (state) { function handleCopyLink () {
const updateOpened = isOpen.value !== state useCopyToClipboard().copy(window.location.href)
isOpen.value = state toast.add({
handleShare(updateOpened) icon: 'i-heroicons-information-circle-20-solid',
timeout: 2000,
title: '链接已复制到剪贴板'
})
} }
function handleSetOpenState() { function handleSetOpenState() {
const isUpdate = !isOpen.value if (!isOpen.value) {
setTimeout(async () => { setTimeout(async () => {
if (!isOpen.value) { await handleUpdateOpenState(true)
await handleShare(isUpdate) handleCopyLink()
} }, 500)
if (!isOpen.value) { } else {
isOpen.value = true handleCopyLink()
} }
useCopyToClipboard().copy(window.location.href)
toast.add({
icon: 'i-heroicons-information-circle-20-solid',
timeout: 2000,
title: '链接已复制到剪贴板'
})
}, 500)
} }
</script> </script>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册