first commit
This commit is contained in:
10
day01-electron-life-cycle/index.html
Normal file
10
day01-electron-life-cycle/index.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Life Cycle</h1>
|
||||
</body>
|
||||
</html>
|
||||
45
day01-electron-life-cycle/main.js
Normal file
45
day01-electron-life-cycle/main.js
Normal file
@@ -0,0 +1,45 @@
|
||||
const { app, BrowserWindow } = require('electron')
|
||||
|
||||
function createWindow() {
|
||||
let mainWin = new BrowserWindow({
|
||||
width: 600,
|
||||
height: 400
|
||||
})
|
||||
|
||||
mainWin.loadFile('index.html')
|
||||
|
||||
mainWin.webContents.on('did-finish-load', () => {
|
||||
console.log('3 - did finish load')
|
||||
})
|
||||
|
||||
mainWin.webContents.on('dom-ready', () => {
|
||||
console.log('2 - dom ready')
|
||||
})
|
||||
|
||||
mainWin.on('close', () => {
|
||||
console.log('8 - win closed') // 多窗口时最后触发
|
||||
mainWin = null // 删除引用,释放空间
|
||||
})
|
||||
}
|
||||
|
||||
app.on('ready', () => {
|
||||
console.log('1 - ready')
|
||||
createWindow()
|
||||
})
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
console.log('4 - window all closed')
|
||||
app.quit()
|
||||
})
|
||||
|
||||
app.on('before-quit', () => {
|
||||
console.log('5 - before quit')
|
||||
})
|
||||
|
||||
app.on('will-quit', () => {
|
||||
console.log('6 - will-quit')
|
||||
})
|
||||
|
||||
app.on('quit', () => {
|
||||
console.log('7 - quit')
|
||||
})
|
||||
1034
day01-electron-life-cycle/package-lock.json
generated
Normal file
1034
day01-electron-life-cycle/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
15
day01-electron-life-cycle/package.json
Normal file
15
day01-electron-life-cycle/package.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "electron-life-cycle",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
"start": "electron ."
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"electron": "^11.2.1"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user