瀏覽代碼

增加文件拖拽事件

master
unknown 4 年之前
父節點
當前提交
6620011136
共有 2 個檔案被更改,包括 13 行新增3 行删除
  1. 二進制
      src/main/file_word.png
  2. +13
    -3
      src/main/index.js

二進制
src/main/file_word.png 查看文件

Before After
Width: 180  |  Height: 180  |  Size: 3.7 KiB

+ 13
- 3
src/main/index.js 查看文件

@@ -1,8 +1,7 @@
// Modules to control application life and create native browser window
const { app, BrowserWindow, protocol, ipcMain, dialog } = require('electron')
const { app, BrowserWindow, protocol, ipcMain, dialog, nativeImage } = require('electron')
const path = require('path')


const gotTheLock = app.requestSingleInstanceLock();

if (!gotTheLock) {
@@ -76,4 +75,15 @@ ipcMain.handle('project-upload-file', async (event, args) => {
properties: ['openFile'],
});
return res;
});
});
const testIcon = nativeImage.createFromPath(path.resolve(__dirname, 'file_word.png'));

ipcMain.handle('project-file-dnd', (event, filePath) => {
console.log('receive file path: ', filePath)
event.sender.startDrag({
file: filePath, // path.resolve(__dirname, 'file_word.png'),
// icon: nativeImage.createFromNamedImage('NS')
icon: testIcon,
});

})

Loading…
取消
儲存