基于电子的应用程序有一种方法可以让用户将文件夹放在反应组件上并处理掉落事件,以便主过程可以完全访问它并递归扫描文件夹的内容?
到目前为止,我的设置:
<DropZone>
和onDrop
的组件。
下降事件射击,我可以看到
onDragOver
event.dataTransfer.files
)也为文件。
webkitRelativePath
电子版本:35
反射版本:19
windows11const folderDropped = async (event: React.DragEvent) => {
event.preventDefault();
// If a folder or file has been dragged
if (event.dataTransfer.files.length > 0) {
const filePath = event.dataTransfer.files[0].path;
console.log("Drop event:", event.dataTransfer.files);
console.log("Dropped file path:", filePath);
// Call the IPC handler: readDroppedFile
const result = await window.api.readDroppedFile(filePath, browserWindowId);
console.log("readDroppedFile result:", result);
/* Further Process:
After the api call, the object is checked if its a folder and that it contains files
of a specific type (for example, only PNG files). Once confirmed, the main process will scan through all the
files within the folder recursively.
*/
}
};