import { defineStore } from 'pinia'
import { ref } from 'vue'
interface datatype {
  attr: string
  data: any
}
export const useWordDetailStore = defineStore('wordDetail', () => {
  const detailData = ref<datatype[]>([])
  const keyword = ref('')

  const setDetailData = (data: datatype, keywordValue: string) => {
    detailData.value.push(data)
    console.log('detailData', detailData.value)
    keyword.value = keywordValue
  }

  const clearAllData = () => {
    detailData.value = []
    keyword.value = ''
  }

  const $reset = () => {
    clearAllData()
  }

  return {
    $reset,
    detailData,
    keyword,
    setDetailData,
    clearAllData,
  }
  // persist: true,
})

export const useTodayStatusStore = defineStore('todayStatus', () => {
  const checkStatus = ref(false) // 查看单词变为true，返回关卡列表时会进行刷新
  const checkWordNew = ref(false) // 标生变为true，返回关卡列表时会进行刷新

  return {
    checkStatus,
    checkWordNew,
  }
})

export const useCheckDictStore = defineStore('checkDict', () => {
  const checkDict = ref(false) // 从词典进入为true，决定词典中回退按钮的跳转

  return {
    checkDict,
  }
})
