From c42fb12a60523927ab4cdb7fdb703d314357c350 Mon Sep 17 00:00:00 2001 From: Anton Reshetov Date: Fri, 17 Jan 2020 15:34:37 +0300 Subject: [PATCH 1/5] chore(main): update menu --- src/main/lib/main-menu.js | 81 ++++++++++++++++++++++++++++++++++----- 1 file changed, 72 insertions(+), 9 deletions(-) diff --git a/src/main/lib/main-menu.js b/src/main/lib/main-menu.js index dd9226f..5ef8737 100644 --- a/src/main/lib/main-menu.js +++ b/src/main/lib/main-menu.js @@ -1,19 +1,22 @@ -import { app, shell } from 'electron' +import { app, shell, dialog, BrowserWindow } from 'electron' +import os from 'os' const { version, author } = require('../../../package.json') -if (process.platform !== 'win32') { +const isMac = process.platform === 'darwin' +const year = new Date().getFullYear() + +if (isMac) { app.setAboutPanelOptions({ applicationName: 'massCode', applicationVersion: version, version, - copyright: author + copyright: `${author}\n https://masscode.io \n©2019-${year}` }) } -export default mainWindow => { - const massCode = { - label: 'massCode', - submenu: [ +function creatMassCodeMenu (mainWindow) { + if (isMac) { + return [ { label: 'About massCode', selector: 'orderFrontStandardAboutPanel:' @@ -23,7 +26,7 @@ export default mainWindow => { }, { label: 'Preferences', - accelerator: 'Command+,', + accelerator: 'CommandOrControl+,', click () { mainWindow.webContents.send('menu:preferences') } @@ -54,6 +57,31 @@ export default mainWindow => { accelerator: 'CommandOrControl+Q' } ] + } else { + return [ + { + label: 'Preferences', + accelerator: 'CommandOrControl+,', + click () { + mainWindow.webContents.send('menu:preferences') + } + }, + { + type: 'separator' + }, + { + label: 'Quit massCode', + role: 'quit', + accelerator: 'CommandOrControl+Q' + } + ] + } +} + +export default mainWindow => { + const massCode = { + label: 'massCode', + submenu: creatMassCodeMenu(mainWindow) } const file = { @@ -173,10 +201,45 @@ export default mainWindow => { role: 'help', submenu: [ { - label: 'GitHub Repo', + label: 'Website', + click () { + shell.openExternal('https://masscode.io') + } + }, + { + label: 'GitHub', click () { shell.openExternal('https://github.com/antonreshetov/massCode') } + }, + { + label: 'Donate', + click () { + shell.openExternal('https://masscode.io/donate') + } + }, + { + type: 'separator' + }, + { + label: 'About', + click () { + dialog.showMessageBox(BrowserWindow.getFocusedWindow(), { + title: 'massCode', + message: 'massCode', + type: 'info', + detail: ` + Version: ${version} + Electron: ${process.versions.electron} + Chrome: ${process.versions.chrome} + Node.js: ${process.versions.node} + V8: ${process.versions.v8} + OS: ${os.type()} ${os.arch()} ${os.release()} + + ©2019-${year} Anton Reshetov + ` + }) + } } ] } From de2eefc942f715d222572caf2dfe0e387c551223 Mon Sep 17 00:00:00 2001 From: Anton Reshetov Date: Fri, 17 Jan 2020 15:50:47 +0300 Subject: [PATCH 2/5] fix(main): win default path to db --- src/main/store/module/preferences.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/store/module/preferences.js b/src/main/store/module/preferences.js index 4e51ed1..8f8cd16 100644 --- a/src/main/store/module/preferences.js +++ b/src/main/store/module/preferences.js @@ -1,5 +1,9 @@ import Store from 'electron-store' -import { homedir } from 'os' +import { homedir, platform } from 'os' + +const isWin = platform() === 'win32' + +const defaultPath = isWin ? homedir() + '\\massCode' : homedir() + '/massCode' const preferences = new Store({ name: 'preferences', @@ -7,7 +11,7 @@ const preferences = new Store({ schema: { storagePath: { - default: homedir() + '/massCode' + default: defaultPath }, theme: { default: 'dark' From da06c71bb908e0945e9c024d3d6d1f596ff955a6 Mon Sep 17 00:00:00 2001 From: Anton Reshetov Date: Fri, 17 Jan 2020 16:13:03 +0300 Subject: [PATCH 3/5] fix(main): get & set storage path --- src/renderer/datastore.js | 8 ++++---- src/renderer/views/Preferences.vue | 8 ++++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/renderer/datastore.js b/src/renderer/datastore.js index 12426c7..6a23c03 100644 --- a/src/renderer/datastore.js +++ b/src/renderer/datastore.js @@ -7,7 +7,7 @@ import fs from 'fs-extra' class DataStore { constructor () { this._defaultPath = remote.app.getPath('home') + '/massCode' - this._storedPath = electronStore.app.get('storagePath') + this._storedPath = electronStore.preferences.get('storagePath') this._path = this._storedPath || this._defaultPath this.init() @@ -29,20 +29,20 @@ class DataStore { } updatePath () { - this._storedPath = electronStore.app.get('storagePath') + this._storedPath = electronStore.preferences.get('storagePath') this._path = this._storedPath || this._defaultPath this.init() } import (from) { - electronStore.set('storagePath', from) + electronStore.preferences.set('storagePath', from) this.updatePath() } async move (to) { try { await fs.move(this._path, to, { overwrite: true }) - electronStore.app.set('storagePath', to) + electronStore.preferences.set('storagePath', to) this.updatePath() } catch (err) { console.error(err) diff --git a/src/renderer/views/Preferences.vue b/src/renderer/views/Preferences.vue index faf0acd..2f90ac9 100644 --- a/src/renderer/views/Preferences.vue +++ b/src/renderer/views/Preferences.vue @@ -126,8 +126,10 @@ export default { properties: ['openDirectory', 'createDirectory'] }) if (dir) { - db.move(dir[0]) + const path = dir[0] + db.move(path) this.updateData() + this.$store.commit('app/SET_STORAGE_PATH', path) } }, async onOpenStorage () { @@ -135,8 +137,10 @@ export default { properties: ['openDirectory'] }) if (dir) { - db.import(dir[0]) + const path = dir[0] + db.import(path) this.updateData() + this.$store.commit('app/SET_STORAGE_PATH', path) } }, async updateData () { From ef1ef3cd4a2ed640115931b7ab55f38f29c12daa Mon Sep 17 00:00:00 2001 From: Anton Reshetov Date: Fri, 17 Jan 2020 16:54:54 +0300 Subject: [PATCH 4/5] fix(main): restore windows bounds on linux & win --- src/main/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/index.js b/src/main/index.js index 4b57970..ea28167 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -43,7 +43,6 @@ app.on('window-all-closed', () => { if (process.platform !== 'darwin') { app.quit() } - store.app.set('bounds', mainWindow.getBounds()) }) app.on('activate', () => { From 4e3cf88a6f1ca34a3e2ae20814f26396fb9588c8 Mon Sep 17 00:00:00 2001 From: Anton Reshetov Date: Fri, 17 Jan 2020 16:55:38 +0300 Subject: [PATCH 5/5] chore(package): add description --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fdffe55..23882f8 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "masscode", "version": "0.8.0", "author": "Anton Reshetov ", - "description": "Snippets app", + "description": "A free and open source code snippets manager for developers", "license": "AGPL-3.0", "main": "./dist/electron/main.js", "scripts": {