登录流程优化 增加错误码弹窗提醒

This commit is contained in:
2025-09-25 15:09:04 +08:00
parent 7f1d20e51b
commit ed525d9ed2
5 changed files with 34 additions and 30 deletions
+2
View File
@@ -132,7 +132,9 @@ export default class GameRootUI extends Component {
this.LayerNodeGroups[key] = newNode; this.LayerNodeGroups[key] = newNode;
} }
} }
}
showDefault() {
//默认打开的界面 //默认打开的界面
if (this.DefaultUI.length > 0) { if (this.DefaultUI.length > 0) {
ResManager.I.loadSubpackagePrefab(this.DefaultUI, (res) => { ResManager.I.loadSubpackagePrefab(this.DefaultUI, (res) => {
+2 -2
View File
@@ -86,7 +86,7 @@ export default class ResManager {
}); });
} else { } else {
assetManager.loadBundle( assetManager.loadBundle(
"PB", "Chat18x",
(err: Error, _bundle: AssetManager.Bundle) => { (err: Error, _bundle: AssetManager.Bundle) => {
if (err) { if (err) {
logger.log(err); logger.log(err);
@@ -137,7 +137,7 @@ export default class ResManager {
}); });
} else { } else {
assetManager.loadBundle( assetManager.loadBundle(
"PB", "Chat18x",
(err: Error, _bundle: AssetManager.Bundle) => { (err: Error, _bundle: AssetManager.Bundle) => {
if (err) { if (err) {
logger.log(err); logger.log(err);
-16
View File
@@ -25,21 +25,5 @@ export class MainScene extends Component {
gameRootUI.InitByCreate(this.UIRoot, this.UILayerMod, "NavigationPanel"); gameRootUI.InitByCreate(this.UIRoot, this.UILayerMod, "NavigationPanel");
} }
GameRootUI.MainCamera = this.MainCamera; GameRootUI.MainCamera = this.MainCamera;
// 初始化MainController并预加载数据
this.initMainController();
}
/**
* 初始化MainController并预加载数据
*/
private async initMainController(): Promise<void> {
try {
logger.log("[MainScene] 开始初始化MainController");
await MainController.I.init();
logger.log("[MainScene] MainController初始化完成");
} catch (error) {
logger.error("[MainScene] MainController初始化失败:", error);
}
} }
} }
+16 -2
View File
@@ -48,6 +48,9 @@ import { prodConfig } from "../../chat18x/config/env/prod";
import { logger } from "db://assets/Scripts/Main/Common/Logger"; import { logger } from "db://assets/Scripts/Main/Common/Logger";
import AudioManager from "../../Main/Manager/AudioManager"; import AudioManager from "../../Main/Manager/AudioManager";
import { Config18x } from "../../Main/Config/Config18x"; import { Config18x } from "../../Main/Config/Config18x";
import { MainController } from "../../chat18x/core/MainController";
import GameRootUI from "../../Main/Common/GameRootUI";
import { TipsPanel } from "../../chat18x/ui/panels/TipsPanel";
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
@@ -115,6 +118,8 @@ export class PreloadUI extends Component {
SDKManager.init(); SDKManager.init();
this.preloadFiles(); this.preloadFiles();
this.mainScene.init();
} }
protected onDestroy(): void {} protected onDestroy(): void {}
@@ -225,6 +230,8 @@ export class PreloadUI extends Component {
this.reqMyInfo(); this.reqMyInfo();
this.reqGlobalData(); this.reqGlobalData();
this.reqAiCharacterData(); this.reqAiCharacterData();
} else {
TipsPanel.show(LanguageUtils.getText("error_code_" + res.code));
} }
} }
@@ -238,6 +245,8 @@ export class PreloadUI extends Component {
const walletData = DataManager.I.getDataById<WalletData>(DataId.Wallet); const walletData = DataManager.I.getDataById<WalletData>(DataId.Wallet);
walletData.balance = Number(resData.balance); walletData.balance = Number(resData.balance);
walletData.vipExpire = Number(resData.vipExpire); walletData.vipExpire = Number(resData.vipExpire);
} else {
TipsPanel.show(LanguageUtils.getText("error_code_" + res.code));
} }
} }
@@ -251,6 +260,8 @@ export class PreloadUI extends Component {
// 保存数据 // 保存数据
const globalData = DataManager.I.getDataById<GlobalData>(DataId.Global); const globalData = DataManager.I.getDataById<GlobalData>(DataId.Global);
globalData.globals = res.data; globalData.globals = res.data;
} else {
TipsPanel.show(LanguageUtils.getText("error_code_" + res.code));
} }
} }
@@ -266,12 +277,15 @@ export class PreloadUI extends Component {
DataId.AiCharacter DataId.AiCharacter
); );
aiCharacterData.aiCharacter = res.data; aiCharacterData.aiCharacter = res.data;
} else {
TipsPanel.show(LanguageUtils.getText("error_code_" + res.code));
} }
} }
private enterGame() { private async enterGame() {
this.mainScene.init(); await MainController.I.init();
this.node.destroy(); this.node.destroy();
GameRootUI.I.showDefault();
//ResManager.I.goMainScene(); //ResManager.I.goMainScene();
} }
} }
@@ -38,7 +38,7 @@ export class MainController {
await Promise.all([ await Promise.all([
this.preloadThemeData(), this.preloadThemeData(),
this.preloadDailyRecommend(), this.preloadDailyRecommend(),
this.preloadShopList() this.preloadShopList(),
]); ]);
logger.log("[MainController] 数据预加载完成"); logger.log("[MainController] 数据预加载完成");
@@ -141,7 +141,11 @@ export class MainController {
* 检查数据是否已预加载 * 检查数据是否已预加载
*/ */
isDataPreloaded(): boolean { isDataPreloaded(): boolean {
return this.isThemeDataPreloaded && this.isDailyRecommendPreloaded && this.isShopListPreloaded; return (
this.isThemeDataPreloaded &&
this.isDailyRecommendPreloaded &&
this.isShopListPreloaded
);
} }
/** /**
@@ -152,7 +156,7 @@ export class MainController {
themeData: this.isThemeDataPreloaded, themeData: this.isThemeDataPreloaded,
dailyRecommend: this.isDailyRecommendPreloaded, dailyRecommend: this.isDailyRecommendPreloaded,
shopList: this.isShopListPreloaded, shopList: this.isShopListPreloaded,
allComplete: this.isDataPreloaded() allComplete: this.isDataPreloaded(),
}; };
} }