Fixed electron vue state issue, Added Sidebar state and Added sidebar icon on click and removed redundent Counter state

pull/6/head
Nikan Dalvand 2019-07-21 17:26:42 +04:30
parent dd9ee29615
commit d4ef91614c
5 changed files with 37 additions and 29 deletions

View File

@ -1,3 +1,4 @@
test/unit/coverage/** test/unit/coverage/**
test/unit/*.js test/unit/*.js
test/e2e/*.js test/e2e/*.js
src/main/*.js

View File

@ -1,7 +1,7 @@
'use strict' 'use strict'
import { app, BrowserWindow } from 'electron' import { app, BrowserWindow } from 'electron'
import store from '../renderer/store/index'
/** /**
* Set `__static` path to static files in production * Set `__static` path to static files in production
* https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html * https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html

View File

@ -1,7 +1,7 @@
<template> <template>
<div> <div>
<section class="handle"> <section class="handle">
<div class="icon"> <div @click="toggleMenuStatus" class="icon">
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 384.97 384.97" style="enable-background:new 0 0 384.97 384.97;" xml:space="preserve"> <svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 384.97 384.97" style="enable-background:new 0 0 384.97 384.97;" xml:space="preserve">
<g> <g>
<g id="Menu_1_"> <g id="Menu_1_">
@ -16,7 +16,7 @@
</div> </div>
<Logo :nopadding="true"/> <Logo :nopadding="true"/>
</section> </section>
<section class="sidebar"> <section class="sidebar" :class="{'open': menuStatus === true}">
<Logo class="logo" /> <Logo class="logo" />
<MenuGroup> <MenuGroup>
<template v-slot:title>Menu</template> <template v-slot:title>Menu</template>
@ -105,12 +105,18 @@ import MenuGroup from '../components/MenuGroup'
import MenuItem from '../components/MenuItem' import MenuItem from '../components/MenuItem'
import projectPackage from '~/package.json' import projectPackage from '~/package.json'
import Logo from '../components/Logo' import Logo from '../components/Logo'
import { mapActions, mapGetters } from 'vuex'
export default { export default {
name: 'DockableSidebar', name: 'DockableSidebar',
components: { MenuGroup, MenuItem, Logo }, components: { MenuGroup, MenuItem, Logo },
data: () => { data: () => {
return { version: projectPackage.version } return { version: projectPackage.version }
} },
methods: {
...mapActions(['toggleMenuStatus'])
},
computed: mapGetters(['menuStatus'])
} }
</script> </script>

View File

@ -1,25 +0,0 @@
const state = {
main: 0
}
const mutations = {
DECREMENT_MAIN_COUNTER (state) {
state.main--
},
INCREMENT_MAIN_COUNTER (state) {
state.main++
}
}
const actions = {
someAsyncTask ({ commit }) {
// do something async
commit('INCREMENT_MAIN_COUNTER')
}
}
export default {
state,
mutations,
actions
}

View File

@ -0,0 +1,26 @@
const state = {
menu_open: false
}
const getters = {
menuStatus: (state) => state.menu_open
}
const mutations = {
TOGGLE_MENU (state) {
state.menu_open = !state.menu_open
}
}
const actions = {
toggleMenuStatus ({ commit }) {
commit('TOGGLE_MENU')
}
}
export default {
actions,
state,
mutations,
getters
}