/**
 * 顶级模块
 */
import { storeInfo, StoreInfoStoreType } from './useStoreInfoStore'        // 门店信息模块
import { serveInfo, ServeinfoStoreType } from './useServeInfoStore'

import { InjectionKey } from 'vue'
import { createStore, Store, useStore as baseUserStore } from "vuex";


export interface State {
    storeInfo: StoreInfoStoreType       // 门店信息
    serveInfo: ServeinfoStoreType       // 系统信息
}

export const key: InjectionKey<Store<State>> = Symbol()
export const store: Store<State> = createStore({
    /**
     * 同步修改 state 状态
     */
    mutations: {},

    /**
     * 异步修改 state 调用 mutations 修改
     */
    actions: {},

    /**
     * 逻辑复用计算属性
     */
    getters: {},

    /**
     * 子模块
     */
    modules: {
        storeInfo,          // 门店信息
        serveInfo,          // 系统信息
    }
})


export function useStore() {
    return baseUserStore(key)
}