From 9439bcf9d7096611cecf7eafa50f15fcbf560d87 Mon Sep 17 00:00:00 2001 From: kk <875203880@qq.com> Date: Fri, 17 Jul 2026 12:20:20 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E6=9E=90state=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/auth/loading.vue | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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') || '';