diff options
author | 0neGal <mail@0negal.com> | 2021-12-29 23:33:30 +0100 |
---|---|---|
committer | 0neGal <mail@0negal.com> | 2021-12-29 23:33:30 +0100 |
commit | 9d4515fd408c38ad081c010e052b2960f5fe3dfe (patch) | |
tree | ffd6528723e7fb4e5e6f99027683794226f22a2d /src/index.js | |
parent | dcbdadbe3568beca429b0df5caf96156ee43f474 (diff) | |
parent | 74cb566e5ea97f62121fbd7b2cc170b94d36f0bb (diff) | |
download | Viper-9d4515fd408c38ad081c010e052b2960f5fe3dfe.tar.gz Viper-9d4515fd408c38ad081c010e052b2960f5fe3dfe.zip |
Merge branch 'feat/version-indicator' of https://github.com/Alystrasz/viper into feat/icon
Diffstat (limited to 'src/index.js')
-rw-r--r-- | src/index.js | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/src/index.js b/src/index.js index 3d50cee..b41971d 100644 --- a/src/index.js +++ b/src/index.js @@ -1,6 +1,6 @@ const fs = require("fs"); const path = require("path"); -const { app, dialog, ipcMain, BrowserWindow } = require("electron"); +const { app, dialog, ipcMain, BrowserWindow, ipcRenderer } = require("electron"); const Emitter = require("events"); const events = new Emitter(); @@ -9,8 +9,9 @@ const utils = require("./utils"); const cli = require("./cli"); function start() { + let width = 600; win = new BrowserWindow({ - width: 600, + width: width, height: 115, show: false, title: "Viper", @@ -27,17 +28,30 @@ function start() { win.removeMenu(); win.loadFile(__dirname + "/app/index.html"); - win.webContents.once("dom-ready", () => {win.show()}); - ipcMain.on("setpath", (event) => {utils.setpath(win)}) ipcMain.on("exit", (event) => {process.exit(0)}) + ipcMain.on("setpath", (event) => {utils.setpath(win)}) + ipcMain.on("setsize", (event, height) => { + win.setSize(width, height); + if (! win.isVisible()) { + win.show(); + } + }) } ipcMain.on("launch", (event) => {utils.launch()}) +ipcMain.on("setlang", (event, lang) => {utils.setlang(lang)}) ipcMain.on("launchVanilla", (event) => {utils.launch("vanilla")}) ipcMain.on("update", (event) => {utils.update()}) -ipcMain.on("setpathcli", (event) => {utils.setpath()}) +ipcMain.on("setpathcli", (event) => {utils.setpath()}); + +ipcMain.on('getVersionInfo', () => { + win.webContents.send('versionInfo', { + ns: utils.getInstalledVersion(), + vp: 'v' + require('../package.json').version + }); +}); process.chdir(app.getPath("appData")); |