Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .claude/settings.local.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"Bash(npm install:*)",
"Bash(cat)",
"Read(//tmp/**)",
"Bash(xargs grep:*)"
"Bash(xargs grep:*)",
"Bash(ipconfig)"
]
}
}
2 changes: 1 addition & 1 deletion miniprogram/constants/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ interface IEnvConfig {
}

/** LAN IP for real device testing in develop mode */
const LAN_IP: string = '192.168.31.204';
const LAN_IP: string = '192.168.31.205';

const ENV_CONFIGS = {
devtools: {
Expand Down
89 changes: 60 additions & 29 deletions miniprogram/packageA/pages/waiting-room/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ interface IWaitingRoomCustomOption extends WechatMiniprogram.Page.CustomOption {
confirmButtonAnim: WechatMiniprogram.Animation | null;
isCreatingRoom: boolean;
isJoiningRoom: boolean;
pendingRoomId: string | null;
pendingAction: 'host' | 'join' | 'confirm_join' | null;
}

/**
Expand Down Expand Up @@ -144,7 +144,7 @@ Page<IWaitingRoomPageData, IWaitingRoomCustomOption>({
// 请求锁
isCreatingRoom: false,
isJoiningRoom: false,
pendingRoomId: null,
pendingAction: null,

onLoad(options: IWaitingRoomOnLoadOptions): void {
this.initAnimations();
Expand All @@ -155,14 +155,7 @@ Page<IWaitingRoomPageData, IWaitingRoomCustomOption>({
});

const roomId = options['room_id'] ?? null;
const storedNick: string = wx.getStorageSync('userNickName') || '';

if (!storedNick) {
// 未设置昵称:先弹昵称框,房间号暂存
this.pendingRoomId = roomId;
this.openNicknameModal();
} else if (roomId) {
// 已有昵称且是分享链接进入:直接弹加入房间框
if (roomId) {
this.showJoinModalWithCode(roomId);
}
},
Expand Down Expand Up @@ -269,26 +262,44 @@ Page<IWaitingRoomPageData, IWaitingRoomCustomOption>({
}

nicknameService.saveNickName(nicknameInput);

this.setData({ showNicknameModal: false });

if (this.pendingRoomId) {
const rid = this.pendingRoomId;
this.pendingRoomId = null;
this.showJoinModalWithCode(rid);
}
this.executePendingAction();
},

/**
* 「稍后再说」次级按钮:使用默认昵称进入,不保存到 Storage
*/
onNicknameSkip(): void {
this.setData({ showNicknameModal: false });
this.executePendingAction();
},

if (this.pendingRoomId) {
const rid = this.pendingRoomId;
this.pendingRoomId = null;
this.showJoinModalWithCode(rid);
/**
* 昵称弹窗关闭后,根据 pendingAction 执行后续操作
*/
executePendingAction(): void {
const action = this.pendingAction;
this.pendingAction = null;
if (action === 'host') {
void this.createRoom();
} else if (action === 'join') {
this.setData({
showJoinModal: true,
roomCodeInput: '',
roomCodeDisplay: ['', '', '', '', '', ''],
inputFocus: true,
errorType: null,
errorMessage: '',
isJoinButtonDisabled: true,
});
} else if (action === 'confirm_join') {
const { roomCodeInput } = this.data;
this.isJoiningRoom = true;
void wx.showLoading({ title: '加入房间中...' });
roomWebSocketService.joinRoom(
roomCodeInput,
nicknameService.getNickName()
);
}
},

Expand All @@ -297,7 +308,7 @@ Page<IWaitingRoomPageData, IWaitingRoomCustomOption>({
*/
onNicknameModalMaskTap(): void {
this.setData({ showNicknameModal: false });
this.pendingRoomId = null;
this.pendingAction = null;
},

/**
Expand Down Expand Up @@ -399,6 +410,15 @@ Page<IWaitingRoomPageData, IWaitingRoomCustomOption>({
'hostButtonAnimation'
);

const storedNick: string = wx.getStorageSync('userNickName') || '';
if (!storedNick) {
this.pendingAction = 'host';
setTimeout(() => {
this.openNicknameModal();
}, 200);
return;
}

setTimeout(() => {
void this.createRoom();
}, 200);
Expand Down Expand Up @@ -463,6 +483,15 @@ Page<IWaitingRoomPageData, IWaitingRoomCustomOption>({
'joinButtonAnimation'
);

const storedNick: string = wx.getStorageSync('userNickName') || '';
if (!storedNick) {
this.pendingAction = 'join';
setTimeout(() => {
this.openNicknameModal();
}, 200);
return;
}

setTimeout(() => {
this.setData({
showJoinModal: true,
Expand Down Expand Up @@ -548,16 +577,18 @@ Page<IWaitingRoomPageData, IWaitingRoomCustomOption>({
return;
}

// 通过 WebSocket 加入房间
this.setData({
errorType: null,
errorMessage: '',
});
this.setData({ errorType: null, errorMessage: '' });

// 无昵称:先弹昵称框,确认后再加入
const storedNick: string = wx.getStorageSync('userNickName') || '';
if (!storedNick) {
this.pendingAction = 'confirm_join';
this.openNicknameModal();
return;
}

this.isJoiningRoom = true;
void wx.showLoading({ title: '加入房间中...' });

// 发送加入房间消息
roomWebSocketService.joinRoom(
roomCodeInput,
nicknameService.getNickName()
Expand Down
Loading