Skip to content
This repository was archived by the owner on Apr 1, 2021. It is now read-only.

Commit 19332de

Browse files
committed
Merge branch 'feature/vuex' into develop
2 parents a3cf88b + d68e401 commit 19332de

File tree

11 files changed

+91
-2
lines changed

11 files changed

+91
-2
lines changed

.babelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"plugins": ["wildcard"]
3+
}

package-lock.json

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"fix": "eslint --ext .js,.vue resources/assets/js/ ./*.js --fix"
1313
},
1414
"devDependencies": {
15+
"babel-plugin-wildcard": "^5.0.0",
1516
"cross-env": "^5.1",
1617
"eslint": "^4.19.1",
1718
"eslint-config-standard": "^11.0.0",
@@ -36,6 +37,7 @@
3637
"simple-line-icons": "^2.4.1",
3738
"vue": "^2.5.16",
3839
"vue-chartjs": "^3.3.1",
39-
"vue-router": "^3.0.1"
40+
"vue-router": "^3.0.1",
41+
"vuex": "^3.0.1"
4042
}
4143
}

resources/assets/js/coreui/main.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ import Vue from 'vue'
44
import BootstrapVue from 'bootstrap-vue'
55
import App from './App'
66
import router from './router'
7+
import store from './store'
78

89
Vue.use(BootstrapVue)
910

1011
window.Vue = new Vue({
1112
el : '#app',
1213
router,
14+
store,
1315
template : '<App/>',
1416
components: {
1517
App,

resources/assets/js/coreui/router/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ import Register from '@/views/pages/Register'
5555
Vue.use(Router)
5656

5757
export default new Router({
58-
mode : 'hash', // Demo is living in GitHub.io, so required!
58+
mode : 'history', // Demo is living in GitHub.io, so required!
5959
linkActiveClass: 'open active',
6060
scrollBehavior : () => ({ y: 0 }),
6161
routes : [
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// actions are functions that cause side effects and can involve
2+
// asynchronous operations.
3+
export default {
4+
5+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// getters are functions like computed
2+
export default {
3+
4+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import Vue from 'vue'
2+
import Vuex from 'vuex'
3+
import state from './state'
4+
import mutations from './mutations'
5+
import getter from './getters'
6+
import actions from './actions'
7+
8+
Vue.use(Vuex)
9+
10+
export default new Vuex.Store({
11+
state,
12+
mutations,
13+
getter,
14+
actions,
15+
})
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
const state = {
2+
config: {},
3+
}
4+
5+
const mutations = {
6+
set (state, { key, value }) {
7+
_.set(state, key, value)
8+
},
9+
}
10+
11+
const actions = {
12+
getConfig ({ commit }) {
13+
return new Promise((resolve, reject) => {
14+
axios.get('config')
15+
.then((response) => {
16+
commit('set', {
17+
key : 'config',
18+
value: response.data,
19+
})
20+
resolve()
21+
})
22+
.catch(reject)
23+
})
24+
},
25+
}
26+
27+
export default {
28+
state,
29+
mutations,
30+
actions,
31+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// mutations are operations that actually mutates the state.
2+
// each mutation handler gets the entire state tree as the
3+
// first argument, followed by additional payload arguments.
4+
// mutations must be synchronous and can be recorded by plugins
5+
// for debugging purposes.
6+
export default {
7+
8+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// root state object.
2+
// each Vuex instance is just a single state tree.
3+
export default {
4+
version: '1.0.0',
5+
}

0 commit comments

Comments
 (0)