Settings window.
This commit is contained in:
parent
60ceaf5450
commit
bea31a8131
6 changed files with 118 additions and 33 deletions
|
@ -44,6 +44,10 @@ module.exports = {
|
|||
name: 'main_window',
|
||||
config: 'vite.renderer.config.mjs',
|
||||
},
|
||||
{
|
||||
name: 'settings_window',
|
||||
config: 'vite.settings.config.mjs',
|
||||
}
|
||||
],
|
||||
},
|
||||
},
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta charset="UTF-8">
|
||||
<title>ED Safari v0.0.1</title>
|
||||
</head>
|
||||
<body>
|
||||
|
|
11
settings.html
Normal file
11
settings.html
Normal file
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Settings</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Hello World this is settings!</h1>
|
||||
<script type="module" src="/src/settings.js"></script>
|
||||
</body>
|
||||
</html>
|
55
src/main.js
55
src/main.js
|
@ -1,4 +1,4 @@
|
|||
const { app, BrowserWindow } = require('electron');
|
||||
const { app, BrowserWindow, Menu } = require('electron');
|
||||
const path = require('path');
|
||||
|
||||
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
|
||||
|
@ -6,6 +6,8 @@ if (require('electron-squirrel-startup')) {
|
|||
app.quit();
|
||||
}
|
||||
|
||||
let settingsWindow;
|
||||
|
||||
const createWindow = () => {
|
||||
// Create the browser window.
|
||||
const mainWindow = new BrowserWindow({
|
||||
|
@ -27,7 +29,23 @@ const createWindow = () => {
|
|||
}
|
||||
|
||||
// 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
|
||||
|
@ -54,3 +72,38 @@ app.on('activate', () => {
|
|||
|
||||
// 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.
|
||||
|
||||
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)
|
4
src/settings.js
Normal file
4
src/settings.js
Normal file
|
@ -0,0 +1,4 @@
|
|||
import 'bootstrap/dist/css/bootstrap.css'
|
||||
import './assets/index.css'
|
||||
import './assets/ldom.min'
|
||||
|
13
vite.settings.config.mjs
Normal file
13
vite.settings.config.mjs
Normal file
|
@ -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')
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
Loading…
Reference in a new issue