-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
62 lines (53 loc) · 1.53 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
const { app, BrowserWindow, ipcMain, dialog } = require('electron');
const prompt = require('electron-prompt');
const path = require('path');
const electronReload = require('electron-reload');
electronReload(__dirname);
const createWindow = () => {
const win = new BrowserWindow({
width: 840,
height: 600,
icon:path.join(__dirname,'./public/img/共享文件夹.png'),
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
nodeIntegration: true,
contextIsolation: false,
},
// resizable: false,
})
win.loadFile('./index.html');
// win.loadURL(`file://${path.join(__dirname,"./render/index.html#/login")}`)
}
ipcMain.on('dropped-file', (event, arg) => {
console.log(arg, event);
event.returnValue = `${arg.length}`;
event.sender.startDrag
})
ipcMain.on('main-alert', (event, message) => {
dialog.showMessageBoxSync({message:message})
})
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') app.quit()
})
app.whenReady().then(() => {
ipcMain.handle('diglog:prompt', async () => {
return await prompt({
title: '请输入文件夹名',
label: '文件夹名:',
inputAttrs: {
type: 'text',
required:true,
},
buttonLabels: {
ok: '确定',
cancel:'取消'
},
type: 'input',
alwaysOnTop:true,
},)
})
createWindow()
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) createWindow()
})
})