mirror of
https://gitee.com/dgflash/oops-plugin-framework.git
synced 2026-05-07 01:01:09 +08:00
1. TimeUtili添加将秒数格式化为时间格式
2. CCEntity添加逻辑组件为空时验证
This commit is contained in:
@@ -35,4 +35,32 @@ export class TimeUtil {
|
||||
}, ms)
|
||||
});
|
||||
}
|
||||
|
||||
/** 格式化字符串 */
|
||||
static format(countDown: number) {
|
||||
let result: string = "";
|
||||
let c: number = countDown;
|
||||
let date: number = Math.floor(c / 86400);
|
||||
c = c - date * 86400;
|
||||
let hours: number = Math.floor(c / 3600);
|
||||
c = c - hours * 3600;
|
||||
let minutes: number = Math.floor(c / 60);
|
||||
c = c - minutes * 60;
|
||||
let seconds: number = c;
|
||||
|
||||
if (date == 0 && hours == 0 && minutes == 0 && seconds == 0) {
|
||||
result = "00:00:00";
|
||||
}
|
||||
else {
|
||||
hours += date * 24;
|
||||
result = `${this.coverString(hours)}:${this.coverString(minutes)}:${this.coverString(seconds)}`;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/** 个位数的时间数据将字符串补位 */
|
||||
private static coverString(value: number) {
|
||||
if (value < 10) return "0" + value;
|
||||
return value.toString();
|
||||
}
|
||||
}
|
||||
@@ -190,6 +190,7 @@ export abstract class CCEntity extends ecs.Entity {
|
||||
* @returns 业务逻辑组件实例
|
||||
*/
|
||||
getBusiness<T extends CCBusiness<CCEntity>>(cls: any): T {
|
||||
if (this.businesss == null) return null!;
|
||||
return this.businesss.get(cls) as T;
|
||||
}
|
||||
|
||||
@@ -198,8 +199,10 @@ export abstract class CCEntity extends ecs.Entity {
|
||||
* @param cls 业务逻辑组件类
|
||||
*/
|
||||
removeBusiness(cls: any) {
|
||||
let business = this.businesss.get(cls);
|
||||
if (business) this.businesss.delete(cls);
|
||||
if (this.businesss) {
|
||||
let business = this.businesss.get(cls);
|
||||
if (business) this.businesss.delete(cls);
|
||||
}
|
||||
}
|
||||
//#endregion
|
||||
|
||||
|
||||
Reference in New Issue
Block a user