added windows build and minor tweaks for `win32` platform

master
Michael Ochmann 3 years ago
parent 38cb3e3295
commit 9b8da8be9e
  1. 1
      .gitignore
  2. 2
      contextAPI.js
  3. 18
      package.json
  4. 18
      src/Ation.js
  5. 1
      src/SettingsManager.js
  6. 10
      src/WindowManager.js

1
.gitignore vendored

@ -6,4 +6,5 @@ node_modules
dist
assets/*.png
assets/*.icns
assets/*.ico
!assets/dmg_background.png

@ -26,7 +26,7 @@ contextBridge.exposeInMainWorld("api", {
clearCache : () => webFrame.clearCache(),
appVersion : async () => await ipcRenderer.invoke("Ation::appVersion"),
fonts : async () => await ipcRenderer.invoke("FontManager::fonts"),
resize : size => ipcRenderer.invoke("SettingsManager::resize", size)
resize : size => ipcRenderer.invoke("WindowManager::resize", size)
});
contextBridge.exposeInMainWorld("appSettings", {

@ -8,9 +8,9 @@
"dev": "concurrently \"cd src/ui && cross-env BROWSER=none npm start\" \"wait-on tcp:3000 && electron .\"",
"build": "npm i && npm run build:assets && npm run build:react",
"build:react": "cd src/ui && npm i && npm run build",
"build:assets": "icon-gen -i assets/appIcon.svg -o ./assets --icns && xattr -cr assets/appIcon.svg",
"dist": "npm run clean && npm run build && electron-builder -m",
"clean": "rm -rf node_modules && rm -rf src/public/build/* && rm -rf src/public/node_modules && rm -rf dist && rm -f assets/*.icns"
"build:assets": "icon-gen -i assets/appIcon.svg -o ./assets --icns --ico --ico-name appIcon && xattr -cr assets/appIcon.svg",
"dist": "npm run clean && npm run build && electron-builder -mw",
"clean": "rm -rf node_modules && rm -rf src/public/build/* && rm -rf src/public/node_modules && rm -rf dist && rm -f assets/*.icns rm -f assets/*.ico"
},
"author": "Michael Ochmann <miko@massivedynamic.eu>",
"license": "MIT",
@ -30,10 +30,20 @@
"assets/*.svg",
"package.json"
],
"win": {
"target": "nsis",
"icon": "assets/appIcon.ico"
},
"mac": {
"category": "public.app-category.productivity",
"target": [
"dmg"
{
"target": "dmg",
"arch": [
"x64",
"arm64"
]
}
],
"icon": "assets/app.icns",
"darkModeSupport": true,

@ -20,10 +20,12 @@ class Ation {
mainMenu;
watcher;
currentFile;
fileToOpen;
constructor() {
if (Ation.Instances > 0)
throw new Error("Only one Instance of Ation possible");
this.fileToOpen = null;
this.currentFile = "";
this.watcher = null;
this.windowManager = new WindowManager(this);
@ -31,16 +33,24 @@ class Ation {
this.settingsManager = new SettingsManager(this);
this.mainMenu = new MainMenu(this);
ipcMain.handle("Ation::appVersion", () => AppInfo.version);
ipcMain.on("Ation::closeFile", () => this.closeFile());
app.on("open-file", (_, path) => {
this.fileToOpen = path;
});
ipcMain.handle("Ation::appVersion", () => AppInfo.version);
ipcMain.on("Ation::closeFile", () => this.closeFile());
app.whenReady().then(async () => {
this.settingsManager.change();
// this is a hack for windows, because they do not send the
// `open-file` event, but pass a "cli parameter" as second
// argument
if (!this.fileToOpen) {
if (process.argv.length >= 2)
this.fileToOpen = process.argv[1];
}
if (this.fileToOpen)
this.openFile(this.fileToOpen);
protocol.registerFileProtocol("slideimg", (request, callback) => {
@ -64,7 +74,7 @@ class Ation {
filters : [
{
name : "Markdown files",
extensions : [".md"]
extensions : ["md"]
}
]
});

@ -20,7 +20,6 @@ class SettingsManager {
}
this.data = JSON.parse(fsn.readFileSync(SettingsManager.File, {encoding : "utf-8"}));
ipcMain.handle("SettingsManager::resize", (_, height) => app.windowManager.windows.settings.setSize(800, height, true));
ipcMain.handle("SettingsManager::get", (_, key, defaultValue = null) => this.get(key, defaultValue));
ipcMain.handle("SettingsManager::set", (_, key, value) => this.set(key, value));
ipcMain.handle("SettingsManager::all", () => this.data);

@ -19,12 +19,14 @@ class WindowManager {
ipcMain.on("WindowManager::openFileDialog", () => this.app.openFile());
ipcMain.on("WindowManager::openFile", (_, path) => this.app.openFile(path));
ipcMain.handle("WindowManager::resize", (_, height) => this.windows.settings.setSize(800, height + (process.platform === "win32" ? 50 : 0), true));
}
init() {
this.mainWindow = WindowManager._CreateWindow({
fullscreen : false,
fullscreenable : true
fullscreenable : true,
autoHideMenuBar : process.platform === "win32"
});
this.windows.settings = WindowManager._CreateWindow({
height : 300,
@ -34,6 +36,12 @@ class WindowManager {
show : false
}, this.mainWindow, false);
// on windows and linux we need to hide the main menu in the settings
// window, because it would look odd.
if (["win32", "linux"].includes(process.platform)) {
this.windows.settings.removeMenu();
}
this.windows.settings.on("close", event => {
event.preventDefault();
this.windows.settings.hide();

Loading…
Cancel
Save