Skip to content

Commit

Permalink
electron support for testing builds
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Boughton committed Sep 6, 2021
1 parent 23d29fb commit b7f91f8
Show file tree
Hide file tree
Showing 9 changed files with 539 additions and 16 deletions.
22 changes: 22 additions & 0 deletions build-electron.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

version=$(grep '"version"' package.json | sed -re 's/[^0-9.]+//g')
echo "Building and packaging v$version in 5 seconds"
sleep 5

quasar b -m electron

cd dist/electron

echo "Zipping Win32 build in 3s"
sleep 3
zip -r Stargazer-win-$version.zip 'Stargazer-win32-x64'

echo "Tarring Linux build in 3s"
sleep 3
tar czvf Stargazer-linux-$version.tar.gz 'Stargazer-linux-x64'

echo "Tarring Mac build in 3s"
sleep 3
tar czvf Stargazer-darwin-$version.tar.gz 'Stargazer-darwin-x64'

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stargazer",
"version": "0.0.1",
"version": "0.1.0",
"description": "An app for journaling solo Ironsworn: Starforged campaigns",
"productName": "Stargazer",
"author": "Nick Boughton <[email protected]>",
Expand All @@ -26,6 +26,8 @@
"@types/uuid": "^8.3.1",
"@typescript-eslint/eslint-plugin": "^4.16.1",
"@typescript-eslint/parser": "^4.16.1",
"electron": "^14.0.0",
"electron-packager": "^15.2.0",
"eslint": "^7.14.0",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-vue": "^7.0.0"
Expand Down
2 changes: 1 addition & 1 deletion quasar.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ module.exports = configure(function (ctx) {

packager: {
// https://github.com/electron-userland/electron-packager/blob/master/docs/api.md#options

platform: 'all'
// OS X / Mac App Store
// appBundleId: '',
// appCategoryType: '',
Expand Down
56 changes: 56 additions & 0 deletions src-electron/electron-main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { app, BrowserWindow, nativeTheme } from 'electron'
import path from 'path'

try {
if (process.platform === 'win32' && nativeTheme.shouldUseDarkColors === true) {
require('fs').unlinkSync(require('path').join(app.getPath('userData'), 'DevTools Extensions'))
}
} catch (_) { }

let mainWindow

function createWindow () {
/**
* Initial window options
*/
mainWindow = new BrowserWindow({
width: 1000,
height: 600,
useContentSize: true,
webPreferences: {
contextIsolation: true,
// More info: /quasar-cli/developing-electron-apps/electron-preload-script
preload: path.resolve(__dirname, process.env.QUASAR_ELECTRON_PRELOAD)
}
})

mainWindow.loadURL(process.env.APP_URL)

if (process.env.DEBUGGING) {
// if on DEV or Production with debug enabled
mainWindow.webContents.openDevTools()
} else {
// we're on production; no access to devtools pls
mainWindow.webContents.on('devtools-opened', () => {
mainWindow.webContents.closeDevTools()
})
}

mainWindow.on('closed', () => {
mainWindow = null
})
}

app.on('ready', createWindow)

app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})

app.on('activate', () => {
if (mainWindow === null) {
createWindow()
}
})
17 changes: 17 additions & 0 deletions src-electron/electron-preload.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* This file is used specifically for security reasons.
* Here you can access Nodejs stuff and inject functionality into
* the renderer thread (accessible there through the "window" object)
*
* WARNING!
* If you import anything from node_modules, then make sure that the package is specified
* in package.json > dependencies and NOT in devDependencies
*
* Example (injects window.myAPI.doAThing() into renderer thread):
*
* import { contextBridge } from 'electron'
*
* contextBridge.exposeInMainWorld('myAPI', {
* doAThing: () => {}
* })
*/
Binary file added src-electron/icons/icon.icns
Binary file not shown.
Binary file added src-electron/icons/icon.ico
Binary file not shown.
Binary file added src-electron/icons/linux-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit b7f91f8

Please sign in to comment.