mirror of
https://github.com/kiwix/kiwix-js-pwa.git
synced 2025-08-04 03:48:41 -04:00
Style changes for main and preload
This commit is contained in:
parent
9cb7116f9f
commit
6d082826de
33
main.cjs
33
main.cjs
@ -1,11 +1,11 @@
|
|||||||
// Modules to control application life and create native browser window
|
// Modules to control application life and create native browser window
|
||||||
const { app, dialog, ipcMain, BrowserWindow } = require('electron');
|
const { app, dialog, ipcMain, BrowserWindow } = require('electron');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const { autoUpdater } = require("electron-updater");
|
const { autoUpdater } = require('electron-updater');
|
||||||
|
|
||||||
app.commandLine.appendSwitch("enable-experimental-web-platform-features");
|
|
||||||
|
|
||||||
const contextMenu = require('electron-context-menu');
|
const contextMenu = require('electron-context-menu');
|
||||||
|
|
||||||
|
app.commandLine.appendSwitch('enable-experimental-web-platform-features');
|
||||||
|
|
||||||
contextMenu({
|
contextMenu({
|
||||||
labels: {
|
labels: {
|
||||||
cut: 'Cut',
|
cut: 'Cut',
|
||||||
@ -33,20 +33,9 @@ contextMenu({
|
|||||||
inspect: true
|
inspect: true
|
||||||
});
|
});
|
||||||
|
|
||||||
// This is used to set capabilities of the app: protocol in onready event below
|
|
||||||
// protocol.registerSchemesAsPrivileged([{
|
|
||||||
// scheme: 'app',
|
|
||||||
// privileges: {
|
|
||||||
// standard: true,
|
|
||||||
// secure: true,
|
|
||||||
// allowServiceWorkers: true,
|
|
||||||
// supportFetchAPI: true
|
|
||||||
// }
|
|
||||||
// }]);
|
|
||||||
|
|
||||||
let mainWindow;
|
let mainWindow;
|
||||||
|
|
||||||
function createWindow() {
|
function createWindow () {
|
||||||
// Create the browser window.
|
// Create the browser window.
|
||||||
mainWindow = new BrowserWindow({
|
mainWindow = new BrowserWindow({
|
||||||
// titleBarStyle: 'hidden',
|
// titleBarStyle: 'hidden',
|
||||||
@ -56,6 +45,12 @@ function createWindow() {
|
|||||||
minHeight: 480,
|
minHeight: 480,
|
||||||
autoHideMenuBar: true,
|
autoHideMenuBar: true,
|
||||||
icon: path.join(__dirname, 'www/img/icons/kiwix-64.png'),
|
icon: path.join(__dirname, 'www/img/icons/kiwix-64.png'),
|
||||||
|
// titleBarStyle: 'hidden',
|
||||||
|
// titleBarOverlay: {
|
||||||
|
// color: '#000000',
|
||||||
|
// symbolColor: '#ffffff',
|
||||||
|
// height: 16
|
||||||
|
// },
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
preload: path.join(__dirname, 'preload.cjs'),
|
preload: path.join(__dirname, 'preload.cjs'),
|
||||||
nativeWindowOpen: true,
|
nativeWindowOpen: true,
|
||||||
@ -69,7 +64,7 @@ function createWindow() {
|
|||||||
mainWindow.loadFile('www/index.html');
|
mainWindow.loadFile('www/index.html');
|
||||||
}
|
}
|
||||||
|
|
||||||
function registerListeners() {
|
function registerListeners () {
|
||||||
ipcMain.on('file-dialog', function (event) {
|
ipcMain.on('file-dialog', function (event) {
|
||||||
dialog.showOpenDialog(mainWindow, {
|
dialog.showOpenDialog(mainWindow, {
|
||||||
filters: [
|
filters: [
|
||||||
@ -109,7 +104,7 @@ function registerListeners() {
|
|||||||
console.log('Download is paused');
|
console.log('Download is paused');
|
||||||
mainWindow.webContents.send('dl-received', 'paused');
|
mainWindow.webContents.send('dl-received', 'paused');
|
||||||
} else {
|
} else {
|
||||||
let newReceivedBytes = item.getReceivedBytes();
|
const newReceivedBytes = item.getReceivedBytes();
|
||||||
if (newReceivedBytes - receivedBytes < 250000) return;
|
if (newReceivedBytes - receivedBytes < 250000) return;
|
||||||
receivedBytes = newReceivedBytes;
|
receivedBytes = newReceivedBytes;
|
||||||
mainWindow.webContents.send('dl-received', receivedBytes);
|
mainWindow.webContents.send('dl-received', receivedBytes);
|
||||||
@ -153,7 +148,6 @@ app.whenReady().then(() => {
|
|||||||
createWindow();
|
createWindow();
|
||||||
registerListeners();
|
registerListeners();
|
||||||
|
|
||||||
|
|
||||||
var appName = app.getName();
|
var appName = app.getName();
|
||||||
console.log('App name: ' + appName);
|
console.log('App name: ' + appName);
|
||||||
|
|
||||||
@ -177,7 +171,6 @@ app.whenReady().then(() => {
|
|||||||
// dock icon is clicked and there are no other windows open.
|
// dock icon is clicked and there are no other windows open.
|
||||||
if (BrowserWindow.getAllWindows().length === 0) createWindow();
|
if (BrowserWindow.getAllWindows().length === 0) createWindow();
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Quit when all windows are closed.
|
// Quit when all windows are closed.
|
||||||
|
@ -13,14 +13,14 @@ console.log('Window location: ' + window.location.pathname + '\nStore publisher
|
|||||||
const { ipcRenderer, contextBridge } = require('electron');
|
const { ipcRenderer, contextBridge } = require('electron');
|
||||||
const { open, read, close, stat, readdir } = require('fs');
|
const { open, read, close, stat, readdir } = require('fs');
|
||||||
|
|
||||||
console.log("Inserting required Electron functions into DOM...");
|
console.log('Inserting required Electron functions into DOM...');
|
||||||
|
|
||||||
// DEV: FOR ELECTRON ^12 DO IT THIS WAY:
|
// DEV: FOR ELECTRON ^12 DO IT THIS WAY:
|
||||||
contextBridge.exposeInMainWorld('fs', {
|
contextBridge.exposeInMainWorld('fs', {
|
||||||
open: open,
|
open: open,
|
||||||
read: read,
|
read: read,
|
||||||
readdir: readdir,
|
readdir: readdir,
|
||||||
close: close,
|
close: close,
|
||||||
stat: stat
|
stat: stat
|
||||||
});
|
});
|
||||||
// Exposed events and Event callback for electronAPI (you can add events to listen to, so long as main.js sends a message with name of the event)
|
// Exposed events and Event callback for electronAPI (you can add events to listen to, so long as main.js sends a message with name of the event)
|
||||||
@ -50,7 +50,7 @@ contextBridge.exposeInMainWorld('dialog', {
|
|||||||
callback(data);
|
callback(data);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// window.Buffer = Buffer;
|
// window.Buffer = Buffer;
|
||||||
|
|
||||||
@ -59,4 +59,3 @@ contextBridge.exposeInMainWorld('dialog', {
|
|||||||
// win.session.cookies.get({}, (error, cookies) => {
|
// win.session.cookies.get({}, (error, cookies) => {
|
||||||
// console.log(cookies);
|
// console.log(cookies);
|
||||||
// });
|
// });
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user