feat: 添加微信授权登录和修改昵称功能
This commit is contained in:
@@ -46,13 +46,37 @@ export default class Main {
|
||||
});
|
||||
console.log('[Main] 云环境初始化完成');
|
||||
|
||||
// 用户初始化(失败不阻塞)
|
||||
console.log('[Main] 初始化用户...');
|
||||
await this.userManager.init().catch(e => {
|
||||
console.warn('[Main] 用户初始化失败,使用游客模式:', e);
|
||||
});
|
||||
console.log('[Main] 用户初始化完成');
|
||||
// 检查用户是否已登录(只检查缓存,不自动登录)
|
||||
console.log('[Main] 检查登录状态...');
|
||||
const isLoggedIn = this.userManager.checkLogin();
|
||||
console.log('[Main] 登录状态:', isLoggedIn ? '已登录' : '未登录');
|
||||
|
||||
// 隐藏加载界面
|
||||
this.hideLoading();
|
||||
|
||||
if (!isLoggedIn) {
|
||||
// 未登录,显示登录场景
|
||||
console.log('[Main] 未登录,显示登录页面');
|
||||
this.sceneManager.switchScene('login');
|
||||
} else {
|
||||
// 已登录,加载数据并进入首页
|
||||
await this.loadAndEnterHome();
|
||||
}
|
||||
|
||||
// 设置分享
|
||||
this.setupShare();
|
||||
} catch (error) {
|
||||
console.error('[Main] 初始化失败:', error);
|
||||
this.hideLoading();
|
||||
this.showError('初始化失败,请重试');
|
||||
}
|
||||
}
|
||||
|
||||
// 加载数据并进入首页
|
||||
async loadAndEnterHome() {
|
||||
this.showLoading('正在加载...');
|
||||
|
||||
try {
|
||||
// 加载故事列表
|
||||
console.log('[Main] 加载故事列表...');
|
||||
await this.storyManager.loadStoryList();
|
||||
@@ -65,17 +89,15 @@ export default class Main {
|
||||
this.sceneManager.switchScene('home');
|
||||
console.log('[Main] 初始化完成,进入首页');
|
||||
|
||||
// 设置分享
|
||||
this.setupShare();
|
||||
|
||||
// 启动草稿检查(仅登录用户)
|
||||
if (this.userManager.isLoggedIn) {
|
||||
this.startDraftChecker();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('[Main] 初始化失败:', error);
|
||||
this.hideLoading();
|
||||
this.showError('初始化失败,请重试');
|
||||
console.error('[Main] 加载失败:', error);
|
||||
// 加载失败也进入首页,让用户可以重试
|
||||
this.sceneManager.switchScene('home');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user