fix: change_pct 统一按小数存储并前端乘以100展示

This commit is contained in:
2026-07-04 11:06:41 +08:00
parent 5bf4949999
commit 2d967f21ec
2 changed files with 6 additions and 5 deletions
+3 -3
View File
@@ -133,7 +133,7 @@ export function StockOverview({ role }: StockOverviewProps) {
<KpiCard
icon={<Activity className="h-4 w-4 text-accent" />}
label="平均涨跌"
value={`${avg_change_pct >= 0 ? '+' : ''}${avg_change_pct.toFixed(2)}%`}
value={`${avg_change_pct >= 0 ? '+' : ''}${(avg_change_pct * 100).toFixed(2)}%`}
valueClass={avg_change_pct >= 0 ? 'text-bull' : 'text-bear'}
/>
</div>
@@ -186,7 +186,7 @@ function IndexCard({ item }: { item: StockRow }) {
{item.close.toFixed(2)}
</div>
<div className={cn('text-xs font-medium', positive ? 'text-bull' : 'text-bear')}>
{positive ? '+' : ''}{item.change_pct.toFixed(2)}%
{positive ? '+' : ''}{(item.change_pct * 100).toFixed(2)}%
</div>
</div>
)
@@ -209,7 +209,7 @@ function StockList({
<div className="text-xs text-muted py-2"></div>
) : (
rows.map((item, idx) => {
const val = valueKey === 'amount' ? (item.amount ?? 0) / 1e8 : item.change_pct
const val = valueKey === 'amount' ? (item.amount ?? 0) / 1e8 : item.change_pct * 100
const isPositive = valueKey === 'amount' ? true : item.change_pct >= 0
return (
<div key={item.symbol} className="flex items-center justify-between text-sm py-1">