import { defineStore } from "pinia";
import { VIDEO_LISTS } from "@/api";

const state = () => ({
  list: []
})

export const useVideoStore = defineStore('video', {
  state,
  getters: {
    getVideoList() {
      return this.list
    }
  },
  actions: {
    async setVideoList(isLoading) {
      try {
        const res = await VIDEO_LISTS({ limit: 10, active_id: 0, isLoading });
        const { data: { video_list = [] } } = res;
        this.list = [...this.list, ...video_list];
      } catch (error) { }
    },
    setList(item, index) {
      this.list[index] = item;
    }
  }
})