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

分享逻辑

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