-
Notifications
You must be signed in to change notification settings - Fork 669
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
85 additions
and
11,794 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,6 @@ | |
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
dist | ||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// 引入electron并创建一个Browserwindow | ||
const {app, BrowserWindow} = require('electron') | ||
const path = require('path') | ||
const url = require('url') | ||
|
||
// 保持window对象的全局引用,避免JavaScript对象被垃圾回收时,窗口被自动关闭. | ||
let mainWindow | ||
|
||
function createWindow () { | ||
//创建浏览器窗口,宽高自定义具体大小你开心就好 | ||
mainWindow = new BrowserWindow({width: 800, height: 600}) | ||
|
||
// 加载应用----react 打包 | ||
mainWindow.loadURL(url.format({ | ||
pathname: path.join(__dirname, './build/index.html'), | ||
protocol: 'file:', | ||
slashes: true | ||
})) | ||
// 加载应用----适用于 react 开发时项目 | ||
// mainWindow.loadURL('http://localhost:3000/'); | ||
|
||
// 打开开发者工具,默认不打开 | ||
// mainWindow.webContents.openDevTools() | ||
|
||
// 关闭window时触发下列事件. | ||
mainWindow.on('closed', function () { | ||
mainWindow = null | ||
}) | ||
} | ||
|
||
// 当 Electron 完成初始化并准备创建浏览器窗口时调用此方法 | ||
app.on('ready', createWindow) | ||
|
||
// 所有窗口关闭时退出应用. | ||
app.on('window-all-closed', function () { | ||
// macOS中除非用户按下 `Cmd + Q` 显式退出,否则应用与菜单栏始终处于活动状态. | ||
if (process.platform !== 'darwin') { | ||
app.quit() | ||
} | ||
}) | ||
|
||
app.on('activate', function () { | ||
// macOS中点击Dock图标时没有已打开的其余应用窗口时,则通常在应用中重建一个窗口 | ||
if (mainWindow === null) { | ||
createWindow() | ||
} | ||
}) | ||
|
||
// 你可以在这个脚本中续写或者使用require引入独立的js文件. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.