Initial electron-tests tray app with split amd64/arm64 AppImage CI workflows
This commit is contained in:
commit
0800b06ae3
20
index.html
Normal file
20
index.html
Normal file
@ -0,0 +1,20 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Electron Tray Demo</title>
|
||||
<style>
|
||||
body { font-family: Inter, system-ui, Arial, sans-serif; margin: 24px; }
|
||||
h1 { margin-bottom: 8px; }
|
||||
.card { border: 1px solid #ddd; border-radius: 12px; padding: 16px; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Electron Tray Demo</h1>
|
||||
<div class="card">
|
||||
<p>This is a test desktop window for the Electron tray application.</p>
|
||||
<p>Close window to hide to tray, use tray menu to show it again.</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
70
main.js
Normal file
70
main.js
Normal file
@ -0,0 +1,70 @@
|
||||
const { app, BrowserWindow, Menu, Tray } = require('electron');
|
||||
const path = require('path');
|
||||
|
||||
let tray = null;
|
||||
let mainWindow = null;
|
||||
|
||||
function createWindow() {
|
||||
mainWindow = new BrowserWindow({
|
||||
width: 700,
|
||||
height: 420,
|
||||
title: 'Electron Tray Demo',
|
||||
webPreferences: {
|
||||
contextIsolation: true,
|
||||
nodeIntegration: false,
|
||||
},
|
||||
});
|
||||
mainWindow.loadFile(path.join(__dirname, 'index.html'));
|
||||
mainWindow.on('close', (event) => {
|
||||
if (!app.isQuiting) {
|
||||
event.preventDefault();
|
||||
mainWindow.hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function createTray() {
|
||||
const iconPath = path.join(__dirname, 'assets', 'trayTemplate.png');
|
||||
tray = new Tray(iconPath);
|
||||
tray.setToolTip('Electron Tray Demo');
|
||||
|
||||
const contextMenu = Menu.buildFromTemplate([
|
||||
{
|
||||
label: 'Show Window',
|
||||
click: () => {
|
||||
if (mainWindow) {
|
||||
mainWindow.show();
|
||||
mainWindow.focus();
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Quit',
|
||||
click: () => {
|
||||
app.isQuiting = true;
|
||||
app.quit();
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
tray.setContextMenu(contextMenu);
|
||||
tray.on('double-click', () => {
|
||||
if (mainWindow) {
|
||||
mainWindow.show();
|
||||
mainWindow.focus();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
app.whenReady().then(() => {
|
||||
createWindow();
|
||||
createTray();
|
||||
|
||||
app.on('activate', () => {
|
||||
if (BrowserWindow.getAllWindows().length === 0) createWindow();
|
||||
});
|
||||
});
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
// keep tray app alive on Linux/macOS
|
||||
});
|
||||
39
package.json
Normal file
39
package.json
Normal file
@ -0,0 +1,39 @@
|
||||
{
|
||||
"name": "electron-tray-demo",
|
||||
"version": "1.0.0",
|
||||
"description": "Electron tray demo app",
|
||||
"main": "main.js",
|
||||
"author": "marksaitis",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"start": "electron .",
|
||||
"build:linux:amd64": "electron-builder --linux AppImage --x64 --publish never",
|
||||
"build:linux:arm64": "electron-builder --linux AppImage --arm64 --publish never"
|
||||
},
|
||||
"devDependencies": {
|
||||
"electron": "^30.1.2",
|
||||
"electron-builder": "^24.13.3"
|
||||
},
|
||||
"build": {
|
||||
"appId": "io.swissline.electrontraydemo",
|
||||
"productName": "electron_tray_demo",
|
||||
"files": [
|
||||
"main.js",
|
||||
"index.html",
|
||||
"assets/**/*",
|
||||
"package.json"
|
||||
],
|
||||
"linux": {
|
||||
"target": [
|
||||
{
|
||||
"target": "AppImage",
|
||||
"arch": [
|
||||
"x64",
|
||||
"arm64"
|
||||
]
|
||||
}
|
||||
],
|
||||
"category": "Utility"
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user