import { LevelInfo } from '~/docs' export const state = () => ({ currentLevel: 0, levelInfo: [] as LevelInfo[] }) type RootState = ReturnType export const mutations = { setCurrentLevel(state: RootState, value: number) { state.currentLevel = value }, setLevelInfo(state: RootState, value: LevelInfo[]) { state.levelInfo = value } } export const getters = { getCurrentLevelInfo(state: RootState) { const currentLevel = state.levelInfo[state.currentLevel] if (!currentLevel) // eslint-disable-next-line no-console console.error('current level not exists') return currentLevel } }