| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- import { createStore } from 'vuex'
- // import { ActionContext } from 'vuex'
- import type { App } from 'vue'
- // 定义 RootState 接口(可扩展)
- interface RootState {
- count: number
- }
- // type StoreActionContext = ActionContext<RootState, RootState>
- // 创建 store 实例
- const store = createStore<RootState>({
- state: () => ({
- count: 0,
- horizontalMenuItems:[
- {
- title:'问卷管理',
- route:`/main`,
- childrenRoute:[
- '/main/createQuestionnaire',
- '/main/previewQuestionnaire'
- ]
- },
- {
- title:'评价管理',
- route:`/main/reviewManagement`,
- childrenRoute:[
- '/main/reviewManagementDetail'
- ]
- },
- {
- title:'评价分析',
- route:`/main/reviewAnalysis`,
- childrenRoute:[]
- },
- {
- title:'个人中心',
- route:`/main/personalCenter`,
- childrenRoute:[]
- },
- ]
- }),
- mutations: {
- increment(state: RootState) {
- state.count++
- }
- },
- actions: {
- increment({ commit }) {
- commit('increment')
- },
- },
- getters: {
- count: (state: RootState) => state.count,
- getDemo:(state)=>()=>{
- return state.horizontalMenuItems.map(item=>{
- return item
- })
- },
- }
- })
- // 提供一个方法用于注册到 Vue 应用中
- export function setupStore(app: App) {
- app.use(store)
- }
- export default store
|