@cc-component/cc-core 1.8.5 → 1.8.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,6 +11,7 @@ export class TimeManager {
11
11
  private countdowns: Map<string, CountdownInfo> = new Map();
12
12
  timers = new Map();
13
13
 
14
+ timersKeys = new Map();
14
15
  /** 服务器时间 */
15
16
  private date_s: Date = new Date();
16
17
  /** 服务器初始时间 */
@@ -214,19 +215,19 @@ export class TimeManager {
214
215
 
215
216
  //#region 暂停和恢复计时器
216
217
 
217
-
218
-
219
- setTimeout(callback, delay) {
218
+ setTimeout(key: string, callback, delay) {
220
219
  const timerId = window.setTimeout(() => {
221
220
  callback();
222
221
  this.timers.delete(timerId); // 定时器执行后,从Map中删除
223
222
  }, delay);
224
223
 
225
224
  this.timers.set(timerId, () => window.clearTimeout(timerId));
225
+ this.timersKeys.set(key, timerId)
226
226
  return timerId;
227
227
  }
228
228
 
229
- clearTimeout(timerId) {
229
+ clearTimeout(key: string) {
230
+ const timerId = this.timersKeys.get(key)
230
231
  if (this.timers.has(timerId)) {
231
232
  this.timers.get(timerId)();
232
233
  this.timers.delete(timerId); // 从Map中删除定时器
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cc-component/cc-core",
3
- "version": "1.8.5",
3
+ "version": "1.8.6",
4
4
  "engine": ">=3.8.6",
5
5
  "description": "系统组件添加常用扩展方法",
6
6
  "main": "index.ts",