Primo Committ
This commit is contained in:
23
src/store/index.js
Normal file
23
src/store/index.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
|
||||
import example from './module-example/index'
|
||||
import glob from './modules/glob';
|
||||
|
||||
Vue.use(Vuex);
|
||||
|
||||
const debug = process.env.NODE_ENV !== 'production';
|
||||
|
||||
Vue.filter('time', timestamp => {
|
||||
return new Date(timestamp).toLocaleTimeString()
|
||||
});
|
||||
|
||||
export default new Vuex.Store({
|
||||
modules: {
|
||||
glob,
|
||||
example
|
||||
},
|
||||
|
||||
//strict: debug,
|
||||
//plugins: debug ? [createLogger()] : []
|
||||
});
|
||||
4
src/store/module-example/actions.js
Normal file
4
src/store/module-example/actions.js
Normal file
@@ -0,0 +1,4 @@
|
||||
/*
|
||||
export function someAction (context) {
|
||||
}
|
||||
*/
|
||||
4
src/store/module-example/getters.js
Normal file
4
src/store/module-example/getters.js
Normal file
@@ -0,0 +1,4 @@
|
||||
/*
|
||||
export function someGetter (state) {
|
||||
}
|
||||
*/
|
||||
12
src/store/module-example/index.js
Normal file
12
src/store/module-example/index.js
Normal file
@@ -0,0 +1,12 @@
|
||||
import state from './state'
|
||||
import * as getters from './getters'
|
||||
import * as mutations from './mutations'
|
||||
import * as actions from './actions'
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state,
|
||||
getters,
|
||||
mutations,
|
||||
actions
|
||||
}
|
||||
4
src/store/module-example/mutations.js
Normal file
4
src/store/module-example/mutations.js
Normal file
@@ -0,0 +1,4 @@
|
||||
/*
|
||||
export function someMutation (state) {
|
||||
}
|
||||
*/
|
||||
3
src/store/module-example/state.js
Normal file
3
src/store/module-example/state.js
Normal file
@@ -0,0 +1,3 @@
|
||||
export default {
|
||||
//
|
||||
}
|
||||
80
src/store/modules/glob.js
Normal file
80
src/store/modules/glob.js
Normal file
@@ -0,0 +1,80 @@
|
||||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
|
||||
Vue.use(Vuex);
|
||||
|
||||
import * as types from '../mutation-types'
|
||||
|
||||
|
||||
export const state = {
|
||||
conta: 0,
|
||||
deferredPrompt: null,
|
||||
layoutNeeded: true,
|
||||
isLoginPage: false,
|
||||
mobileMode: false,
|
||||
menuCollapse: true,
|
||||
|
||||
posts: [],
|
||||
};
|
||||
|
||||
export const mutations = {
|
||||
setValue (state) {
|
||||
state.conta = value
|
||||
},
|
||||
setDefprompt (state, value) {
|
||||
state.deferredPrompt = value
|
||||
},
|
||||
setdefprompt (state, value) {
|
||||
state.deferredPrompt = value
|
||||
},
|
||||
setLayoutNeeded (state, value) {
|
||||
state.layoutNeeded = value
|
||||
},
|
||||
setIsLoginPage (state, value) {
|
||||
state.isLoginPage = value
|
||||
},
|
||||
setMobileMode (state, value) {
|
||||
state.mobileMode = value
|
||||
},
|
||||
setMenuCollapse (state, value) {
|
||||
state.menuCollapse = value
|
||||
},
|
||||
setPosts (state, posts) {
|
||||
state.posts = posts
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
export const getters = {
|
||||
getConta () {
|
||||
return state.conta
|
||||
},
|
||||
getDeferredPrompt() {
|
||||
return state.deferredPrompt
|
||||
},
|
||||
getLayoutNeeded () {
|
||||
return state.layoutNeeded
|
||||
},
|
||||
getIsLoginPage () {
|
||||
return state.isLoginPage
|
||||
},
|
||||
getMobileMode () {
|
||||
return state.mobileMode
|
||||
},
|
||||
getMenuCollapse () {
|
||||
return state.menuCollapse
|
||||
},
|
||||
getPosts () {
|
||||
return state.posts
|
||||
},
|
||||
|
||||
//evenOrsOdd: state => state.count % 2 === 0 ? 'even' : 'odd'
|
||||
};
|
||||
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state,
|
||||
getters,
|
||||
mutations,
|
||||
};
|
||||
5
src/store/mutation-types.js
Normal file
5
src/store/mutation-types.js
Normal file
@@ -0,0 +1,5 @@
|
||||
export const SET_VALUE = 'SET_VALUE';
|
||||
export const SET_DEFFERED_PROMPT = 'defprompt';
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user