From ded90fd4234fefb428ddd16edbf43e8e749808ff Mon Sep 17 00:00:00 2001 From: xuchao Date: Tue, 21 Jul 2026 14:14:04 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=BC=80=E5=8F=91=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E8=BF=90=E8=A1=8C=E7=9B=B4=E6=8E=A5=E8=BF=9B=E9=97=A8=E7=A5=A8?= =?UTF-8?q?=E5=88=97=E8=A1=A8=EF=BC=8C=E4=B8=8D=E5=86=8D=E5=BC=B9=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题:全新运行(无登录态)时,列表页的登录门槛会把人弹到登录页, 本地开发每次都要手动输手机号,体验差。 改法:requireLogin 在开发模式下无登录态时静默用首个测试手机号假登录, 直接进业务页,不跳登录页;正式流程不变(公众号入口已透明登录, 登录页仅在外链冷启动等无身份场景出现)。 顺手修掉 redirect 参数的双重编码(URL 里难看的 %252F)。 已实测:清空登录态直接打开列表页,URL 停留在 scenic,列表正常渲染。 Co-Authored-By: Claude Opus 4.8 --- common/auth.js | 10 ++++++++-- pages/index/authorization.vue | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/common/auth.js b/common/auth.js index 5739a1e..39bf033 100644 --- a/common/auth.js +++ b/common/auth.js @@ -10,11 +10,17 @@ const isLogin = () => { return !!uni.getStorageSync('phone') } -// xuchao: 登录校验 —— 未登录则跳登录页,登录成功后回跳 redirect 指定的页面 +// xuchao: 登录校验 +// - 开发模式:无登录态时静默用首个测试手机号假登录,不跳登录页(本地直接进业务页) +// - 正式流程:跳登录页;登录成功后回跳 redirect 指定的页面 const requireLogin = (redirect) => { if (isLogin()) return true + if (config.devMode) { + loginByMock(config.testPhones[0]) + return true + } uni.navigateTo({ - url: '/pages/index/authorization' + (redirect ? '?redirect=' + encodeURIComponent(redirect) : '') + url: '/pages/index/authorization' + (redirect ? '?redirect=' + redirect : '') }) return false } diff --git a/pages/index/authorization.vue b/pages/index/authorization.vue index cf62f34..f8413cd 100644 --- a/pages/index/authorization.vue +++ b/pages/index/authorization.vue @@ -55,7 +55,7 @@ onLoad(options) { // xuchao: 记录登录前的页面,登录成功后回跳 if (options.redirect) { - this.redirect = decodeURIComponent(options.redirect) + this.redirect = options.redirect } // xuchao: 正式流程 —— 公众号网页授权重定向回来时 URL 带 code,用它换用户信息 if (options.code && !config.devMode) {