import { type ComputedRef, ref } from 'vue' import {defineStore} from "pinia"; import {getMe} from "@/api/me"; import type {User} from "@/models/login"; import type {Wallet} from "@/models/wallet"; import {getWallet} from "@/api/wallet"; import type {Const} from "@/models/const"; import {getConstByKey} from "@/api/const"; export const useWalletStore = defineStore('wallet', () => { const walletInfo = ref(undefined) const limitedPrice = ref() const limitedBuyGold = ref() async function getMyWallet() { try { walletInfo.value = await getWallet() return walletInfo.value } catch (e) { console.log(e) } } async function getLimitedPrice(){ try { limitedPrice.value = await getConstByKey('limited_price') return limitedPrice.value }catch (e) { console.log(e) } } async function getLimitedBuyGold(){ try { limitedBuyGold.value = await getConstByKey('first_customer_wallet_value') return limitedBuyGold.value }catch (e) { console.log(e) } } /* const permissions: ComputedRef = computed(() => { const permissions: string[] = get(userInfo.value, 'permission', []) const excludes: string[] = get(userInfo.value, 'exclude', []) return permissions.filter((item) => !excludes.includes(item)) })*/ /* function canAccess(permissionKey: string) { if (isAdmin.value) return true return permissions.value.includes(permissionKey) } */ /* const isAdmin = computed(() => { return userInfo.value?.is_admin })*/ return { walletInfo, getMyWallet, getLimitedPrice, getLimitedBuyGold, limitedPrice, limitedBuyGold/* permissions, canAccess, isAdmin*/ } })