Commit d3f55e2b authored by Domi's avatar Domi

fix: chatdoc drag and drop

parent fcf8d461
...@@ -31,7 +31,7 @@ const siteConfig: SiteConfig = reactive({ ...@@ -31,7 +31,7 @@ const siteConfig: SiteConfig = reactive({
selector: null, selector: null,
}) })
let timer = 0 let count = 0
watchEffect(() => { watchEffect(() => {
const { valid, rect, tx, ty } = position const { valid, rect, tx, ty } = position
...@@ -43,11 +43,19 @@ watchEffect(() => { ...@@ -43,11 +43,19 @@ watchEffect(() => {
} }
}) })
function onDragOver(e: DragEvent) { function onDragEnter() {
if (!siteConfig.selector) return if (!siteConfig.selector) return
count++
docsAddon.visible = true docsAddon.visible = true
clearTimeout(timer) }
timer = window.setTimeout(() => (docsAddon.visible = false), 180)
function onDragLeave() {
if (!siteConfig.selector) return
count--
if (count <= 0) {
count = 0
docsAddon.visible = false
}
} }
async function onDrop(e: DragEvent) { async function onDrop(e: DragEvent) {
...@@ -115,7 +123,8 @@ function adjustPosition() { ...@@ -115,7 +123,8 @@ function adjustPosition() {
onMounted(() => { onMounted(() => {
const doc = div.value?.ownerDocument || document const doc = div.value?.ownerDocument || document
doc.addEventListener("dragover", onDragOver, true) doc.addEventListener("dragenter", onDragEnter, true)
doc.addEventListener("dragleave", onDragLeave, true)
doc.defaultView?.addEventListener("resize", adjustPosition) doc.defaultView?.addEventListener("resize", adjustPosition)
const defaultChatDocSites = config.data.chatDocSites const defaultChatDocSites = config.data.chatDocSites
...@@ -141,7 +150,8 @@ onMounted(() => { ...@@ -141,7 +150,8 @@ onMounted(() => {
onUnmounted(() => { onUnmounted(() => {
const doc = div.value?.ownerDocument || document const doc = div.value?.ownerDocument || document
doc.removeEventListener("dragover", onDragOver, true) doc.removeEventListener("dragenter", onDragEnter, true)
doc.removeEventListener("dragleave", onDragLeave, true)
doc.removeEventListener("resize", adjustPosition) doc.removeEventListener("resize", adjustPosition)
doc.defaultView?.removeEventListener("resize", adjustPosition) doc.defaultView?.removeEventListener("resize", adjustPosition)
}) })
...@@ -212,4 +222,3 @@ onUnmounted(() => { ...@@ -212,4 +222,3 @@ onUnmounted(() => {
</template> </template>
<style scoped></style> <style scoped></style>
@/utils/const
...@@ -643,4 +643,3 @@ input:hover { ...@@ -643,4 +643,3 @@ input:hover {
} }
} }
</style> </style>
@/utils/const@/utils/invoke/service@/utils/invokeb
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment