diff --git a/src/pages/auth/loading.vue b/src/pages/auth/loading.vue index 49242d0..9585ad6 100644 --- a/src/pages/auth/loading.vue +++ b/src/pages/auth/loading.vue @@ -37,6 +37,24 @@ export default { code = urlParams.get('code') || urlParams.get('auth_code') || ''; } + // 解析 state 参数(OAuth 标准保证 state 原样回传,包含 action 和 device_id) + if (!this.action || !this.deviceId) { + const stateRaw = options.state || ''; + if (stateRaw) { + try { + const stateObj = JSON.parse(decodeURIComponent(stateRaw)); + if (!this.action && stateObj.action) { + this.action = stateObj.action; + } + if (!this.deviceId && stateObj.device_id) { + this.deviceId = stateObj.device_id; + } + } catch (_) { + // state 解析失败,继续用 localStorage 兜底 + } + } + } + // 兜底:从 localStorage 恢复(页面复用时 onLoad 不触发,localStorage 由跳转函数清理) if (!this.action) { this.action = localStorage.getItem('__auth_action') || '';