不允许将拖放到电子应用中 [英] Drag'n'Drop into Electron app is not allowed

查看:80
本文介绍了不允许将拖放到电子应用中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试实现拖放功能,以便用户更轻松地上传其图像。在浏览器中,放置区域可以完美工作,但是Electron阻止文件甚至被放置到应用程序中。每次我尝试放置一个文件时,光标都变为下面显示的光标,但没有任何反应。

I am trying to implement Drag'n'Drop functionality for users to easier upload their images. In browser the drop area works perfectly but Electron is preventing files to be even dropped into the app. Every time I try to drop a file cursor changes to the one shown below and nothing happens.

由于普遍的抱怨,我认为Electron可能有默认配置来禁止删除文件,但我找不到任何解决方案。

I thought maybe Electron had configs to disable dropping files by default due to popular complain but I couldn't find any solution.

该图片显示了放置区域,但是

The picture shows the drop area, but the same issue is all across the app.

Main.js:

const { app, BrowserWindow } = require('electron')

let win

function createWindow () {
  win = new BrowserWindow({ width: 1000, height: 600, minWidth: 690, minHeight: 340 })

  win.loadFile('index.html')

  win.webContents.openDevTools()

  win.on('closed', () => {
    win = null
  })
}

app.on('ready', createWindow)

app.on('window-all-closed', () => {
  if (process.platform !== 'darwin') {
    app.quit()
  }
})

app.on('activate', () => {
  if (win === null) {
    createWindow()
  }
})

推荐答案

好。那不好玩。看起来好像真的坏了。但是在我重新启动控制台之后,Windows随后重新安装了项目Electron和NPM,它终于可以工作了。现在问题已解决。

Ok. That wasn't fun. Looks like something actually broke. But after I restarted the console, Windows then reinstalled the project, Electron, and NPM it finally worked. The problem is now solved.

这篇关于不允许将拖放到电子应用中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆