Sistemato menu laterale... getters, state....
This commit is contained in:
@@ -27,13 +27,16 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script type="ts">
|
<script lang="ts">
|
||||||
import menuOne from './menuOne.vue'
|
import menuOne from './menuOne.vue'
|
||||||
import menuTwo from './menuTwo.vue'
|
import menuTwo from './menuTwo.vue'
|
||||||
|
|
||||||
import { Component, Vue, Watch, Prop } from 'vue-property-decorator'
|
import Vue from 'vue'
|
||||||
import { GlobalStore } from '@store'
|
import { Component, Watch, Prop } from 'vue-property-decorator'
|
||||||
import { UserStore } from '@store';
|
import {Store} from 'vuex'
|
||||||
|
import { UserStore } from '@modules';
|
||||||
|
import { GlobalStore } from '@modules'
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
components: {
|
components: {
|
||||||
@@ -42,6 +45,9 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
export default class Drawer extends Vue {
|
export default class Drawer extends Vue {
|
||||||
|
public $q
|
||||||
|
$t: any
|
||||||
|
|
||||||
photo = ''
|
photo = ''
|
||||||
user = null
|
user = null
|
||||||
links = {
|
links = {
|
||||||
@@ -74,18 +80,19 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
get MenuCollapse () {
|
get MenuCollapse () {
|
||||||
return GlobalStore.getters.menuCollapse
|
return GlobalStore.state.menuCollapse
|
||||||
|
// return true
|
||||||
}
|
}
|
||||||
get Username () {
|
get Username () {
|
||||||
return UserStore.getters.username
|
return UserStore.state.username
|
||||||
}
|
}
|
||||||
|
|
||||||
get Verificato () {
|
get Verificato () {
|
||||||
return UserStore.getters.verifiedEmail
|
return UserStore.state.verifiedEmail
|
||||||
}
|
}
|
||||||
|
|
||||||
logoutHandler() {
|
logoutHandler() {
|
||||||
this.logout({ router: this.$router })
|
UserStore.actions.logout()
|
||||||
this.$q.notify(this.$t('logout.uscito'))
|
this.$q.notify(this.$t('logout.uscito'))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
export interface IGlobState {
|
export interface IGlobalState {
|
||||||
conta: number
|
conta: number
|
||||||
isLoginPage: boolean
|
isLoginPage: boolean
|
||||||
layoutNeeded: boolean
|
layoutNeeded: boolean
|
||||||
|
|||||||
@@ -29,9 +29,8 @@ export default class Home extends Vue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get conta() {
|
get conta() {
|
||||||
return GlobalStore.getters.getConta
|
return GlobalStore.state.conta
|
||||||
}
|
}
|
||||||
|
|
||||||
set conta(valore) {
|
set conta(valore) {
|
||||||
GlobalStore.actions.setConta(valore)
|
GlobalStore.actions.setConta(valore)
|
||||||
let my = this.$q.i18n.lang
|
let my = this.$q.i18n.lang
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { IGlobalState } from '@types'
|
import { IGlobalState } from 'model'
|
||||||
import { storeBuilder } from './Store/Store'
|
import { storeBuilder } from './Store/Store'
|
||||||
|
|
||||||
|
|
||||||
@@ -17,37 +17,7 @@ const stateGetter = b.state()
|
|||||||
// Getters
|
// Getters
|
||||||
namespace Getters {
|
namespace Getters {
|
||||||
|
|
||||||
const getConta = b.read(function getConta(state: IGlobalState): number {
|
|
||||||
return state.conta
|
|
||||||
})
|
|
||||||
|
|
||||||
const getIsLoginPage = b.read(function getIsLoginPage(state: IGlobalState): boolean {
|
|
||||||
return state.isLoginPage
|
|
||||||
})
|
|
||||||
|
|
||||||
const getLayoutNeeded = b.read(function getLayoutNeeded(state: IGlobalState): boolean {
|
|
||||||
return state.layoutNeeded
|
|
||||||
})
|
|
||||||
|
|
||||||
const getMobileMode = b.read(function getMobileMode(state: IGlobalState): boolean {
|
|
||||||
return state.mobileMode
|
|
||||||
})
|
|
||||||
|
|
||||||
const getMenuCollapse = b.read(function getMenuCollapse(state: IGlobalState): boolean {
|
|
||||||
return state.menuCollapse
|
|
||||||
})
|
|
||||||
|
|
||||||
const getPosts = b.read(function getPosts(state: IGlobalState): boolean {
|
|
||||||
return state.posts
|
|
||||||
})
|
|
||||||
|
|
||||||
export const getters = {
|
export const getters = {
|
||||||
get getConta() { return getConta() },
|
|
||||||
get getIsLoginPage() { return getIsLoginPage() },
|
|
||||||
get getLayoutNeeded() { return getLayoutNeeded() },
|
|
||||||
get getMobileMode() { return getMobileMode() },
|
|
||||||
get getMenuCollapse() { return getMenuCollapse() },
|
|
||||||
get getPosts() { return getPosts() }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ const b = storeBuilder.module<IUserState>('UserModule', state)
|
|||||||
const stateGetter = b.state()
|
const stateGetter = b.state()
|
||||||
|
|
||||||
namespace Getters {
|
namespace Getters {
|
||||||
|
|
||||||
const lang = b.read(function lang(state): string {
|
const lang = b.read(function lang(state): string {
|
||||||
if (state.lang !== '') {
|
if (state.lang !== '') {
|
||||||
return state.lang
|
return state.lang
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import Vuex, { Store } from 'vuex'
|
import Vuex, { Store } from 'vuex'
|
||||||
|
|
||||||
import { IGlobState } from 'model'
|
import { IGlobalState } from 'model'
|
||||||
import { Route } from 'vue-router'
|
import { Route } from 'vue-router'
|
||||||
import { getStoreBuilder } from 'vuex-typex'
|
import { getStoreBuilder } from 'vuex-typex'
|
||||||
|
|
||||||
|
|
||||||
export interface RootState {
|
export interface RootState {
|
||||||
GlobalModule: IGlobState
|
GlobalModule: IGlobalState
|
||||||
route: Route
|
route: Route
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
8
src/typings/GlobalState.d.ts
vendored
8
src/typings/GlobalState.d.ts
vendored
@@ -1,8 +0,0 @@
|
|||||||
export interface IGlobalState {
|
|
||||||
conta: number,
|
|
||||||
isLoginPage: boolean,
|
|
||||||
layoutNeeded: boolean,
|
|
||||||
mobileMode: boolean,
|
|
||||||
menuCollapse: boolean,
|
|
||||||
posts: Array
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
// export * from './LoginState';
|
// export * from './LoginState';
|
||||||
|
|
||||||
export * from './GlobalState.d'
|
// export * from './GlobalState.d'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user