Skip to content

Commit

Permalink
reset src-electron from quasar project
Browse files Browse the repository at this point in the history
  • Loading branch information
jabelone committed Aug 31, 2023
1 parent 12c1780 commit a56101e
Show file tree
Hide file tree
Showing 8 changed files with 510 additions and 470 deletions.
785 changes: 408 additions & 377 deletions src-frontend/package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@
"autoprefixer": "^10.4.2",
"babel-eslint": "^10.0.1",
"devtron": "^1.4.0",
"electron": "^18.3.7",
"electron": "^26.1.0",
"electron-debug": "^3.1.0",
"electron-devtools-installer": "^3.0.0",
"electron-packager": "^15.5.1",
"electron-packager": "^17.1.2",
"eslint": "^8.14.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-prettier": "^8.5.0",
Expand Down
8 changes: 8 additions & 0 deletions src-frontend/src-electron/electron-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/* eslint-disable */

declare namespace NodeJS {
interface ProcessEnv {
QUASAR_ELECTRON_PRELOAD: string;
APP_URL: string;
}
}
1 change: 1 addition & 0 deletions src-frontend/src-electron/electron-flag.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable */
// THIS FEATURE-FLAG FILE IS AUTOGENERATED,
// REMOVAL OR CHANGES WILL CAUSE RELATED TYPES TO STOP WORKING
import 'quasar/dist/types/feature-flag';
Expand Down
62 changes: 62 additions & 0 deletions src-frontend/src-electron/electron-main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { app, BrowserWindow, nativeTheme } from 'electron';
import path from 'path';
import os from 'os';

// needed in case process is undefined under Linux
const platform = process.platform || os.platform();

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

let mainWindow: BrowserWindow | undefined;

function createWindow() {
/**
* Initial window options
*/
mainWindow = new BrowserWindow({
icon: path.resolve(__dirname, 'icons/icon.png'), // tray icon
fullscreen: process.env.NODE_ENV !== 'Development',
useContentSize: true,
webPreferences: {
contextIsolation: true,
// More info: https://v2.quasar.dev/quasar-cli-vite/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 = undefined;
});
}

app.whenReady().then(createWindow);

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

app.on('activate', () => {
if (mainWindow === undefined) {
createWindow();
}
});
29 changes: 29 additions & 0 deletions src-frontend/src-electron/electron-preload.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* 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: () => {}
* })
*
* WARNING!
* If accessing Node functionality (like importing @electron/remote) then in your
* electron-main.ts you will need to set the following when you instantiate BrowserWindow:
*
* mainWindow = new BrowserWindow({
* // ...
* webPreferences: {
* // ...
* sandbox: false // <-- to be able to import @electron/remote in preload script
* }
* }
*/
27 changes: 0 additions & 27 deletions src-frontend/src-electron/main-process/electron-main.dev.js

This file was deleted.

64 changes: 0 additions & 64 deletions src-frontend/src-electron/main-process/electron-main.js

This file was deleted.

0 comments on commit a56101e

Please sign in to comment.