Skip to content

Commit

Permalink
feat(store): register store module automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
lbwa committed Mar 7, 2020
1 parent 4e47524 commit 62fcd71
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,36 @@ import Vue from 'vue'
import Vuex from 'vuex'
import createLogger from 'vuex/dist/logger'
import modules from './modules'
import { createAbilityPlugin } from '../plugins/ability'
import router from '@/router'

Vue.use(Vuex)

const __DEV__ = process.env.NODE_ENV === 'development'

export type RootState = {}

const abilityPlugin = createAbilityPlugin(
'user/setUserAbilities',
router,
'/forbidden',
[
{
path: '/user',
component: () =>
import(/* webpackChunkName: 'private' */ '../views/User/index.vue'),
meta: {
ability: 'github.repo.read'
}
}
]
)

export default new Vuex.Store<RootState>({
state: {},
mutations: {},
actions: {},
modules,
strict: __DEV__,
plugins: __DEV__ ? [createLogger()] : []
plugins: __DEV__ ? [createLogger(), abilityPlugin] : [abilityPlugin]
})

0 comments on commit 62fcd71

Please sign in to comment.