9.18王德鹏/1

This commit is contained in:
2025-09-18 14:22:04 +08:00
parent a8dcee7296
commit 335e21347b
90 changed files with 1618 additions and 1346 deletions

View File

@@ -19,4 +19,29 @@ export function createApp() {
app
}
}
// #endif
// 规范化 WebSocket 关闭码(仅微信小程序)
// #ifdef MP-WEIXIN
if (typeof uni !== 'undefined' && typeof uni.connectSocket === 'function') {
const _connectSocket = uni.connectSocket
uni.connectSocket = function(options) {
const task = _connectSocket.call(this, options)
if (task && typeof task.close === 'function') {
const _close = task.close
task.close = function(params = {}) {
if (params && typeof params === 'object') {
const codeNum = Number(params.code)
const isValid = codeNum === 1000 || (codeNum >= 3000 && codeNum <= 4999)
if (!isValid) {
params.code = 1000
if (!params.reason) params.reason = 'normalized from invalid close code'
}
}
return _close.call(this, params)
}
}
return task
}
}
// #endif