Skip to content
This repository has been archived by the owner on Jun 18, 2022. It is now read-only.

Commit

Permalink
adesso le preferenze di sistema vengono salvate
Browse files Browse the repository at this point in the history
  • Loading branch information
el3um4s committed Mar 31, 2018
1 parent 52067b1 commit fd900a4
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 36 deletions.
61 changes: 37 additions & 24 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-calc",
"version": "0.18.03.30",
"version": "0.18.03.31",
"author": "el3um4s <[email protected]>",
"description": "An electron-vue project",
"license": "MIT",
Expand Down Expand Up @@ -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",
Expand Down
33 changes: 24 additions & 9 deletions src/main/index.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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)
Expand Down
25 changes: 24 additions & 1 deletion src/renderer/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,20 @@
</template>

<script>
import { mapGetters } from 'vuex'
import { mapGetters, mapMutations } from 'vuex'
import ToolbarENavigation from './components/UIview/ToolbarENavigation.vue'
import Footer from './components/UIview/Footer.vue'
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 }
}
})
export default {
name: 'vue-calc',
components: {
Expand All @@ -26,6 +35,20 @@ export default {
...mapGetters('menu', {
darkTheme: 'darkTheme'
})
},
methods: {
...mapMutations('calculus', {
cambiaFormatoNumero: 'cambiaFormatoNumero',
cambiaNumeroDecimali: 'cambiaNumeroDecimali'
}),
...mapMutations('menu', {
cambiaTema: 'cambiaTema'
})
},
mounted () {
this.cambiaFormatoNumero(impostazioni.get('settings.formatNumber'))
this.cambiaNumeroDecimali(impostazioni.get('settings.decimalPlaces'))
this.cambiaTema(impostazioni.get('settings.temaDark'))
}
}
</script>
Expand Down
1 change: 1 addition & 0 deletions src/renderer/components/InfosView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<li class="itemInElenco openLink" @click.prevent="openLink('https://fonts.google.com/specimen/Roboto')">Google Font Roboto</li>
<li class="itemInElenco openLink" @click.prevent="openLink('https://fonts.google.com/specimen/Mina')">Google Font Mina</li>
<li class="itemInElenco openLink" @click.prevent="openLink('https://github.com/iFgR/vue-shortkey')">vue-shortkey</li>
<li class="itemInElenco openLink" @click.prevent="openLink('https://github.com/sindresorhus/electron-store')">electron-store</li>
</div>
</v-card-text>
</v-card>
Expand Down
11 changes: 11 additions & 0 deletions src/renderer/components/SettingsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@

<script>
import { mapGetters, mapMutations } from 'vuex'
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 }
}
})
export default {
data () {
Expand Down Expand Up @@ -65,12 +73,15 @@ export default {
}),
aggiornaFormatoNumero () {
this.cambiaFormatoNumero(this.linguaSelezionata)
impostazioni.set('settings.formatNumber', this.linguaSelezionata)
},
aggiornaPosizioniDecimali () {
this.cambiaNumeroDecimali(this.posizioniDecimali)
impostazioni.set('settings.decimalPlaces', this.posizioniDecimali)
},
aggiornaTema () {
this.cambiaTema(this.temaSelezionato === 'dark')
impostazioni.set('settings.temaDark', this.temaSelezionato === 'dark')
}
},
mounted () {
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/store/modules/menu.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const state = {
dark: false,
drawer: false,
version: '0.18.03.30',
version: '0.18.03.31',
items: [
// {
// header: 'Formato'
Expand Down

0 comments on commit fd900a4

Please sign in to comment.