From 2483dd933a1f51f3cc9b043e199857b44f1aaf7d Mon Sep 17 00:00:00 2001 From: "DESKTOP-JKIE562\\PC" <1013397054@qq.com> Date: Wed, 25 Nov 2026 12:34:35 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=88=E6=89=AB=E7=A0=81=E7=99=BB?= =?UTF-8?q?=E5=BD=95=EF=BC=89:=E8=B0=83=E6=95=B4=E7=AD=BE=E5=88=B0?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/design/企微扫码签到免登-落地方案.md | 3 +- frontend/src/router/index.ts | 31 +++++++++++++------ frontend/src/views/training/CheckinPage.vue | 4 ++- .../views/training/components/SignPanel.vue | 2 +- internal/handler/training/training.go | 5 +-- 5 files changed, 30 insertions(+), 15 deletions(-) diff --git a/docs/design/企微扫码签到免登-落地方案.md b/docs/design/企微扫码签到免登-落地方案.md index e312088..023c192 100644 --- a/docs/design/企微扫码签到免登-落地方案.md +++ b/docs/design/企微扫码签到免登-落地方案.md @@ -286,4 +286,5 @@ - **OAuth 降级为预留通道**:`checkin-auth/checkin-session` 后端保留,前端仅在 URL 带 code+state 回跳时消费,主流程不再跳转授权页;可信域名配置就绪后可恢复为免登优先; - **自动登录开关**:规则项 `employee_checkin_autologin`(默认 1=开;0=只签到不签发会话,前端停留成功页)——工号属半公开信息,存在知悉他人工号者冒签/冒登录的风险,已与需求方确认接受,该开关是回退手段; - **前端**:`CheckinPage` 匿名主流程(工号输入框 + 输入工号签到按钮);已登录用户(PC 自测/已有会话)仍走登录态接口并预填工号; - - **repo 新增**:`GetMemberByEmployeeNo`(同工号多行取最早建档行,保证稳定映射)。 + - **repo 新增**:`GetMemberByEmployeeNo`(同工号多行取最早建档行,保证稳定映射); + - **独立手机端 H5(2026-11-25 三次调整)**:签到页从 `/platform` 子路由迁出为**顶层独立路由** `/m/training/checkin/:token` —— 直接渲染在 App.vue 裸 RouterView,完全脱离平台壳布局(侧栏/桌面样式),扫码免登录直达;二维码指向新路径;旧路径 `/platform/training/checkin/:token` 兼容重定向(携 query,OAuth 回跳参数不丢);移动端满屏居中样式。核实结论:路由守卫/平台布局/App.vue 均无对显式 `requiresAuth:false` 路由的登录拦截,"扫码先登录"系测试环境跑旧构建所致(旧版进页自动签到 → 401 → axios 拦截器跳登录),**验证前必须重新构建部署前后端**。 diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts index 51ddc94..4de6db5 100644 --- a/frontend/src/router/index.ts +++ b/frontend/src/router/index.ts @@ -56,6 +56,17 @@ const router = createRouter({ component: () => import("../views/auth/Login.vue"), meta: { requiresAuth: false, requiresInit: false } }, + { + // 学员扫码签到:独立手机端 H5 页(2026-11-25 调整)。顶层路由,直接渲染在 + // App.vue 的裸 RouterView —— 完全脱离平台壳布局(侧栏/桌面样式),扫码免 + // 登录直达;页面内自行完成工号签到与自动登录。显式 requiresAuth:false + + // requiresInit:false 放行路由守卫(meta 缺省 = undefined 时守卫仍按需 + // 登录拦截,必须显式 false)。 + path: "/m/training/checkin/:token", + name: "mobileTrainingCheckin", + component: () => import("../views/training/CheckinPage.vue"), + meta: { requiresInit: false, requiresAuth: false } + }, // Embed chat is a separate entry (embed.html + embed-main.ts), not this SPA. { path: "/register", @@ -184,16 +195,16 @@ const router = createRouter({ component: () => import("../views/training/CourseDetail.vue"), meta: { requiresInit: true, requiresAuth: true } }, - { - // 学员扫码签到落地页(2026-11 企微扫码免登):企微「扫一扫」直接打开, - // 页面内自行完成免登(OAuth 静默授权)/自动登录/倒计时/点击签到, - // 故显式 requiresAuth:false + requiresInit:false 放行路由守卫 - // (meta 缺省 = undefined 时守卫仍按需登录拦截,必须显式 false)。 - path: "training/checkin/:token", - name: "trainingCheckin", - component: () => import("../views/training/CheckinPage.vue"), - meta: { requiresInit: false, requiresAuth: false } - }, + { + // 旧平台内签到路径兼容重定向(2026-11-25 签到页迁移为独立手机端 H5): + // 已投屏/已分发的旧二维码短窗口内仍可扫;携 query 重定向,OAuth 回跳 + // 参数(code/state)不丢。 + path: "training/checkin/:token", + redirect: (to) => ({ + path: `/m/training/checkin/${to.params.token}`, + query: to.query + }) + }, { // 组织架构:租户级共享组织架构(部门 + 员工档案), // 业务模块(企业培训等)按需引用,部门岗位只维护一份。 diff --git a/frontend/src/views/training/CheckinPage.vue b/frontend/src/views/training/CheckinPage.vue index 074f11c..e276a3e 100644 --- a/frontend/src/views/training/CheckinPage.vue +++ b/frontend/src/views/training/CheckinPage.vue @@ -429,8 +429,10 @@ onBeforeUnmount(stopCountdown) display: flex; align-items: center; justify-content: center; - min-height: 60vh; + // 独立手机端 H5 页:顶层路由直接渲染,占满整屏并居中卡片(脱离平台壳布局)。 + min-height: 100vh; padding: var(--app-space-4); + background: var(--td-bg-color-page, #f3f3f3); } .checkin-card { diff --git a/frontend/src/views/training/components/SignPanel.vue b/frontend/src/views/training/components/SignPanel.vue index 01f6022..12707a0 100644 --- a/frontend/src/views/training/components/SignPanel.vue +++ b/frontend/src/views/training/components/SignPanel.vue @@ -257,7 +257,7 @@ const buildSignQr = async () => { signQrUrl.value = '' return } - const url = `${window.location.origin}/platform/training/checkin/${token}` + const url = `${window.location.origin}/m/training/checkin/${token}` try { signQrUrl.value = await QRCode.toDataURL(url, { width: 320, margin: 1 }) } catch { diff --git a/internal/handler/training/training.go b/internal/handler/training/training.go index a0de7d3..e4f7f14 100644 --- a/internal/handler/training/training.go +++ b/internal/handler/training/training.go @@ -1855,7 +1855,8 @@ func (h *Handler) WecomCheckinAuth(c *gin.Context) { } redirectURI := strings.TrimSpace(q.RedirectURI) if redirectURI == "" { - // 兜底:按请求 Host 还原落地页地址(反代透传 X-Forwarded-Proto)。 + // 兜底:按请求 Host 还原落地页地址(独立手机端 H5 路由,反代透传 + // X-Forwarded-Proto)。 scheme := "https" if c.Request.TLS == nil { if proto := strings.TrimSpace(c.GetHeader("X-Forwarded-Proto")); proto != "" { @@ -1864,7 +1865,7 @@ func (h *Handler) WecomCheckinAuth(c *gin.Context) { scheme = "http" } } - redirectURI = fmt.Sprintf("%s://%s/platform/training/checkin/%s", scheme, c.Request.Host, q.Token) + redirectURI = fmt.Sprintf("%s://%s/m/training/checkin/%s", scheme, c.Request.Host, q.Token) } url, err := h.svc.WecomCheckinAuthURL(c.Request.Context(), q.Token, redirectURI) if err != nil {