Add Electron

This commit is contained in:
2024-10-11 19:26:03 +02:00
parent 707d607eb6
commit 18b92cf28f
5 changed files with 4494 additions and 2 deletions

4
.gitignore vendored
View File

@@ -3,6 +3,7 @@ node_modules
# Output
.output
.vercel
/dist
/.svelte-kit
/build
@@ -19,3 +20,6 @@ Thumbs.db
# Vite
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
# IDE
.idea

31
main.js Normal file
View File

@@ -0,0 +1,31 @@
import { app, BrowserWindow } from 'electron';
import path from 'path';
import { fileURLToPath } from 'url';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
function createWindow() {
const win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
preload: path.join(__dirname, 'preload.js')
}
});
// win.loadURL('http://localhost:5173'); // Standardport für Vite
win.loadFile(path.join(__dirname, 'build', 'index.html'));
}
app.disableHardwareAcceleration();
app.whenReady().then(() => {
createWindow();
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) createWindow();
});
});
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') app.quit();
});

4431
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,21 +1,45 @@
{
"name": "scanner",
"version": "0.0.1",
"main": "main.js",
"private": true,
"scripts": {
"dev": "vite dev --host",
"build": "vite build",
"start": "concurrently \"npm run dev\" \"npm run electron\"",
"electron": "wait-on tcp:5173 && electron .",
"package": "electron-builder",
"preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json --watch",
"lint": "prettier --check . && eslint .",
"format": "prettier --write ."
},
"build": {
"appId": "de.atashfaraz.scanner",
"files": [
"build/**/*",
"main.js",
"preload.js"
],
"mac": {
"target": "dmg"
},
"win": {
"target": "nsis"
},
"linux": {
"target": "AppImage"
}
},
"devDependencies": {
"@sveltejs/adapter-auto": "^3.0.0",
"@sveltejs/kit": "^2.0.0",
"@sveltejs/vite-plugin-svelte": "^3.0.0",
"@types/eslint": "^9.6.0",
"concurrently": "^9.0.1",
"electron": "^32.2.0",
"electron-builder": "^25.1.7",
"eslint": "^9.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.36.0",
@@ -25,7 +49,8 @@
"svelte": "^4.2.7",
"svelte-check": "^4.0.0",
"typescript": "^5.0.0",
"vite": "^5.0.3"
"vite": "^5.0.3",
"wait-on": "^8.0.1"
},
"type": "module"
}

3
preload.js Normal file
View File

@@ -0,0 +1,3 @@
window.addEventListener('DOMContentLoaded', () => {
// Preload-Logik hier
});