import { ref, computed } from 'vue'
import { defineStore } from 'pinia'
import { http } from '@/plugins/http'
import { retry } from '@/utils/utils'

export const useSystemStore = defineStore('system', () => {
    const riseRate = ref(0)
    const platformCommission = ref(0)
    const saleBatches = ref([])
    const vipEnabled = ref(false)

    const riseRatePercent = computed(() => {
        return riseRate.value * 100
    })

    function getSysConfigs() {
        // retry(() => http.get('/sysConfig/get/max_rise_rate')).then(res => {
        //     riseRate.value = Number(res.value)
        // })
        // retry(() => http.get('/sysConfig/get/platform_commission')).then(res => {
        //     platformCommission.value = Number(res.value)
        // })
        // retry(() => http.post('/saleBatch/all', { size: 10000 }, { body: 'json' })).then(res => {
        //     saleBatches.value = res.content
        // })
        // retry(() => http.get('/sysConfig/get/vip_enabled')).then(res => {
        //     vipEnabled.value = res.value == '1'
        // })
    }

    return { riseRate, riseRatePercent, platformCommission, saleBatches, getSysConfigs, vipEnabled }
})
