@cc-component/cc-core 1.3.7 → 1.3.9
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.
|
@@ -32,7 +32,7 @@ export class LayerUI {
|
|
|
32
32
|
bundleName: string = "";
|
|
33
33
|
|
|
34
34
|
loading_call: { open: (finish: () => void) => void, close: () => void }
|
|
35
|
-
progess: { open: (finish: () => void) => void, close: () => void, progess: (progress: number) => void }
|
|
35
|
+
progess: { open: (finish: () => void) => void, close: () => void, progess: (progress: number, time?: number) => void }
|
|
36
36
|
|
|
37
37
|
scene: ISceneParam
|
|
38
38
|
launch: BaseLaunchComponent;
|
|
@@ -72,15 +72,24 @@ export abstract class BaseLoading extends Component {
|
|
|
72
72
|
LanguageData.path_spine = App.gui.config.language.path.spine;
|
|
73
73
|
App.language.setLanguage(App.bundleName, App.gui.config.language.default)
|
|
74
74
|
}
|
|
75
|
-
/**刷新进度
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
/**刷新进度
|
|
76
|
+
* total 总进度
|
|
77
|
+
* isReset 是否开始重置为0
|
|
78
|
+
*/
|
|
79
|
+
addProgess(progess: number, total: number): void {
|
|
80
|
+
const pro = this.getRemainingProgress(total)
|
|
81
|
+
this.pro_total += (pro * progess)
|
|
82
|
+
App.gui.progess.progess?.(this.pro_total)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
resetProgess() {
|
|
86
|
+
this.pro_total = 0
|
|
87
|
+
App.gui.progess.progess?.(this.pro_total, 0)
|
|
79
88
|
}
|
|
80
89
|
|
|
81
90
|
/**获取剩余进度 */
|
|
82
|
-
getRemainingProgress() {
|
|
83
|
-
return (
|
|
91
|
+
getRemainingProgress(total: number) {
|
|
92
|
+
return ((total) - this.pro_total / 100) * 100
|
|
84
93
|
}
|
|
85
94
|
FinishLoad() {
|
|
86
95
|
App.gui.progess.close?.()
|
|
@@ -136,8 +136,8 @@ export class App {
|
|
|
136
136
|
static OnLoading(param: { open: (finish: () => void) => void, close: () => void }) { App.gui.loading_call = param; }
|
|
137
137
|
static OnProgess(param: { open: (finish: () => void) => void, close: () => void, progess: (progress: number) => void }) { App.gui.progess = param; }
|
|
138
138
|
|
|
139
|
-
static async Requst<T>(config: IHttpConfig, params?: any, ext?: IExtData): Promise<
|
|
140
|
-
return new Promise<
|
|
139
|
+
static async Requst<T>(config: IHttpConfig, params?: any, ext?: IExtData): Promise<{ code: number, data: T, msg: string }> {
|
|
140
|
+
return new Promise<{ code: number, data: T, msg: string }>(async (originalResolve, originalReject) => {
|
|
141
141
|
let retries = 0; // 当前重试次数
|
|
142
142
|
const maxRetries = 5; // 最大重试次数
|
|
143
143
|
// 内部辅助函数,用于执行请求逻辑
|
|
@@ -42,14 +42,14 @@ declare global {
|
|
|
42
42
|
function InitGameConfig(param: IInitConfig): Promise<void>;
|
|
43
43
|
/**=====================================⚠️⚠️⚠️ 必须实现的监听======================= */
|
|
44
44
|
/**监听:打开场景加载进度窗口 -open 回调方法需要执行 finish() 方法 */
|
|
45
|
-
function OnProgess(param: { open: (finish: () => void) => void, close: () => void, progess: (progress: number) => void })
|
|
45
|
+
function OnProgess(param: { open: (finish: () => void) => void, close: () => void, progess: (progress: number, time?: number) => void })
|
|
46
46
|
/**监听:显示加载动画 -open 回调方法需要执行 finish() 方法 */
|
|
47
47
|
function OnLoading(param: { open: (finish: () => void) => void, close: () => void })
|
|
48
48
|
/**监听:是否打开网络接口重连窗口 -open 回调方法需要执行 finish() 方法 */
|
|
49
49
|
function OnRequstNet(param: { open: (finish: (isOk: boolean) => void) => void })
|
|
50
50
|
/**=====================================✅✅Http请求======================= */
|
|
51
51
|
/**网络接口 */
|
|
52
|
-
function Requst<T>(config: IHttpConfig, params?: any, ext?: { is_show_alert?: boolean }): Promise<
|
|
52
|
+
function Requst<T>(config: IHttpConfig, params?: any, ext?: { is_show_alert?: boolean }): Promise<{ code: number, data: T, msg: string }>;
|
|
53
53
|
/**=====================================✅✅消息发送======================= */
|
|
54
54
|
function Emit(eventName: string, params?: any);
|
|
55
55
|
function On(eventName: string, callback: any, target?: any);
|