first commit

This commit is contained in:
2025-01-09 18:30:49 +08:00
commit ead83056ff
99 changed files with 27286 additions and 0 deletions

View 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>

View 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

File diff suppressed because it is too large Load Diff

View 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"
}
}