import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useRefreshStore = defineStore(
  'refresh',
  () => {
    const forceRefresh = ref(false)

    const force = () => {
      forceRefresh.value = !forceRefresh.value
    }

    return {
      forceRefresh,
      force,
    }
  },
  {
    persist: {
      storage: {
        setItem(key: string, value: any) {
          return uni.setStorageSync(key, value)
        },
        getItem(key: string) {
          return uni.getStorageSync(key)
        },
      },
    },
  },
)
