changed folder structure and added readme file
This commit is contained in:
1 parent
cbdffb21e3
commit
3bb0935db9
50 files changed
+6600
-3999
No files matched your search
@@ -0,0 +1 @@
|
||||
virtual-store-dir-max-length=70
|
||||
@@ -0,0 +1,112 @@
|
||||
const { spawn } = require('child_process');
|
||||
const { app, BrowserWindow } = require('electron');
|
||||
const path = require('path');
|
||||
const url = require('url');
|
||||
const configService = require('./backend/services/configService');
|
||||
|
||||
let backendExpressProcess;
|
||||
let mainWindow;
|
||||
|
||||
const _configService = configService;
|
||||
|
||||
|
||||
app.on('ready', () => {
|
||||
// ! Start the Express server loop
|
||||
startExpressServer();
|
||||
_configService.createMediaFolders();
|
||||
|
||||
// Start the Electron app
|
||||
createWindow();
|
||||
});
|
||||
|
||||
app.on('before-quit', () => {
|
||||
if (backendExpressProcess) {
|
||||
backendExpressProcess.kill();
|
||||
console.log('Killing backend process.');
|
||||
}
|
||||
});
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
if (process.platform !== 'darwin') {
|
||||
app.quit();
|
||||
}
|
||||
});
|
||||
|
||||
app.on('activate', () => {
|
||||
if (mainWindow === null) {
|
||||
createWindow();
|
||||
}
|
||||
});
|
||||
|
||||
// const { dialog, ipcMain } = require('electron');
|
||||
|
||||
// ipcMain.on('select-dirs', async (event, arg) => {
|
||||
// const result = await dialog.showOpenDialog(mainWindow, {
|
||||
// properties: ['openDirectory']
|
||||
// })
|
||||
// console.log('directories selected', result.filePaths)
|
||||
// })
|
||||
|
||||
function startExpressServer() {
|
||||
let parrentProcess = {
|
||||
"electron_path": app.getPath('userData')
|
||||
}
|
||||
// Start the Express server
|
||||
backendExpressProcess = spawn('node', ['backend/server.js'], { env: { PARENT_PROCESS: JSON.stringify(parrentProcess) } });
|
||||
|
||||
backendExpressProcess.stdout.on('data', (data) => {
|
||||
console.log(`Express stdout: ${data}`);
|
||||
if (data.toString().includes('Server started')) { // Adjust to match backend's startup message
|
||||
mainWindow.webContents.send('backend-ready'); // Send event to frontend
|
||||
}
|
||||
});
|
||||
|
||||
backendExpressProcess.stderr.on('data', (data) => {
|
||||
console.error(`Express stderr: ${data}`);
|
||||
});
|
||||
|
||||
// Restart the server if it crashes
|
||||
backendExpressProcess.on('exit', (code, signal) => {
|
||||
console.log(`Express process exited with code ${code} and signal ${signal}. Restarting...`);
|
||||
startExpressServer();
|
||||
});
|
||||
}
|
||||
|
||||
function createWindow() {
|
||||
mainWindow = new BrowserWindow({
|
||||
width: 1200,
|
||||
height: 720,
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, 'preload.js'),
|
||||
nodeIntegration: true,
|
||||
enableRemoteModule: false,
|
||||
contextIsolation: true,
|
||||
sandbox: true
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
mainWindow.loadURL(
|
||||
url.format({
|
||||
pathname: path.join(__dirname, 'dist', 'showy', 'browser', 'index.html'),
|
||||
protocol: 'file:',
|
||||
slashes: true
|
||||
})
|
||||
);
|
||||
|
||||
mainWindow.on('closed', () => {
|
||||
mainWindow = null;
|
||||
});
|
||||
|
||||
mainWindow.webContents.on('will-navigate', (event, url) => {
|
||||
event.preventDefault();
|
||||
console.log('hiiiiiiiii');
|
||||
mainWindow.loadURL(`file://${path.join(__dirname, 'dist/showy/index.html')}`);
|
||||
});
|
||||
|
||||
mainWindow.webContents.on('did-fail-load', (event, url) => {
|
||||
// event.preventDefault();
|
||||
console.log('yoooo');
|
||||
mainWindow.loadURL(`file://${path.join(__dirname, 'dist/showy/browser/index.html')}`);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"name": "showy_electron",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
"electron": "electron .",
|
||||
"build-front": "ng build --configuration=production --base-href ./",
|
||||
"copy-front": "",
|
||||
"copy-back": "copyfiles backend/**/* dist/showy",
|
||||
"generate-exe": "electron-builder"
|
||||
},
|
||||
"build": {
|
||||
"appId": "xalo.showy",
|
||||
"productName": "Showy",
|
||||
"win": {
|
||||
"target": [
|
||||
{
|
||||
"target": "dir",
|
||||
"arch": [
|
||||
"x64"
|
||||
]
|
||||
}
|
||||
],
|
||||
"icon": "src/assets/images/showy.ico"
|
||||
},
|
||||
"directories": {
|
||||
"output": "dist"
|
||||
}
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"copyfiles": "^2.4.1",
|
||||
"electron": "^34.0.1",
|
||||
"electron-builder": "^25.1.8"
|
||||
}
|
||||
}
|
||||
Generated
+2901
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,10 @@
|
||||
const { contextBridge, ipcRenderer } = require('electron');
|
||||
|
||||
contextBridge.exposeInMainWorld('electron', {
|
||||
ipcRenderer: {
|
||||
send: (channel, data) => ipcRenderer.send(channel, data),
|
||||
on: (channel, listener) => ipcRenderer.on(channel, (event, ...args) => listener(...args)),
|
||||
once: (channel, listener) => ipcRenderer.once(channel, (event, ...args) => listener(...args)),
|
||||
removeAllListeners: (channel) => ipcRenderer.removeAllListeners(channel)
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user