generated from sindresorhus/electron-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit 961a8a5
Showing
16 changed files
with
536 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = tab | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.yml] | ||
indent_style = space | ||
indent_size = 2 |
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 @@ | ||
* text=auto eol=lf |
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,20 @@ | ||
name: CI | ||
on: | ||
- push | ||
- pull_request | ||
jobs: | ||
test: | ||
name: Node.js ${{ matrix.node-version }} | ||
runs-on: macos-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
node-version: | ||
- 14 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- run: npm install | ||
- run: npm test |
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,3 @@ | ||
node_modules | ||
yarn.lock | ||
/dist |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,8 @@ | ||
'use strict'; | ||
const Store = require('electron-store'); | ||
|
||
module.exports = new Store({ | ||
defaults: { | ||
favoriteAnimal: '🦄' | ||
} | ||
}); |
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,41 @@ | ||
html, | ||
body { | ||
padding: 0; | ||
margin: 0; | ||
background: transparent; | ||
} | ||
|
||
/* Use OS default fonts */ | ||
body { | ||
font-family: | ||
system-ui, | ||
-apple-system, | ||
'Segoe UI', | ||
Roboto, | ||
Helvetica, | ||
Arial, | ||
sans-serif, | ||
'Apple Color Emoji', | ||
'Segoe UI Emoji'; | ||
text-rendering: optimizeLegibility; | ||
font-feature-settings: 'liga', 'clig', 'kern'; | ||
} | ||
|
||
header { | ||
position: absolute; | ||
width: 500px; | ||
height: 250px; | ||
top: 50%; | ||
left: 50%; | ||
margin-top: -125px; | ||
margin-left: -250px; | ||
text-align: center; | ||
} | ||
|
||
header h1 { | ||
font-size: 60px; | ||
font-weight: 200; | ||
margin: 0; | ||
padding: 0; | ||
opacity: 0.7; | ||
} |
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,18 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Electron boilerplate</title> | ||
<link rel="stylesheet" href="index.css"> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<header> | ||
<h1>Electron boilerplate</h1> | ||
<p></p> | ||
</header> | ||
<section class="main"></section> | ||
<footer></footer> | ||
</div> | ||
</body> | ||
</html> |
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,90 @@ | ||
'use strict'; | ||
const path = require('path'); | ||
const {app, BrowserWindow, Menu} = require('electron'); | ||
/// const {autoUpdater} = require('electron-updater'); | ||
const {is} = require('electron-util'); | ||
const unhandled = require('electron-unhandled'); | ||
const debug = require('electron-debug'); | ||
const contextMenu = require('electron-context-menu'); | ||
const config = require('./config.js'); | ||
const menu = require('./menu.js'); | ||
|
||
unhandled(); | ||
debug(); | ||
contextMenu(); | ||
|
||
// Note: Must match `build.appId` in package.json | ||
app.setAppUserModelId('com.company.AppName'); | ||
|
||
// Uncomment this before publishing your first version. | ||
// It's commented out as it throws an error if there are no published versions. | ||
// if (!is.development) { | ||
// const FOUR_HOURS = 1000 * 60 * 60 * 4; | ||
// setInterval(() => { | ||
// autoUpdater.checkForUpdates(); | ||
// }, FOUR_HOURS); | ||
// | ||
// autoUpdater.checkForUpdates(); | ||
// } | ||
|
||
// Prevent window from being garbage collected | ||
let mainWindow; | ||
|
||
const createMainWindow = async () => { | ||
const win = new BrowserWindow({ | ||
title: app.name, | ||
show: false, | ||
width: 600, | ||
height: 400 | ||
}); | ||
|
||
win.on('ready-to-show', () => { | ||
win.show(); | ||
}); | ||
|
||
win.on('closed', () => { | ||
// Dereference the window | ||
// For multiple windows store them in an array | ||
mainWindow = undefined; | ||
}); | ||
|
||
await win.loadFile(path.join(__dirname, 'index.html')); | ||
|
||
return win; | ||
}; | ||
|
||
// Prevent multiple instances of the app | ||
if (!app.requestSingleInstanceLock()) { | ||
app.quit(); | ||
} | ||
|
||
app.on('second-instance', () => { | ||
if (mainWindow) { | ||
if (mainWindow.isMinimized()) { | ||
mainWindow.restore(); | ||
} | ||
|
||
mainWindow.show(); | ||
} | ||
}); | ||
|
||
app.on('window-all-closed', () => { | ||
if (!is.macos) { | ||
app.quit(); | ||
} | ||
}); | ||
|
||
app.on('activate', async () => { | ||
if (!mainWindow) { | ||
mainWindow = await createMainWindow(); | ||
} | ||
}); | ||
|
||
(async () => { | ||
await app.whenReady(); | ||
Menu.setApplicationMenu(menu); | ||
mainWindow = await createMainWindow(); | ||
|
||
const favoriteAnimal = config.get('favoriteAnimal'); | ||
mainWindow.webContents.executeJavaScript(`document.querySelector('header p').textContent = 'Your favorite animal is ${favoriteAnimal}'`); | ||
})(); |
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,9 @@ | ||
MIT License | ||
|
||
Copyright (c) <%= name %> <<%= email %>> (<%= website %>) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
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,179 @@ | ||
'use strict'; | ||
const path = require('path'); | ||
const {app, Menu, shell} = require('electron'); | ||
const { | ||
is, | ||
appMenu, | ||
aboutMenuItem, | ||
openUrlMenuItem, | ||
openNewGitHubIssue, | ||
debugInfo | ||
} = require('electron-util'); | ||
const config = require('./config.js'); | ||
|
||
const showPreferences = () => { | ||
// Show the app's preferences here | ||
}; | ||
|
||
const helpSubmenu = [ | ||
openUrlMenuItem({ | ||
label: 'Website', | ||
url: 'https://github.com/sindresorhus/electron-boilerplate' | ||
}), | ||
openUrlMenuItem({ | ||
label: 'Source Code', | ||
url: 'https://github.com/sindresorhus/electron-boilerplate' | ||
}), | ||
{ | ||
label: 'Report an Issue…', | ||
click() { | ||
const body = ` | ||
<!-- Please succinctly describe your issue and steps to reproduce it. --> | ||
--- | ||
${debugInfo()}`; | ||
|
||
openNewGitHubIssue({ | ||
user: 'sindresorhus', | ||
repo: 'electron-boilerplate', | ||
body | ||
}); | ||
} | ||
} | ||
]; | ||
|
||
if (!is.macos) { | ||
helpSubmenu.push( | ||
{ | ||
type: 'separator' | ||
}, | ||
aboutMenuItem({ | ||
icon: path.join(__dirname, 'static', 'icon.png'), | ||
text: 'Created by Your Name' | ||
}) | ||
); | ||
} | ||
|
||
const debugSubmenu = [ | ||
{ | ||
label: 'Show Settings', | ||
click() { | ||
config.openInEditor(); | ||
} | ||
}, | ||
{ | ||
label: 'Show App Data', | ||
click() { | ||
shell.openItem(app.getPath('userData')); | ||
} | ||
}, | ||
{ | ||
type: 'separator' | ||
}, | ||
{ | ||
label: 'Delete Settings', | ||
click() { | ||
config.clear(); | ||
app.relaunch(); | ||
app.quit(); | ||
} | ||
}, | ||
{ | ||
label: 'Delete App Data', | ||
click() { | ||
shell.moveItemToTrash(app.getPath('userData')); | ||
app.relaunch(); | ||
app.quit(); | ||
} | ||
} | ||
]; | ||
|
||
const macosTemplate = [ | ||
appMenu([ | ||
{ | ||
label: 'Preferences…', | ||
accelerator: 'Command+,', | ||
click() { | ||
showPreferences(); | ||
} | ||
} | ||
]), | ||
{ | ||
role: 'fileMenu', | ||
submenu: [ | ||
{ | ||
label: 'Custom' | ||
}, | ||
{ | ||
type: 'separator' | ||
}, | ||
{ | ||
role: 'close' | ||
} | ||
] | ||
}, | ||
{ | ||
role: 'editMenu' | ||
}, | ||
{ | ||
role: 'viewMenu' | ||
}, | ||
{ | ||
role: 'windowMenu' | ||
}, | ||
{ | ||
role: 'help', | ||
submenu: helpSubmenu | ||
} | ||
]; | ||
|
||
// Linux and Windows | ||
const otherTemplate = [ | ||
{ | ||
role: 'fileMenu', | ||
submenu: [ | ||
{ | ||
label: 'Custom' | ||
}, | ||
{ | ||
type: 'separator' | ||
}, | ||
{ | ||
label: 'Settings', | ||
accelerator: 'Control+,', | ||
click() { | ||
showPreferences(); | ||
} | ||
}, | ||
{ | ||
type: 'separator' | ||
}, | ||
{ | ||
role: 'quit' | ||
} | ||
] | ||
}, | ||
{ | ||
role: 'editMenu' | ||
}, | ||
{ | ||
role: 'viewMenu' | ||
}, | ||
{ | ||
role: 'help', | ||
submenu: helpSubmenu | ||
} | ||
]; | ||
|
||
const template = is.macos ? macosTemplate : otherTemplate; | ||
|
||
if (is.development) { | ||
template.push({ | ||
label: 'Debug', | ||
submenu: debugSubmenu | ||
}); | ||
} | ||
|
||
module.exports = Menu.buildFromTemplate(template); |
Oops, something went wrong.