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

Commit fca6a28

Browse files
committed
setup default mutations vuex easy access
1 parent 017758f commit fca6a28

File tree

6 files changed

+47
-40
lines changed

6 files changed

+47
-40
lines changed

Dockerfile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ COPY --from=compiler /var/www /var/www
6060
RUN composer dump-autoload --no-dev --optimize
6161
RUN grep -q "APP_KEY=" .env || echo "APP_KEY=" >> .env
6262
RUN php artisan key:generate \
63-
&& php artisan config:cache \
64-
&& php artisan route:cache \
65-
&& php artisan view:cache
63+
&& php artisan optimize
6664
RUN chown -R www-data:www-data /var/www
6765
RUN rm -rf /var/www/html/ /var/www/deploy/
6866

package-lock.json

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

resources/js/coreui/store/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import Vue from 'vue'
22
import Vuex from 'vuex'
3+
import EasyAccess from 'vuex-easy-access'
4+
35
import state from './state'
46
import mutations from './mutations'
57
import getter from './getters'
68
import actions from './actions'
7-
import EasyAccess from 'vuex-easy-access'
9+
import modules from './modules'
810

911
Vue.use(Vuex)
1012

@@ -13,5 +15,6 @@ export default new Vuex.Store({
1315
mutations,
1416
getter,
1517
actions,
18+
modules,
1619
plugins: [EasyAccess()],
1720
})

resources/js/coreui/store/modules/example.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
1+
import { defaultMutations } from 'vuex-easy-access'
2+
13
const state = { config: {} }
24

3-
const mutations = {
4-
set (state, { key, value }) {
5-
_.set(state, key, value)
6-
},
7-
}
5+
// add generate mutation vuex easy access
6+
// https://mesqueeb.github.io/vuex-easy-access/setup.html#setup
7+
const mutations = { ...defaultMutations(state) }
88

99
const actions = {
1010
getConfig ({ commit }) {
1111
return new Promise((resolve, reject) => {
1212
axios.get('config')
1313
.then((response) => {
14-
commit('set', {
15-
key : 'config',
16-
value: response.data,
17-
})
18-
resolve()
14+
commit('config', response.data)
15+
16+
resolve(response)
1917
})
2018
.catch(reject)
2119
})
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import camelCase from 'lodash/camelCase'
2+
3+
const requireModule = require.context('.', false, /\.js$/)
4+
const modules = {}
5+
6+
// Auto loader vuex modules
7+
requireModule.keys().forEach((fileName) => {
8+
if (fileName === './index.js')
9+
return
10+
11+
const moduleName = camelCase(fileName.replace(/(\.\/|\.js)/g, ''))
12+
13+
modules[moduleName] = {
14+
namespaced: true,
15+
...requireModule(fileName).default,
16+
}
17+
})
18+
19+
export default modules

resources/js/coreui/store/mutations.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@
33
// first argument, followed by additional payload arguments.
44
// mutations must be synchronous and can be recorded by plugins
55
// for debugging purposes.
6-
export default {}
6+
import state from './state'
7+
import { defaultMutations } from 'vuex-easy-access'
8+
9+
export default { ...defaultMutations(state) }

0 commit comments

Comments
 (0)