import { ref, computed } from 'vue'
import { defineStore } from 'pinia'
import { AxiosWrapper } from '@/util/axios-wrapper'

import type { IQueryResult } from '@/util/types.util'
const axios = new AxiosWrapper()
const api = {
  url: `/zkzx/v2/api/token`
}
export const TokenStore = defineStore('token', () => {
  const count = ref(0)
  const doubleCount = computed(() => count.value * 2)
  function increment() {
    count.value++
  }

  const tokenInfo = async (): Promise<IQueryResult> => {
    const res = await axios.$get(`${api.url}/tokenView`)
    return res
  }
  return {
    count,
    doubleCount,
    increment,
    tokenInfo
  }
})
