import { createStore } from 'vuex' // import { ActionContext } from 'vuex' import type { App } from 'vue' // 定义 RootState 接口(可扩展) interface RootState { count: number } // type StoreActionContext = ActionContext // 创建 store 实例 const store = createStore({ 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