1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/**
* 应用加载服务类
*
* @export
* @class AppLoadingService
* @extends {LoadingServiceBase}
*/
export class AppLoadingService {
/**
* 唯一实例
*
* @private
* @static
* @memberof AppLoadingService
*/
private static readonly instance = new AppLoadingService();
/**
* 获取唯一实例
*
* @static
* @returns {AppLoadingService}
* @memberof AppLoadingService
*/
public static getInstance(): AppLoadingService {
return AppLoadingService.instance;
}
/**
* 视图loading计数器
*
* @type {number}
* @memberof AppLoadingService
*/
public loadingCounter: number = 0
/**
* 视图loading状态变量,true时正在loading
*
* @type {boolean}
* @memberof AppLoadingService
*/
public isLoading:boolean = false;
/**
* 开启视图loading
*
* @memberof AppLoadingService
*/
public beginLoading(){
this.loadingCounter++;
if(!this.isLoading){
this.isLoading = true;
}
}
/**
* 关闭视图loading
*
* @memberof AppLoadingService
*/
public endLoading(){
this.loadingCounter--;
if(this.isLoading && this.loadingCounter == 0){
this.isLoading = false;
}
}
}