From fd900a4ebe5fa3d7806a1eb1db347dca70b9e84b Mon Sep 17 00:00:00 2001 From: el3um4s Date: Sat, 31 Mar 2018 02:32:50 +0200 Subject: [PATCH] adesso le preferenze di sistema vengono salvate --- package-lock.json | 61 ++++++++++++++---------- package.json | 3 +- src/main/index.js | 33 +++++++++---- src/renderer/App.vue | 25 +++++++++- src/renderer/components/InfosView.vue | 1 + src/renderer/components/SettingsView.vue | 11 +++++ src/renderer/store/modules/menu.js | 2 +- 7 files changed, 100 insertions(+), 36 deletions(-) diff --git a/package-lock.json b/package-lock.json index 41f604f..b630766 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "vue-calc", - "version": "0.18.03.26", + "version": "0.18.03.30", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -2702,6 +2702,18 @@ "typedarray": "0.0.6" } }, + "conf": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/conf/-/conf-1.4.0.tgz", + "integrity": "sha512-bzlVWS2THbMetHqXKB8ypsXN4DQ/1qopGwNJi1eYbpwesJcd86FBjFciCQX/YwAhp9bM7NVnPFqZ5LpV7gP0Dg==", + "requires": { + "dot-prop": "4.2.0", + "env-paths": "1.0.0", + "make-dir": "1.2.0", + "pkg-up": "2.0.0", + "write-file-atomic": "2.3.0" + } + }, "configstore": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/configstore/-/configstore-3.1.1.tgz", @@ -3503,7 +3515,6 @@ "version": "4.2.0", "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-4.2.0.tgz", "integrity": "sha512-tUMXrxlExSW6U2EXiiKGSBVdYgtV8qlHL+C10TsW4PURY/ic+eaysnSkwB4kA/mBlCyy/IKDJ+Lc3wbWeaXtuQ==", - "dev": true, "requires": { "is-obj": "1.0.1" } @@ -3853,6 +3864,14 @@ "mime": "2.2.0" } }, + "electron-store": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/electron-store/-/electron-store-1.3.0.tgz", + "integrity": "sha512-r1Pdl5MwpiCxgbsl0qnwv/GABO5+J/JTO16+KyqL+bOITIk9o3cq3Sw69uO9NgPkpfcKeEwxtJFbtbiBlGTiDA==", + "requires": { + "conf": "1.4.0" + } + }, "electron-to-chromium": { "version": "1.3.36", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.36.tgz", @@ -3916,8 +3935,7 @@ "env-paths": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-1.0.0.tgz", - "integrity": "sha1-QWgTO0K7BcOKNbGuQ5fIKYqzaeA=", - "dev": true + "integrity": "sha1-QWgTO0K7BcOKNbGuQ5fIKYqzaeA=" }, "errno": { "version": "0.1.7", @@ -5025,7 +5043,6 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", - "dev": true, "requires": { "locate-path": "2.0.0" } @@ -6306,8 +6323,7 @@ "graceful-fs": { "version": "4.1.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", - "dev": true + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=" }, "graceful-readlink": { "version": "1.0.1", @@ -6860,8 +6876,7 @@ "imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", - "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", - "dev": true + "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=" }, "indent-string": { "version": "2.1.0", @@ -7220,8 +7235,7 @@ "is-obj": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", - "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=", - "dev": true + "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=" }, "is-odd": { "version": "2.0.0", @@ -7675,7 +7689,6 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", - "dev": true, "requires": { "p-locate": "2.0.0", "path-exists": "3.0.0" @@ -8006,7 +8019,6 @@ "version": "1.2.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-1.2.0.tgz", "integrity": "sha512-aNUAa4UMg/UougV25bbrU4ZaaKNjJ/3/xnvg/twpmKROPdKZPZ9wGgI0opdZzO8q/zUFawoUuixuOv33eZ61Iw==", - "dev": true, "requires": { "pify": "3.0.0" } @@ -8806,7 +8818,6 @@ "version": "1.2.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.2.0.tgz", "integrity": "sha512-Y/OtIaXtUPr4/YpMv1pCL5L5ed0rumAaAeBSj12F+bSlMdys7i8oQF/GUJmfpTS/QoaRrS/k6pma29haJpsMng==", - "dev": true, "requires": { "p-try": "1.0.0" } @@ -8815,7 +8826,6 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", - "dev": true, "requires": { "p-limit": "1.2.0" } @@ -8829,8 +8839,7 @@ "p-try": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", - "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", - "dev": true + "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=" }, "package-json": { "version": "4.0.1", @@ -8984,8 +8993,7 @@ "path-exists": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", - "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", - "dev": true + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=" }, "path-is-absolute": { "version": "1.0.1", @@ -9054,8 +9062,7 @@ "pify": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", - "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", - "dev": true + "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=" }, "pinkie": { "version": "2.0.4", @@ -9081,6 +9088,14 @@ "find-up": "2.1.0" } }, + "pkg-up": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/pkg-up/-/pkg-up-2.0.0.tgz", + "integrity": "sha1-yBmscoBZpGHKscOImivjxJoATX8=", + "requires": { + "find-up": "2.1.0" + } + }, "plist": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/plist/-/plist-2.1.0.tgz", @@ -10786,8 +10801,7 @@ "signal-exit": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", - "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", - "dev": true + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=" }, "single-line-log": { "version": "1.1.2", @@ -13105,7 +13119,6 @@ "version": "2.3.0", "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-2.3.0.tgz", "integrity": "sha512-xuPeK4OdjWqtfi59ylvVL0Yn35SF3zgcAcv7rBPFHVaEapaDr4GdGgm3j7ckTwH9wHL7fGmgfAnb0+THrHb8tA==", - "dev": true, "requires": { "graceful-fs": "4.1.11", "imurmurhash": "0.1.4", diff --git a/package.json b/package.json index b1982e1..94c1a76 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vue-calc", - "version": "0.18.03.30", + "version": "0.18.03.31", "author": "el3um4s ", "description": "An electron-vue project", "license": "MIT", @@ -56,6 +56,7 @@ "dependencies": { "axios": "^0.16.1", "decimal.js": "^9.0.1", + "electron-store": "^1.3.0", "mdi": "^2.1.99", "vue": "^2.4.2", "vue-electron": "^1.0.6", diff --git a/src/main/index.js b/src/main/index.js index 07366ac..8be7a88 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -1,8 +1,15 @@ 'use strict' import { app, BrowserWindow } from 'electron' -// import { autoUpdater } from 'electron-updater' -// const path = require('path') + +const Impostazioni = require('electron-store') +const impostazioni = new Impostazioni({ + name: 'impostazioni', + defaults: { + windowBounds: { width: 340, height: 550 }, + settings: { temaDark: 'dark', formatNumber: 'it-IT', decimalPlaces: 5 } + } +}) /** * Set `__static` path to static files in production @@ -17,19 +24,22 @@ const winURL = process.env.NODE_ENV === 'development' ? `http://localhost:9080` : `file://${__dirname}/index.html` +// impostazioni.set({ +// windowBounds: { +// width: 340, +// height: 550 +// } +// }) + function createWindow () { /** * Initial window options */ - // mainWindow = new BrowserWindow({ - // height: 563, - // useContentSize: true, - // width: 1000 - // }) + let { width, height } = impostazioni.get('windowBounds') mainWindow = new BrowserWindow({ - height: 550, - width: 340, + height: height, + width: width, minHeight: 550, // useContentSize: true, minWidth: 340 @@ -40,6 +50,11 @@ function createWindow () { mainWindow.on('closed', () => { mainWindow = null }) + + mainWindow.on('resize', () => { + let { width, height } = mainWindow.getBounds() + impostazioni.set('windowBounds', { width, height }) + }) } app.on('ready', createWindow) diff --git a/src/renderer/App.vue b/src/renderer/App.vue index 6804963..46dd192 100644 --- a/src/renderer/App.vue +++ b/src/renderer/App.vue @@ -11,11 +11,20 @@ diff --git a/src/renderer/components/InfosView.vue b/src/renderer/components/InfosView.vue index ede94bc..caffa7e 100644 --- a/src/renderer/components/InfosView.vue +++ b/src/renderer/components/InfosView.vue @@ -27,6 +27,7 @@ + diff --git a/src/renderer/components/SettingsView.vue b/src/renderer/components/SettingsView.vue index 4226d63..4aa90a3 100644 --- a/src/renderer/components/SettingsView.vue +++ b/src/renderer/components/SettingsView.vue @@ -35,6 +35,14 @@