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