简化state参数
Uni-app H5 Deploy (Prod + Staging) / deploy (release) Successful in 1m7s

This commit is contained in:
kk
2026-07-20 17:45:44 +08:00
parent 558e1380db
commit e1f71fb220
2 changed files with 12 additions and 61 deletions
+4 -25
View File
@@ -47,32 +47,11 @@
if (code) {
// 有 code → 进入授权 Loading 页处理
// state 中解析 device_id 和 actionOAuth 标准保证 state 原样回传)
let action = '';
let callbackDeviceId = deviceId || '';
try {
const stateStr = urlParams.get('state');
if (stateStr) {
const stateObj = JSON.parse(decodeURIComponent(stateStr));
action = stateObj.action || action;
callbackDeviceId = stateObj.device_id || callbackDeviceId;
}
} catch (_) {
// state 解析失败,忽略
}
// 存入 localStorage,确保 loading 页面复用时也能获取(redirectTo 可能不触发 onLoad
if (action) {
localStorage.setItem('__auth_action', action);
}
if (callbackDeviceId) {
localStorage.setItem('__auth_device_id', callbackDeviceId);
}
// state 为 "base" 或 "userinfo",直接透传
const state = urlParams.get('state') || '';
let loadingUrl = '/pages/auth/loading?code=' + encodeURIComponent(code);
if (action) {
loadingUrl += '&action=' + action;
}
if (callbackDeviceId) {
loadingUrl += '&device_id=' + callbackDeviceId;
if (state) {
loadingUrl += '&state=' + state;
}
uni.redirectTo({ url: loadingUrl });
return;