| | |
| | | } |
| | | |
| | | // 2. 同时保留原有的URL参数解析逻辑,作为备选 |
| | | // const url = new URL(window.location.href); |
| | | // const paramsStr = url.searchParams.get('params'); |
| | | // if (paramsStr) { |
| | | // try { |
| | | // const params = JSON.parse(decodeURIComponent(paramsStr)); |
| | | // if (params.peerUid) { |
| | | // peerUid.value = String(params.peerUid); |
| | | // log('🔗 从URL参数获取peerUid:', params.peerUid); |
| | | // } |
| | | // } catch (e) { |
| | | // log('❌ 解析URL参数失败:', String(e)); |
| | | // } |
| | | // } |
| | | const url = new URL(window.location.href); |
| | | const paramsStr = url.searchParams.get('params'); |
| | | if (paramsStr) { |
| | | try { |
| | | const params = JSON.parse(decodeURIComponent(paramsStr)); |
| | | if (params.peerUid) { |
| | | peerUid.value = String(params.peerUid); |
| | | log('🔗 从URL参数获取peerUid:', params.peerUid); |
| | | } |
| | | } catch (e) { |
| | | log('❌ 解析URL参数失败:', String(e)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 从URL参数或本地存储获取用户ID |
| | | const getUserIdFromStorage = () => { |
| | | // 从url获取用户id |
| | | const contact = JSON.parse(decodeURIComponent(receiveParameters.value)).userId |
| | | console.log('从url获取用户id',contact) |
| | | const contact = JSON.parse(decodeURIComponent(receiveParameters.value)) |
| | | console.log('从url获取用户id',contact?.userId) |
| | | // 从本地获取用户id |
| | | const userId = localStorage.getItem('userId') || sessionStorage.getItem('userId') |
| | | console.log('从本地存储获取userId:', userId) |