update pay ui
This commit is contained in:
@@ -207,9 +207,12 @@ const CompactIndexCard = ({ indexCode, indexName }) => {
|
||||
const raw = chartData.rawData[idx];
|
||||
if (!raw) return '';
|
||||
|
||||
// 安全格式化数字
|
||||
const safeFixed = (val, digits = 2) => (val != null && !isNaN(val)) ? val.toFixed(digits) : '-';
|
||||
|
||||
// 计算涨跌
|
||||
const prevClose = raw.prev_close || (idx > 0 ? chartData.rawData[idx - 1]?.close : raw.open) || raw.open;
|
||||
const changeAmount = raw.close - prevClose;
|
||||
const changeAmount = (raw.close != null && prevClose != null) ? (raw.close - prevClose) : 0;
|
||||
const changePct = prevClose ? ((changeAmount / prevClose) * 100) : 0;
|
||||
const isUp = changeAmount >= 0;
|
||||
const color = isUp ? '#ef5350' : '#26a69a';
|
||||
@@ -218,22 +221,22 @@ const CompactIndexCard = ({ indexCode, indexName }) => {
|
||||
return `
|
||||
<div style="min-width: 180px;">
|
||||
<div style="font-weight: bold; color: #FFD700; margin-bottom: 10px; font-size: 13px; border-bottom: 1px solid rgba(255,215,0,0.2); padding-bottom: 8px;">
|
||||
📅 ${raw.time}
|
||||
📅 ${raw.time || '-'}
|
||||
</div>
|
||||
<div style="display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 12px;">
|
||||
<span style="color: #999;">开盘</span>
|
||||
<span style="text-align: right; font-family: monospace;">${raw.open.toFixed(2)}</span>
|
||||
<span style="text-align: right; font-family: monospace;">${safeFixed(raw.open)}</span>
|
||||
<span style="color: #999;">收盘</span>
|
||||
<span style="text-align: right; font-weight: bold; color: ${color}; font-family: monospace;">${raw.close.toFixed(2)}</span>
|
||||
<span style="text-align: right; font-weight: bold; color: ${color}; font-family: monospace;">${safeFixed(raw.close)}</span>
|
||||
<span style="color: #999;">最高</span>
|
||||
<span style="text-align: right; color: #ef5350; font-family: monospace;">${raw.high.toFixed(2)}</span>
|
||||
<span style="text-align: right; color: #ef5350; font-family: monospace;">${safeFixed(raw.high)}</span>
|
||||
<span style="color: #999;">最低</span>
|
||||
<span style="text-align: right; color: #26a69a; font-family: monospace;">${raw.low.toFixed(2)}</span>
|
||||
<span style="text-align: right; color: #26a69a; font-family: monospace;">${safeFixed(raw.low)}</span>
|
||||
</div>
|
||||
<div style="margin-top: 10px; padding-top: 8px; border-top: 1px solid rgba(255,255,255,0.1); display: flex; justify-content: space-between; align-items: center;">
|
||||
<span style="color: #999; font-size: 11px;">涨跌幅</span>
|
||||
<span style="color: ${color}; font-weight: bold; font-size: 14px; font-family: monospace;">
|
||||
${sign}${changeAmount.toFixed(2)} (${sign}${changePct.toFixed(2)}%)
|
||||
${sign}${safeFixed(changeAmount)} (${sign}${safeFixed(changePct)}%)
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -529,7 +532,7 @@ const FlowingConcepts = () => {
|
||||
color={colors.text}
|
||||
whiteSpace="nowrap"
|
||||
>
|
||||
{concept.change_pct > 0 ? '+' : ''}{concept.change_pct.toFixed(2)}%
|
||||
{concept.change_pct > 0 ? '+' : ''}{concept.change_pct?.toFixed(2) ?? '-'}%
|
||||
</Text>
|
||||
</HStack>
|
||||
</Box>
|
||||
|
||||
Reference in New Issue
Block a user