diff --git a/forge.config.js b/forge.config.js
index 941f732..44ed1eb 100755
--- a/forge.config.js
+++ b/forge.config.js
@@ -44,6 +44,10 @@ module.exports = {
name: 'main_window',
config: 'vite.renderer.config.mjs',
},
+ {
+ name: 'settings_window',
+ config: 'vite.settings.config.mjs',
+ }
],
},
},
diff --git a/index.html b/index.html
index 6620ae8..422d721 100755
--- a/index.html
+++ b/index.html
@@ -1,7 +1,7 @@
-
+
ED Safari v0.0.1
diff --git a/settings.html b/settings.html
new file mode 100644
index 0000000..44af611
--- /dev/null
+++ b/settings.html
@@ -0,0 +1,11 @@
+
+
+
+
+ Settings
+
+
+ Hello World this is settings!
+
+
+
\ No newline at end of file
diff --git a/src/main.js b/src/main.js
index 62ed0c9..1d48f22 100755
--- a/src/main.js
+++ b/src/main.js
@@ -1,33 +1,51 @@
-const { app, BrowserWindow } = require('electron');
+const { app, BrowserWindow, Menu } = require('electron');
const path = require('path');
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
if (require('electron-squirrel-startup')) {
- app.quit();
+ app.quit();
}
+let settingsWindow;
+
const createWindow = () => {
- // Create the browser window.
- const mainWindow = new BrowserWindow({
- width: 1000,
- height: 800,
- webPreferences: {
- preload: path.join(__dirname, 'preload.js'),
- nodeIntegration: true,
- contextIsolation: false,
- additionalArguments: [`EDS-ENV=${app.isPackaged}`],
- },
- });
-
- // and load the index.html of the app.
- if (MAIN_WINDOW_VITE_DEV_SERVER_URL) {
- mainWindow.loadURL(MAIN_WINDOW_VITE_DEV_SERVER_URL);
- } else {
- mainWindow.loadFile(path.join(__dirname, `../renderer/${MAIN_WINDOW_VITE_NAME}/index.html`));
- }
-
- // Open the DevTools.
- mainWindow.webContents.openDevTools();
+ // Create the browser window.
+ const mainWindow = new BrowserWindow({
+ width: 1000,
+ height: 800,
+ webPreferences: {
+ preload: path.join(__dirname, 'preload.js'),
+ nodeIntegration: true,
+ contextIsolation: false,
+ additionalArguments: [`EDS-ENV=${app.isPackaged}`],
+ },
+ });
+
+ // and load the index.html of the app.
+ if (MAIN_WINDOW_VITE_DEV_SERVER_URL) {
+ mainWindow.loadURL(MAIN_WINDOW_VITE_DEV_SERVER_URL);
+ } else {
+ mainWindow.loadFile(path.join(__dirname, `../renderer/${MAIN_WINDOW_VITE_NAME}/index.html`));
+ }
+
+ // Open the DevTools.
+ if (!app.isPackaged) {
+ mainWindow.webContents.openDevTools();
+ }
+
+ // Create the settings window that we can use later.
+ settingsWindow = new BrowserWindow({
+ width: 800,
+ height: 600,
+ parent: mainWindow,
+ modal: true,
+ show: false,
+ webPreferences: {
+ nodeIntegration: true,
+ contextIsolation: false,
+ additionalArguments: [`EDS-ENV=${app.isPackaged}`],
+ },
+ });
};
// This method will be called when Electron has finished
@@ -39,18 +57,53 @@ app.on('ready', createWindow);
// for applications and their menu bar to stay active until the user quits
// explicitly with Cmd + Q.
app.on('window-all-closed', () => {
- if (process.platform !== 'darwin') {
- app.quit();
- }
+ if (process.platform !== 'darwin') {
+ app.quit();
+ }
});
app.on('activate', () => {
- // On OS X it's common to re-create a window in the app when the
- // dock icon is clicked and there are no other windows open.
- if (BrowserWindow.getAllWindows().length === 0) {
- createWindow();
- }
+ // On OS X it's common to re-create a window in the app when the
+ // dock icon is clicked and there are no other windows open.
+ if (BrowserWindow.getAllWindows().length === 0) {
+ createWindow();
+ }
});
// In this file you can include the rest of your app's specific main process
-// code. You can also put them in separate files and import them here.
\ No newline at end of file
+// code. You can also put them in separate files and import them here.
+
+const openSettings = async () => {
+ if (SETTINGS_WINDOW_VITE_DEV_SERVER_URL) {
+ settingsWindow.loadURL(`${SETTINGS_WINDOW_VITE_DEV_SERVER_URL}/settings.html`);
+ } else {
+ settingsWindow.loadFile(path.join(__dirname, `../renderer/${SETTINGS_WINDOW_VITE_NAME}/settings.html`));
+ }
+
+ settingsWindow.show()
+}
+
+const menuTemplate = [
+ {
+ label: 'File',
+ submenu: [
+ { label: 'Settings', click: async () => { openSettings(); } },
+ { role: 'quit' }
+ ]
+ },
+ {
+ role: 'help',
+ submenu: [
+ {
+ label: 'Github',
+ click: async () => {
+ const { shell } = require('electron');
+ await shell.openExternal('https://github.com/punkfairie/ed-safari');
+ }
+ }
+ ]
+ }
+]
+
+const menu = Menu.buildFromTemplate(menuTemplate)
+Menu.setApplicationMenu(menu)
\ No newline at end of file
diff --git a/src/settings.js b/src/settings.js
new file mode 100644
index 0000000..e68ea35
--- /dev/null
+++ b/src/settings.js
@@ -0,0 +1,4 @@
+import 'bootstrap/dist/css/bootstrap.css'
+import './assets/index.css'
+import './assets/ldom.min'
+
diff --git a/vite.settings.config.mjs b/vite.settings.config.mjs
new file mode 100644
index 0000000..48f56bb
--- /dev/null
+++ b/vite.settings.config.mjs
@@ -0,0 +1,13 @@
+import { resolve } from 'path';
+import { defineConfig } from 'vite';
+
+// https://vitejs.dev/config
+export default defineConfig({
+ build: {
+ rollupOptions: {
+ input: {
+ main: resolve(__dirname, 'settings.html')
+ }
+ }
+ }
+});