feat: 挑战详情支持挑战人数展示
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -4,7 +4,7 @@ import { ViewManager } from 'db://assets/scripts/core/ViewManager';
|
||||
import { CreatedShareItem, ShareDetailData, ShareParticipantRankSummary } from 'db://assets/scripts/types/ApiTypes';
|
||||
import { ShareManager } from 'db://assets/scripts/utils/ShareManager';
|
||||
import { ToastManager } from 'db://assets/scripts/utils/ToastManager';
|
||||
const { ccclass } = _decorator;
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
interface PagePKDetailParams {
|
||||
share?: CreatedShareItem | null;
|
||||
@@ -18,6 +18,9 @@ export class PagePKDetail extends BaseView {
|
||||
private static readonly RANK_ITEM_BOTTOM_PADDING = 16;
|
||||
private static readonly RANK_ITEM_SPACING = 16;
|
||||
|
||||
@property({ type: Label, tooltip: '参与人数文案,例如:66 人参与' })
|
||||
participateLabel: Label | null = null;
|
||||
|
||||
private _backButton: Node | null = null;
|
||||
private _titleLabel: Label | null = null;
|
||||
private _championPanel: Node | null = null;
|
||||
@@ -54,6 +57,7 @@ export class PagePKDetail extends BaseView {
|
||||
this._titleLabel = this._titleLabel
|
||||
?? this.node.getChildByName('Title')?.getChildByName('Label')?.getComponent(Label)
|
||||
?? null;
|
||||
this.participateLabel = this.participateLabel ?? this._findLabelIn(this.node, 'ParticipateLabel');
|
||||
this._championPanel = this._championPanel ?? this.node.getChildByName('ChampionPanel');
|
||||
|
||||
const rankList = this.node.getChildByName('RankList');
|
||||
@@ -72,6 +76,9 @@ export class PagePKDetail extends BaseView {
|
||||
if (!this._rankListItemTemplate) {
|
||||
console.warn('[PagePKDetail] 未找到 RankListItem 模板节点');
|
||||
}
|
||||
if (!this.participateLabel) {
|
||||
console.warn('[PagePKDetail] 未找到 ParticipateLabel 节点');
|
||||
}
|
||||
}
|
||||
|
||||
private _bindEvents(): void {
|
||||
@@ -138,6 +145,7 @@ export class PagePKDetail extends BaseView {
|
||||
private _renderShareSummary(share: CreatedShareItem | null, version: number): void {
|
||||
this._clearRankItems();
|
||||
this._setLabel(this._titleLabel, share?.title || '挑战详情');
|
||||
this._renderParticipateCount(share);
|
||||
this._renderChampion(share ? this._getFirstParticipant(share) : null, share, version);
|
||||
this._layoutRankContent(0);
|
||||
this._scrollRankListToTop();
|
||||
@@ -151,10 +159,16 @@ export class PagePKDetail extends BaseView {
|
||||
const restRankings = rankings.filter((participant) => participant !== champion);
|
||||
|
||||
this._setLabel(this._titleLabel, detail.title || '挑战详情');
|
||||
this._renderParticipateCount(detail);
|
||||
this._renderChampion(champion, detail, version);
|
||||
this._renderRankList(restRankings, version);
|
||||
}
|
||||
|
||||
private _renderParticipateCount(shareInfo: CreatedShareItem | ShareDetailData | null): void {
|
||||
const participantCount = Math.max(0, shareInfo?.participantCount ?? 0);
|
||||
this._setLabel(this.participateLabel, `${participantCount} 人参与`);
|
||||
}
|
||||
|
||||
private _normalizeRankings(rankings: ShareParticipantRankSummary[]): ShareParticipantRankSummary[] {
|
||||
return rankings
|
||||
.map((participant, index) => ({
|
||||
|
||||
Reference in New Issue
Block a user