PixelAI-admin/vue-admin-wonderful-next/src/store/index.ts

63 lines
1.7 KiB
TypeScript

import { InjectionKey } from 'vue'
import { createStore, useStore as baseUseStore, Store } from 'vuex'
import themeConfig from '../utils/themeConfig'
export interface RootStateTypes {
themeConfig: {
isDrawer: boolean,
primary: string,
success: string,
info: string,
warning: string,
danger: string,
topBar: string,
menuBar: string,
columnsMenuBar: string,
topBarColor: string,
menuBarColor: string,
columnsMenuBarColor: string,
isTopBarColorGradual: boolean,
isMenuBarColorGradual: boolean,
isMenuBarColorHighlight: boolean,
isCollapse: boolean,
isUniqueOpened: boolean,
isFixedHeader: boolean,
isFixedHeaderChange: boolean,
isCollapse1: boolean,
menuWidth1: number,
isShowLogo: boolean,
isShowLogoChange: boolean,
isBreadcrumb: boolean,
isTagsview: boolean,
isTagsviewIcon: boolean,
isFooter: boolean,
isGrayscale: boolean,
isInvert: boolean,
isWartermark: boolean,
wartermarkText: string,
tagsStyle: string,
animation: string,
layout: string
}
}
export const key: InjectionKey<Store<RootStateTypes>> = Symbol()
export const store = createStore<RootStateTypes>({
state: {
themeConfig
},
mutations: {
getThemeConfig(state: any, data: object) {
state.themeConfig = Object.assign({}, data)
}
},
actions: {
setThemeConfig({ commit }, data: object) {
commit('getThemeConfig', data)
}
}
})
export function useStore() {
return baseUseStore(key)
}