2
0

feat:多货币以及支付方式配置

This commit is contained in:
zhongzm
2025-04-27 19:19:03 +08:00
parent 59d54185f5
commit 4422a2bab2
8 changed files with 233 additions and 13 deletions

View File

@@ -0,0 +1,39 @@
import { defineStore } from 'pinia'
interface CurrencyOption {
code: string
symbol: string
name: string
}
interface CurrencyState {
currentCurrency: CurrencyOption
}
export const availableCurrencies: CurrencyOption[] = [
{ code: 'USD', symbol: '$', name: '美元' },
{ code: 'CNY', symbol: '¥', name: '人民币' },
{ code: 'EUR', symbol: '€', name: '欧元' },
{ code: 'GBP', symbol: '£', name: '英镑' },
]
export const useCurrencyStore = defineStore('currency', {
state: (): CurrencyState => ({
currentCurrency: availableCurrencies[0]
}),
actions: {
setCurrency(currencyCode: string) {
const currency = availableCurrencies.find(c => c.code === currencyCode)
if (currency) {
this.currentCurrency = currency
}
}
},
getters: {
symbol: (state: CurrencyState): string => state.currentCurrency.symbol,
code: (state: CurrencyState): string => state.currentCurrency.code,
name: (state: CurrencyState): string => state.currentCurrency.name
}
})