feat(app跳转方法文件): 更新2种页面跳转方法

This commit is contained in:
hzj 2025-10-27 10:40:10 +08:00
parent c3d537ed2f
commit 14eeb193fe

View File

@ -60,8 +60,13 @@ export function closePage() {
*/ */
export function gotoPrivateChat(userId) { export function gotoPrivateChat(userId) {
try { try {
// 使用注入的方法 if (window.app && window.app.gotoPrivateChat) {
window.app.gotoPrivateChat(userId) // 使用注入的方法
window.app.gotoPrivateChat(userId)
} else if (window.FlutterPageControl) {
// 直接使用Flutter通道
window.FlutterPageControl.postMessage(`private_chat:${userId}`)
}
} catch (error) { } catch (error) {
console.error('前往私聊失败:', error) console.error('前往私聊失败:', error)
} }
@ -72,8 +77,13 @@ export function gotoPrivateChat(userId) {
*/ */
export function viewUserInfo(userId) { export function viewUserInfo(userId) {
try { try {
// 使用注入的方法 if (window.app && window.app.viewUserInfo) {
window.app.viewUserInfo(userId) // 使用注入的方法
window.app.viewUserInfo(userId)
} else if (window.FlutterPageControl) {
// 直接使用Flutter通道
window.FlutterPageControl.postMessage(`view_user_info:${userId}`)
}
} catch (error) { } catch (error) {
console.error('查看个人页面失败:', error) console.error('查看个人页面失败:', error)
} }
@ -84,8 +94,13 @@ export function viewUserInfo(userId) {
*/ */
export function gotoRoom(roomId) { export function gotoRoom(roomId) {
try { try {
// 使用注入的方法 if (window.app && window.app.gotoRoom) {
window.app.gotoRoom(roomId) // 使用注入的方法
window.app.gotoRoom(roomId)
} else if (window.FlutterPageControl) {
// 直接使用Flutter通道
window.FlutterPageControl.postMessage(`go_to_room:${roomId}`)
}
} catch (error) { } catch (error) {
console.error('前往房间失败:', error) console.error('前往房间失败:', error)
} }