feat(扫码签到):扫码签到方案调整~
deploy-hxtesting / build-and-deploy (push) Successful in 1m16s

This commit is contained in:
runny committed 2026-11-25 11:55:12 +08:00
1 parent f43fbef5db
commit 21abd01593
11 files changed
+450 -104

No files matched your search

@@ -31,6 +31,11 @@
有效期至 {{ fmtTime(signCode.expire_at) }}
<template v-if="signCode.geo_radius"> · 定位半径 {{ signCode.geo_radius }}m</template>
</div>
<!-- 二维码地址预检:非对外域名生成时当场提醒,避免学员扫码后企微报
"redirect_uri需使用应用可信域名"(2026-11 联调反馈) -->
<div class="sign-code-box__countdown is-stale" v-if="signCode && qrOriginWarn">
当前页面地址({{ qrOriginHost }})不是对外域名,学员扫码无法签到 —— 请从 kbt/kb.well-trust.com 打开本页重新生成
</div>
<!-- 自动轮换倒计时(2026-11 需求:二维码每 5 分钟自动更新,旧码即时作废;
轮换由后端在轮询读取时惰性触发,本页每 10s 轻量轮询驱动) -->
<div class="sign-code-box__countdown" v-if="signCode && rotateRemainSec > 0">
@@ -261,6 +266,22 @@ const buildSignQr = async () => {
}
watch(signCode, buildSignQr, { immediate: true })
// 二维码地址预检:企微 OAuth 要求 redirect_uri 使用应用可信域名,二维码内容
// 取本页 origin —— 若讲师在本机/内网地址打开培训签到页,学员扫码必然失败。
// 启发式与后端 checkin-auth 预检同口径(localhost/内网 IP/单标签/伪域名)。
const qrOriginHost = window.location.hostname.toLowerCase()
const qrOriginWarn = (() => {
const h = qrOriginHost
if (h === 'localhost' || h === '127.0.0.1' || h === '::1' || !h.includes('.')) return true
if (/^\d{1,3}(\.\d{1,3}){3}$/.test(h)) {
const [a, b] = h.split('.').map(Number)
if (a === 127 || a === 10 || a === 192) return true
if (a === 172 && b >= 16 && b <= 31) return true
if (a === 169 && b === 254) return true
}
return /\.(local|lan|internal|localhost)$/.test(h)
})()
// ---- 签到码自动轮换(2026-11 企微扫码需求) ----
// 后端在 GET sign-code 超过轮换窗口(rotation_sec,默认 5 分钟)时惰性轮换:
// 旧 token 挪入 prev(30s 宽限后彻底作废),新码即时生效。本页每 10s 轻量轮询