-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
68 lines (66 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
63
64
65
66
67
68
/*
* @Author: your name
* @Date: 2019-09-17 13:26:30
* @LastEditTime : 2020-01-16 09:40:50
* @LastEditors : Please set LastEditors
* @Description: In User Settings Edit
* @FilePath: \scratchpad\main.js
*/
const {
app,
BrowserWindow,
ipcMain,
dialog
} = require('electron')
class AppWin extends BrowserWindow {
//构造函数
constructor(config, fileLocation) {
const basicConfig = {
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true
}
}
// const finalConfig = Object.assign(basicConfig, config)
const finalConfig = {
...basicConfig,
...config
}
super(finalConfig)
fileLocation && (this.loadFile(fileLocation))
this.once('ready-to-show', () => {
this.show()
})
}
}
app.on('ready', () => {
const mainWin = new AppWin({
transparent: true
}, 'views/index/index.html')
mainWin.setMenu(null)
// mainWin.webContents.openDevTools()
ipcMain.on('save', (event) => {
const options = {
title: '文件另存为',
filters: [{
name: 'javaScript',
extensions: ['js', 'es6', 'mjs', 'pac']
}]
}
dialog.showSaveDialog(options, function (filename) {
event.sender.send('saved-file', filename)
})
})
// ipcMain.on('save', () => {
// dialog.showSaveDialog({
// title: '文件另存为',
// filters: [{
// name: 'javaScript',
// extensions: ['js', 'es6', 'mjs', 'pac']
// }]
// },(fileName)=>{
// console.log(fileName)
// })
// })
})