This commit is contained in:
2026-05-19 11:55:24 +08:00
parent f62f6b4ac9
commit 4ee43cf71a
462 changed files with 75251 additions and 0 deletions

View File

@@ -0,0 +1,75 @@
import { Node, UIOpacity, _decorator, tween } from 'cc';
import BaseAppInit from '../../../extensions/app/assets/base/BaseAppInit';
import { LOGIN_TOKEN } from '../../res-native/network/HttpRequest';
import { Tools } from '../../res-native/tools/Tools';
import { app } from '../../app/app';
import { USERDATA } from '../../res-native/data/UserData';
const { ccclass, property } = _decorator;
@ccclass('AppInit')
export class AppInit extends BaseAppInit {
@property(Node)
private logo: Node;
/**
* 获得用户资源总量这里返回几就需要用户自行调用几次nextInit
*/
protected getUserAssetNum(): number {
return 1;
}
protected onLoad() {
this.initToken();
if (LOGIN_TOKEN.access_token == "" || LOGIN_TOKEN.access_token == undefined) {
return
}
// 执行初始化操作
const opacity = this.logo.getComponent(UIOpacity);
opacity.opacity = 0;
tween(opacity)
.to(0.5, { opacity: 255 })
.delay(1)
.to(0.5, { opacity: 0 })
.call(() => {
Tools.httpReq("prize-list", {}, (res:any) => {
USERDATA.setUserData(res);
this.nextInit();
})
})
.start();
}
/** 根据参数初始化TOKEN */
initToken(){
let str = window.location.search.slice(1)
const pairs = str.split('&');
const params: { [key: string]: string } = {};
pairs.forEach(pair => {
const [key, value] = pair.split('=');
params[decodeURIComponent(key)] = decodeURIComponent(value || '');
});
const at = Tools.parseJWT(params.access_token)
const actualKey = 'xyxfz83d'.substring(0, 8); // 取前8个字符
// 解密appkey
const appkey = Tools.desEcbDecrypt(at.extend.channel, actualKey);
// 如果解密失败,尝试原始值
if (!appkey) {
console.log('Failed to decrypt token, using original value');
}
LOGIN_TOKEN.setToken(params.access_token, params.refresh_token, at.extend.app_id, appkey)
}
// BaseAppInit中使用start方法作为初始化入口如果重写start方法请注意调用父类方法
// protected start() { }
protected onFinish() {
// 执行完成操作
this.node.destroy();
}
}