import { defineStore } from 'pinia'
import { getList } from "@/server";
import type {RootObject, IChildren, IChinaAdd, IChinaTotal, ILocalCityNCOVDataList} from "@/stores/type";

export const useStore = defineStore({
  id: 'list',
  state: () => ({
    list: <RootObject>{},
    item: <IChildren[]>[],
    chinaAdd: <IChinaAdd>{},
    chinaTotal: <IChinaTotal>{},
    cityDetail: <ILocalCityNCOVDataList[]>[]
  }),
  actions: {
    async getList () {
      let { data } = await getList()
      this.list = data.data
      this.chinaAdd = this.list.diseaseh5Shelf.chinaAdd
      this.chinaTotal = this.list.diseaseh5Shelf.chinaTotal
      this.cityDetail = this.list.localCityNCOVDataList.slice(0, 10)
    }
  }
})
