From d2c47ff78448b3e23a43bfd296af31d40e88c21c Mon Sep 17 00:00:00 2001 From: dgflash Date: Wed, 17 Sep 2025 13:45:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DLabelTime=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E4=BB=8E1=E5=A4=A9=E5=87=8F=E5=88=B0=E5=B0=8F=E4=BA=8E1?= =?UTF-8?q?=E5=A4=A9=E6=97=B6=EF=BC=8C=E7=BB=93=E6=9E=9C=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/libs/gui/label/LabelTime.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/assets/libs/gui/label/LabelTime.ts b/assets/libs/gui/label/LabelTime.ts index e370c7f..2639553 100644 --- a/assets/libs/gui/label/LabelTime.ts +++ b/assets/libs/gui/label/LabelTime.ts @@ -18,7 +18,7 @@ export default class LabelTime extends Label { @property({ tooltip: "天数数据格式化", }) - dayFormat: string = "{0} day"; + dayFormat: string = "{0}天{1}时"; @property({ tooltip: "时间格式化", @@ -26,7 +26,7 @@ export default class LabelTime extends Label { timeFormat: string = "{0}:{1}:{2}"; @property({ - tooltip: "是否有00", + tooltip: "时间是否有固定二位数据", }) zeroize: boolean = true; @@ -74,7 +74,7 @@ export default class LabelTime extends Label { let dataFormat = this.dayFormat; let index = dataFormat.indexOf("{1}"); if (hours == 0 && index > -1) { - dataFormat = dataFormat.substring(0, index - 1); + dataFormat = dataFormat.substring(0, index); } let df = dataFormat; if (date > 1 && dataFormat.indexOf("days") < 0) { @@ -83,7 +83,13 @@ export default class LabelTime extends Label { if (date < 2) { df = df.replace("days", "day"); } - this.result = this.replace(df, date, hours); // 如果天大于1,则显示 "1 Day..." + + if (this.zeroize) { + this.result = this.replace(df, date, this.coverString(hours)); + } + else { + this.result = this.replace(df, date, hours); // 如果天大于1,则显示 "1 Day..." + } } else { hours += date * 24; @@ -214,4 +220,4 @@ export default class LabelTime extends Label { timing_end() { this.unscheduleAllCallbacks(); } -} +} \ No newline at end of file