fix(selection): 列表仅展示单个 J 值
This commit is contained in:
@@ -90,6 +90,14 @@ export function getSignalJValue(details: SelectionSignal["details"]) {
|
|||||||
return formatSignalDetailValue("j", details.j)
|
return formatSignalDetailValue("j", details.j)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getStockJValue(stock: SelectionStockResult) {
|
||||||
|
const signal = stock.signals.find(
|
||||||
|
({ details }) =>
|
||||||
|
details.j !== null && details.j !== undefined && details.j !== "",
|
||||||
|
)
|
||||||
|
return getSignalJValue(signal?.details ?? {})
|
||||||
|
}
|
||||||
|
|
||||||
function formatSignalDetailValue(
|
function formatSignalDetailValue(
|
||||||
key: string,
|
key: string,
|
||||||
value: number | string | null | undefined,
|
value: number | string | null | undefined,
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { PatternScoreDetails, PatternScoreSummary } from "./pattern-score"
|
|||||||
import {
|
import {
|
||||||
categoryToneClass,
|
categoryToneClass,
|
||||||
getCategoryLabel,
|
getCategoryLabel,
|
||||||
getSignalJValue,
|
getStockJValue,
|
||||||
getStockKey,
|
getStockKey,
|
||||||
} from "./selection-presentation"
|
} from "./selection-presentation"
|
||||||
import { SignalDetails } from "./signal-details"
|
import { SignalDetails } from "./signal-details"
|
||||||
@@ -77,9 +77,7 @@ export function SignalRecordList({
|
|||||||
<span className="text-xs tabular-nums text-muted-foreground">
|
<span className="text-xs tabular-nums text-muted-foreground">
|
||||||
J
|
J
|
||||||
<strong className="font-semibold text-foreground">
|
<strong className="font-semibold text-foreground">
|
||||||
{stock.signals
|
{getStockJValue(stock)}
|
||||||
.map((signal) => getSignalJValue(signal.details))
|
|
||||||
.join(" / ")}
|
|
||||||
</strong>
|
</strong>
|
||||||
</span>
|
</span>
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { PatternScoreSummary } from "./pattern-score"
|
|||||||
import {
|
import {
|
||||||
categoryToneClass,
|
categoryToneClass,
|
||||||
getCategoryLabel,
|
getCategoryLabel,
|
||||||
getSignalJValue,
|
getStockJValue,
|
||||||
getStockKey,
|
getStockKey,
|
||||||
} from "./selection-presentation"
|
} from "./selection-presentation"
|
||||||
|
|
||||||
@@ -81,11 +81,7 @@ export function SignalTable({
|
|||||||
<PatternScoreSummary score={stock.score} />
|
<PatternScoreSummary score={stock.score} />
|
||||||
</td>
|
</td>
|
||||||
<td className="px-3 text-right align-middle font-semibold tabular-nums text-foreground">
|
<td className="px-3 text-right align-middle font-semibold tabular-nums text-foreground">
|
||||||
{stock.signals.map((signal) => (
|
{getStockJValue(stock)}
|
||||||
<span key={signal.category} className="block">
|
|
||||||
{getSignalJValue(signal.details)}
|
|
||||||
</span>
|
|
||||||
))}
|
|
||||||
</td>
|
</td>
|
||||||
<td className="px-3 text-right align-middle font-medium tabular-nums text-foreground">
|
<td className="px-3 text-right align-middle font-medium tabular-nums text-foreground">
|
||||||
¥ {stock.close.toFixed(2)}
|
¥ {stock.close.toFixed(2)}
|
||||||
|
|||||||
@@ -153,11 +153,15 @@ describe("SelectionResultsPage", () => {
|
|||||||
expect(within(table).getByText("原始 B1")).toBeInTheDocument()
|
expect(within(table).getByText("原始 B1")).toBeInTheDocument()
|
||||||
expect(within(table).getByText("回踩白线 B")).toBeInTheDocument()
|
expect(within(table).getByText("回踩白线 B")).toBeInTheDocument()
|
||||||
expect(within(table).getByText("12")).toBeInTheDocument()
|
expect(within(table).getByText("12")).toBeInTheDocument()
|
||||||
expect(within(table).getByText("13")).toBeInTheDocument()
|
expect(within(table).queryByText("13")).not.toBeInTheDocument()
|
||||||
expect(within(table).getByText("平安银行")).toBeInTheDocument()
|
expect(within(table).getByText("平安银行")).toBeInTheDocument()
|
||||||
expect(within(table).getByText("86.40 分")).toBeInTheDocument()
|
expect(within(table).getByText("86.40 分")).toBeInTheDocument()
|
||||||
expect(within(table).getByText("华纳药厂")).toBeInTheDocument()
|
expect(within(table).getByText("华纳药厂")).toBeInTheDocument()
|
||||||
|
|
||||||
|
const mobileRecord = screen.getAllByRole("article")[0]
|
||||||
|
expect(within(mobileRecord).getByText("12")).toBeInTheDocument()
|
||||||
|
expect(within(mobileRecord).queryByText("13")).not.toBeInTheDocument()
|
||||||
|
|
||||||
const detailPanel = screen.getByRole("complementary", {
|
const detailPanel = screen.getByRole("complementary", {
|
||||||
name: "当前股票详情",
|
name: "当前股票详情",
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user