fix market ranking display fallbacks

This commit is contained in:
clz
2026-07-27 10:31:22 +08:00
parent af0025ce38
commit 5af37bfa51
4 changed files with 35 additions and 6 deletions
@@ -488,7 +488,8 @@ export struct MarketRankingNodeComponent {
.height(30)
.linearGradient({
angle: 90,
colors: [['#00FFFFFF', 0], [$r('app.color.surface_layer1_foreground'), 1]],
colors: [[$r('app.color.transparent_white'), 0],
[$r('app.color.surface_layer1_foreground'), 1]],
})
.hitTestBehavior(HitTestMode.None)
}
@@ -26,18 +26,21 @@ class MarketRankingTableRequestClient extends TableRequestClient {
private requestParams: string;
private fieldIds: number[];
private sortId: number;
private fallbackNames: Map<string, string>;
private listener: MarketRankingCardDataListener;
constructor(
requestParams: string,
fieldIds: number[],
sortId: number,
fallbackNames: Map<string, string>,
listener: MarketRankingCardDataListener,
) {
super(FRAME_ID, PAGE_ID, [], null, undefined);
this.requestParams = requestParams;
this.fieldIds = fieldIds;
this.sortId = sortId;
this.fallbackNames = fallbackNames;
this.listener = listener;
this.setSubscribeIds(fieldIds);
}
@@ -67,7 +70,7 @@ class MarketRankingTableRequestClient extends TableRequestClient {
const item: RankItem = {
code: `${codeValue}`,
market: `${marketValue}`,
name: this.getString(row, TableConstants.DATA_ID_NAME),
name: this.getContractName(row, `${codeValue}`, `${marketValue}`),
};
item.price = this.getNumber(row, TableConstants.DATA_ID_PRICE);
item.price_chg = this.getNumber(row, TableConstants.DATA_ID_ZF);
@@ -90,6 +93,14 @@ class MarketRankingTableRequestClient extends TableRequestClient {
return value === undefined ? '' : `${value}`;
}
private getContractName(row: RowData, code: string, market: string): string {
const hqName: string = this.getString(row, TableConstants.DATA_ID_NAME);
if (hqName !== '' && hqName !== '--') {
return hqName;
}
return this.fallbackNames.get(`${market}_${code}`) ?? '';
}
private getNumber(row: RowData, fieldId: number): number | undefined {
const value = row.originalData.get(fieldId);
if (typeof value === 'number') {
@@ -145,10 +156,15 @@ export class MarketRankingHqRequestClient {
const requestParams: string =
this.buildRequestParams(contracts, primaryIdx, sortId, fieldIds);
const fallbackNames: Map<string, string> = new Map();
contracts.forEach((contract: RecommendFuturesItem): void => {
fallbackNames.set(`${contract.market}_${contract.contract_code}`, contract.contract_name);
});
const requestClient = new MarketRankingTableRequestClient(
requestParams,
fieldIds,
sortId,
fallbackNames,
listener,
);
requestClient.request(0, contracts.length);