From 7402e35d6600ff5468ccb37d98f150f373aea9f9 Mon Sep 17 00:00:00 2001 From: TaurusXin Date: Sat, 1 Feb 2025 12:11:13 +0800 Subject: [PATCH] feat: file drop --- frontend/src/App.tsx | 12 ++++++++++-- main.go | 4 ++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 58af25e..019069d 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -40,7 +40,7 @@ import { import { Status, Item, SaveTo } from './types' import { SelectFiles, SelectFolder, ProcessFiles } from '../wailsjs/go/main/App' import { main } from '../wailsjs/go/models' -import { EventsOn } from '../wailsjs/runtime/runtime' +import { EventsOn, OnFileDrop } from '../wailsjs/runtime/runtime' const columnsDef: TableColumnDefinition[] = [ createTableColumn({ @@ -135,7 +135,7 @@ export const App = () => { for (const file of files) { setItems(prev => [...prev, { file, status: 'pending' }]) } - setTotalFilesNeedToProcess(files.length) + setTotalFilesNeedToProcess(prev => prev + files.length) }) } @@ -194,6 +194,14 @@ export const App = () => { } }, [finishedCount]) + OnFileDrop((_x, _y, paths) => { + for (const path of paths) { + setItems(prev => [...prev, { file: path, status: 'pending' }]) + } + console.log(paths.length, paths) + setTotalFilesNeedToProcess(prev => prev + paths.length) + }, false) + return (