Skip to content

Commit

Permalink
feat(upload): drag over list to upload (#229)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lanfei authored Jan 10, 2025
1 parent 06a0d80 commit 9d6c10b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/pages/home/folder/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
import { OrderBy } from "~/store"
import { Col, cols, ListItem } from "./ListItem"
import { ItemCheckbox, useSelectWithMouse } from "./helper"
import { bus } from "~/utils"

const ListLayout = () => {
const t = useT()
Expand Down Expand Up @@ -41,11 +42,23 @@ const ListLayout = () => {
},
}
}
const onDragOver = (e: DragEvent) => {
const items = Array.from(e.dataTransfer?.items ?? [])
for (let i = 0; i < items.length; i++) {
const item = items[i]
if (item.kind === "file") {
bus.emit("tool", "upload")
e.preventDefault()
break
}
}
}
const { isMouseSupported, registerSelectContainer, captureContentMenu } =
useSelectWithMouse()
registerSelectContainer()
return (
<VStack
onDragOver={onDragOver}
oncapture:contextmenu={captureContentMenu}
classList={{ "viselect-container": isMouseSupported() }}
class="list"
Expand Down

0 comments on commit 9d6c10b

Please sign in to comment.