50 lines
1.0 KiB
TypeScript
50 lines
1.0 KiB
TypeScript
|
import {
|
||
|
Store as VuexStore,
|
||
|
Module,
|
||
|
CommitOptions,
|
||
|
DispatchOptions,
|
||
|
} from 'vuex'
|
||
|
|
||
|
import { getters, Getters } from './getters'
|
||
|
import { mutations, Mutations, MutationTypes } from './mutations'
|
||
|
import { actions, Actions, ActionTypes } from './actions'
|
||
|
|
||
|
import { RootState } from '~/store/index'
|
||
|
|
||
|
interface State {
|
||
|
main: Map<string, any>
|
||
|
}
|
||
|
|
||
|
const state: State = {
|
||
|
main: new Map(),
|
||
|
}
|
||
|
|
||
|
const data_module: Module<State, RootState> = {
|
||
|
state,
|
||
|
mutations,
|
||
|
actions,
|
||
|
getters,
|
||
|
}
|
||
|
|
||
|
export default data_module
|
||
|
|
||
|
type Store<S = State> = Omit<VuexStore<S>, 'commit' | 'getters' | 'dispatch' > & {
|
||
|
commit<K extends keyof Mutations, P extends Parameters<Mutations[K]>[1]>(
|
||
|
key: K,
|
||
|
payload: P,
|
||
|
options?: CommitOptions
|
||
|
): ReturnType<Mutations[K]>
|
||
|
} & {
|
||
|
getters: {
|
||
|
[K in keyof Getters]: ReturnType<Getters[K]>
|
||
|
}
|
||
|
} & {
|
||
|
dispatch<K extends keyof Actions>(
|
||
|
key: K,
|
||
|
payload: Parameters<Actions[K]>[1],
|
||
|
options?: DispatchOptions
|
||
|
): ReturnType<Actions[K]>
|
||
|
}
|
||
|
|
||
|
export { State, ActionTypes, MutationTypes, Store }
|