feat: 更新 @riwa/api-types 依赖版本至 0.0.139;重构交易页面以优化数据展示和格式化逻辑
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
<script lang='ts' setup>
|
||||
import type { TradableData } from "@/api/types";
|
||||
import dayjs from "dayjs";
|
||||
import { client, safeClient } from "@/api";
|
||||
|
||||
const props = defineProps<{
|
||||
data: TradableData | null;
|
||||
@@ -7,31 +9,21 @@ const props = defineProps<{
|
||||
|
||||
const { t } = useI18n();
|
||||
const tradingViewInst = useTemplateRef<HTMLDivElement>("tradingViewInst");
|
||||
const { data: tickerData } = safeClient(client.api.market_data.pairs.ticker.get({
|
||||
query: { symbol: props.data?.asset?.tradingPairsAsBase[0].symbol || "" },
|
||||
}));
|
||||
|
||||
useTradingView(tradingViewInst, {
|
||||
type: "Area",
|
||||
data: computed(() => [
|
||||
{
|
||||
time: "2024-01-01",
|
||||
value: 1000,
|
||||
},
|
||||
{
|
||||
time: "2024-02-01",
|
||||
value: 1200,
|
||||
},
|
||||
{
|
||||
time: "2024-03-01",
|
||||
value: 900,
|
||||
},
|
||||
{
|
||||
time: "2024-04-01",
|
||||
value: 1400,
|
||||
},
|
||||
{
|
||||
time: "2024-05-01",
|
||||
value: 1300,
|
||||
},
|
||||
]),
|
||||
data: async () => {
|
||||
const { data } = safeClient(client.api.market_cap.history.get({
|
||||
query: { symbol: props.data?.asset?.tradingPairsAsBase[0].symbol || "" },
|
||||
}));
|
||||
return data.value?.map(item => ({
|
||||
time: dayjs(item.ts).format("YYYY-MM-DD"),
|
||||
value: item.marketCapUsd,
|
||||
})) || [];
|
||||
},
|
||||
weightChartOptions: {
|
||||
height: 150,
|
||||
rightPriceScale: {
|
||||
@@ -74,7 +66,7 @@ useTradingView(tradingViewInst, {
|
||||
总供应量
|
||||
</div>
|
||||
<div class="value">
|
||||
{{ data?.totalSupply }}
|
||||
{{ Number(data?.totalSupply).toString() }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="item">
|
||||
@@ -82,7 +74,7 @@ useTradingView(tradingViewInst, {
|
||||
市值
|
||||
</div>
|
||||
<div class="value">
|
||||
${{ data?.product?.estimatedValue }}
|
||||
${{ Number(data?.product?.estimatedValue).toString() }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="item">
|
||||
@@ -119,7 +111,7 @@ useTradingView(tradingViewInst, {
|
||||
24小时
|
||||
</div>
|
||||
<div class="value">
|
||||
+1.66%
|
||||
{{ tickerData?.changePercent || '-' }}%
|
||||
</div>
|
||||
</div>
|
||||
<div class="item">
|
||||
@@ -127,7 +119,7 @@ useTradingView(tradingViewInst, {
|
||||
7天
|
||||
</div>
|
||||
<div class="value">
|
||||
-5.98%
|
||||
-%
|
||||
</div>
|
||||
</div>
|
||||
<div class="item">
|
||||
@@ -135,19 +127,10 @@ useTradingView(tradingViewInst, {
|
||||
30天
|
||||
</div>
|
||||
<div class="value">
|
||||
-10.24%
|
||||
-%
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-5">
|
||||
<div class="font-semibold">
|
||||
资产状态
|
||||
</div>
|
||||
<div class="text-xs mt-2">
|
||||
{{ data?.status }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user