1. import * as api from "../api/index";
    2. import {Commit} from 'vuex'
    3. interface State{
    4. cateLeft:unknown[],
    5. }
    6. interface CateStore{
    7. namespaced:boolean,
    8. state:State,
    9. actions:{
    10. getCateLeft:({commit}:{commit:Commit}) =>void
    11. },
    12. mutations:{
    13. GET_CATELEFT:(state:State,{payload}:{payload:unknown[]})=>void
    14. }
    15. }
    16. const cateStore:CateStore = {
    17. namespaced: true,
    18. state: {
    19. cateLeft: [],
    20. },
    21. actions: {
    22. async getCateLeft({commit}) {
    23. const res = await api.cateReq();
    24. commit({type:'GET_CATELEFT',payload:res.data.data})
    25. },
    26. },
    27. mutations: {
    28. GET_CATELEFT(state,{payload}){
    29. state.cateLeft=payload;
    30. }
    31. },
    32. };
    33. export default cateStore;