feat: redesign crypto market with synced favorites
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import appConfig from '@/config'
|
||||
import request from '@/utils/request'
|
||||
|
||||
const PROXY_BASE = `${appConfig.baseUrl}${appConfig.urlPrefix}/crypto/proxy`
|
||||
|
||||
@@ -165,6 +166,46 @@ export interface CoinTicker {
|
||||
lowPrice: string
|
||||
}
|
||||
|
||||
export interface CryptoMarketCoin {
|
||||
id: string
|
||||
symbol: string
|
||||
name: string
|
||||
name_zh: string
|
||||
image: string
|
||||
current_price: number
|
||||
market_cap: number
|
||||
market_cap_rank: number
|
||||
total_volume: number
|
||||
price_change_percentage_24h: number
|
||||
}
|
||||
|
||||
export interface CryptoMarketSnapshot {
|
||||
updated_at: number
|
||||
updated_time: string
|
||||
stale: boolean
|
||||
overview: {
|
||||
btc_market_cap_percentage: number
|
||||
total_volume_cny: number
|
||||
}
|
||||
coins: CryptoMarketCoin[]
|
||||
}
|
||||
|
||||
export function getCryptoMarket() {
|
||||
return request.get<CryptoMarketSnapshot>({ url: '/crypto/market' }, { ignoreCancel: true })
|
||||
}
|
||||
|
||||
export function getCryptoFavorites() {
|
||||
return request.get<{ symbols: string[] }>({ url: '/crypto/favorites' }, { isAuth: true, ignoreCancel: true })
|
||||
}
|
||||
|
||||
export function addCryptoFavorite(symbol: string) {
|
||||
return request.post({ url: '/crypto/addFavorite', data: { symbol } }, { isAuth: true })
|
||||
}
|
||||
|
||||
export function cancelCryptoFavorite(symbol: string) {
|
||||
return request.post({ url: '/crypto/cancelFavorite', data: { symbol } }, { isAuth: true })
|
||||
}
|
||||
|
||||
export function formatPrice(price: string | number): string {
|
||||
const p = typeof price === 'string' ? parseFloat(price) : price
|
||||
if (isNaN(p)) return '0.00'
|
||||
|
||||
@@ -518,7 +518,7 @@
|
||||
"iconPath": "static/images/tabbar/crypto.png",
|
||||
"selectedIconPath": "static/images/tabbar/crypto_s.png",
|
||||
"pagePath": "pages/crypto/crypto",
|
||||
"text": "加密行情"
|
||||
"text": "行情"
|
||||
},
|
||||
{
|
||||
"iconPath": "static/images/tabbar/lottery.png",
|
||||
|
||||
+645
-208
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user