重构了云函数
This commit is contained in:
@@ -135,12 +135,26 @@ export class Initialize extends ecs.Entity {
|
||||
// 2. 登录并获取云端数据
|
||||
const loginResult = await WxCloudApi.login();
|
||||
const response = loginResult.result;
|
||||
|
||||
if (response.code === 200) {
|
||||
|
||||
if (loginResult.result.code === 200) {
|
||||
console.log("[Initialize]: 云端登录成功");
|
||||
const cloudData = response.data;
|
||||
|
||||
// 3. 用云端数据覆盖本地数据
|
||||
const cloudData = loginResult.result.data;
|
||||
try {
|
||||
// 直接覆盖基础游戏数据
|
||||
if (cloudData.openid) {
|
||||
smc.openid=cloudData.openid
|
||||
}
|
||||
// 直接覆盖出战英雄配置
|
||||
if (cloudData.game_data) {
|
||||
let gameDate=cloudData.game_data
|
||||
if( gameDate.gold ) smc.vmdata.gold=gameDate.gold
|
||||
if( gameDate.heros ) smc.heros=gameDate.heros
|
||||
if( gameDate.fight_hero ) smc.fight_hero=gameDate.fight_hero
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error(`[SMC]: 数据覆盖失败:`, error);
|
||||
}
|
||||
|
||||
} else {
|
||||
console.warn("[Initialize]: 云端登录失败:", response.msg);
|
||||
@@ -160,8 +174,7 @@ export class Initialize extends ecs.Entity {
|
||||
private async loadFromLocalDebug() {
|
||||
try {
|
||||
// 使用本地调试API,模拟云端接口
|
||||
const loginResult = new Test().load_data_from_local()
|
||||
|
||||
|
||||
// 用本地调试数据覆盖客户端数据
|
||||
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user