const state = {
    courses: []
}

const mutations = {
    setCourses(state, courses) {
        state.courses = courses
    }
}

const actions = {
    fetchCourses({ commit }) {
        // 模拟API调用
        const courses = [
            { id: 1, name: 'Course 1' },
            { id: 2, name: 'Course 2' }
        ]
        commit('setCourses', courses)
    }
}

const getters = {
    allCourses: state => state.courses
}

export default {
    namespaced: true,
    state,
    mutations,
    actions,
    getters
}
