From 103443535522ea3c2ea4fb33a09a92e1a4ff4776 Mon Sep 17 00:00:00 2001 From: "DESKTOP-JKIE562\\PC" <1013397054@qq.com> Date: Fri, 11 Sep 2026 04:09:56 +0800 Subject: [PATCH] =?UTF-8?q?fix(auth):=20=E4=BC=81=E5=BE=AE=E6=8F=90?= =?UTF-8?q?=E9=86=92=E5=8D=A1=E7=89=87=E6=B7=B1=E9=93=BE=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E5=90=8E=E5=9B=9E=E8=B7=B3=E5=8E=9F=E7=9B=AE=E6=A0=87=20-=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=20shared/utils/redirect.ts=20=E5=AE=89?= =?UTF-8?q?=E5=85=A8=E5=9B=9E=E8=B7=B3=E6=A0=A1=E9=AA=8C=EF=BC=88=E9=98=B2?= =?UTF-8?q?=E5=BC=80=E6=94=BE=E9=87=8D=E5=AE=9A=E5=90=91=EF=BC=89=20-=20?= =?UTF-8?q?=E8=B7=AF=E7=94=B1=E5=AE=88=E5=8D=AB=E6=9C=AA=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E8=B7=B3=E8=BD=AC=E6=90=BA=E5=B8=A6=20redirect=20=E5=AE=8C?= =?UTF-8?q?=E6=95=B4=E6=B7=B1=E9=93=BE=EF=BC=8C=E5=B7=B2=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E8=AE=BF=E9=97=AE=E7=99=BB=E5=BD=95=E9=A1=B5=E4=BC=98=E5=85=88?= =?UTF-8?q?=E5=9B=9E=E8=B7=B3=20-=20=E7=99=BB=E5=BD=95=E6=88=90=E5=8A=9F?= =?UTF-8?q?=E7=BB=9F=E4=B8=80=E6=8C=89=20redirect=20=E6=B7=B1=E9=93=BE?= =?UTF-8?q?=E8=90=BD=E5=9C=B0=EF=BC=8C=E6=94=AF=E6=8C=81=E4=BC=81=E5=BE=AE?= =?UTF-8?q?=E5=8D=A1=E7=89=87=E7=82=B9=E5=87=BB=E7=9B=B4=E8=BE=BE=E7=B2=BE?= =?UTF-8?q?=E7=9B=8A=E5=9F=B9=E8=AE=AD=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/funclist.md | 1 + frontend/package-lock.json | 334 +++++++++++++++++- frontend/package.json | 2 + frontend/src/app/router/guards.ts | 13 +- .../src/features/auth/composables/useLogin.ts | 42 ++- .../chat/components/TrainingShareModal.vue | 160 +++++++++ .../components/TrainingWorkspacePanel.vue | 60 +++- .../messages/ContractReviewResultCard.vue | 4 +- .../shipping-review/useShippingOrderReview.ts | 8 +- .../shipping/useShippingProcessingWorkItem.ts | 4 +- frontend/src/locales/en/chat.json | 12 + frontend/src/locales/th/chat.json | 12 + frontend/src/locales/zh-CN/chat.json | 12 + frontend/src/locales/zh-TW/chat.json | 12 + frontend/src/shared/utils/redirect.ts | 18 + 15 files changed, 656 insertions(+), 38 deletions(-) create mode 100644 frontend/src/features/chat/components/TrainingShareModal.vue create mode 100644 frontend/src/shared/utils/redirect.ts diff --git a/docs/funclist.md b/docs/funclist.md index dad7f5af..33eb8eb3 100644 --- a/docs/funclist.md +++ b/docs/funclist.md @@ -67,6 +67,7 @@ | 培训配置管理 | 已实现 | `TrainingConfigResource` 增加 `training_level`;管理端按公司级、部门级、班组级卡片独立增删资料;知识库候选仅允许“员工培训”分组内未删除文档的当前版本;员工端按 `safetyStage` 动态展示当前级别资料 | | 精益培训对象化任务与提醒 | 已实现 | HR 按系统角色或指定用户(并集)发布精益周任务;任务、看板和提醒只处理冻结对象,首次发布与定向催学均复用企微提醒审计幂等去重。学员端“精益管理”按时间树展示全部已发布任务(按任务周期倒序、最新在上),每期任务带状态徽章(进行中/已延期/已完成,由服务端按截止时间与完成记录判定)、任务周期区间与视频缩略图(点击弹窗播放,须播放到结尾才判定观看完成并由服务端持久化,提前关闭或拖拽跳过不计);提交学习感悟前校验:未观看全部已推送视频或感悟字数不达标时拦截并友好提示;任务"已完成"仅在感悟提交后落定。 | | 精益周任务规则化推送 | 已实现 | 任务周(周一)与截止时间默认按当周计算且**支持修改**(可指定任意自然周与截止时刻,须为周一且截止不早于所选周周一;修改后【发布周任务】/【立即新增任务补推】均作用于所选周任务);培训视频列表分页展示(4 条/页),已推送视频默认勾选、不可取消并带"第X周 MM-DD至MM-DD"周次标签,推过的视频不重复推直至全部推完;【发布周任务】对所选周任务发布并首次自动推首批,【立即新增任务补推】按游标对所选周任务增推;平台排程每周一 09:00(Asia/Shanghai)自动滚动创建当周任务(模板取严格早于当周的最近一期,游标继承进度)并推送下一批,无需人工维护;每批推送成功后立即向受训人员发送企微通知,并对"已延期"(过截止未提交)人员立即发送延期提醒(event_key 幂等防重);学员端任务期号统一采用后端 week_index 口径。规则手册见 [docs/features/training/精益管理周任务规则手册.md](features/training/精益管理周任务规则手册.md) | +| 培训分享入口 | 前端已实现 | 员工培训页培训类型页签行右侧新增分享按钮,仅具备 `training_hr_manage`(培训管理)权限的用户可见;点击弹出分享弹窗,支持复制链接或下载二维码,链接指向 `/chat/?training_type=<当前培训类型>` 深链,接收者点击或扫码后在登录页登录,登录成功自动回跳员工培训页并定位到对应培训类型(如“出国规章培训”);文案覆盖 zh-CN/zh-TW/en/th 四语言 | | 培训主链推荐架构 | 已文档化 | 推荐采用“受控考试主链 + Dify 辅助问答/ChatBI”的混合方案;培训 Agent 对接 Dify 时会额外透传后台账号 `role`,便于区分学员/HR 问答分支,见 [docs/新人入职培训Agent_推荐落地方案.md](新人入职培训Agent_推荐落地方案.md) | | 培训业务闭环整改清单 | 已文档化 | 见[docs/新人入职培训Agent_闭环整改清单.md](新人入职培训Agent_闭环整改清单.md) | diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 20433374..34aff6ce 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -20,6 +20,7 @@ "marked": "^17.0.3", "pdfjs-dist": "^5.6.205", "pinia": "^3.0.4", + "qrcode": "^1.5.4", "vue": "^3.5.25", "vue-i18n": "^11.2.8", "vue-router": "^4.6.4", @@ -28,6 +29,7 @@ "devDependencies": { "@types/node": "^24.10.1", "@types/pdfjs-dist": "^2.10.377", + "@types/qrcode": "^1.5.6", "@vitejs/plugin-vue": "^6.0.2", "@vue/test-utils": "^2.4.11", "@vue/tsconfig": "^0.8.1", @@ -1179,6 +1181,16 @@ "pdfjs-dist": "*" } }, + "node_modules/@types/qrcode": { + "version": "1.5.6", + "resolved": "https://registry.npmjs.org/@types/qrcode/-/qrcode-1.5.6.tgz", + "integrity": "sha512-te7NQcV2BOvdj2b1hCAHzAoMNuj65kNBMz0KBaxM6c3VGBOhU0dURQKOtH8CFNI/dsKkwlv32p26qYQTWoB5bw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/raf": { "version": "3.4.3", "resolved": "https://registry.npmjs.org/@types/raf/-/raf-3.4.3.tgz", @@ -1845,6 +1857,15 @@ "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" } }, + "node_modules/camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/camelcase-css": { "version": "2.0.1", "resolved": "https://registry.npmmirror.com/camelcase-css/-/camelcase-css-2.0.1.tgz", @@ -1954,6 +1975,87 @@ "node": ">= 6" } }, + "node_modules/cliui": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", + "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==", + "license": "ISC", + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^6.2.0" + } + }, + "node_modules/cliui/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/cliui/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/cliui/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "license": "MIT" + }, + "node_modules/cliui/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/cliui/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/cliui/node_modules/wrap-ansi": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", + "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/codepage": { "version": "1.15.0", "resolved": "https://registry.npmmirror.com/codepage/-/codepage-1.15.0.tgz", @@ -1967,7 +2069,6 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, "license": "MIT", "dependencies": { "color-name": "~1.1.4" @@ -1980,7 +2081,6 @@ "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true, "license": "MIT" }, "node_modules/commander": { @@ -2134,6 +2234,15 @@ "node": "^20.19.0 || ^22.12.0 || >=24.0.0" } }, + "node_modules/decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/decimal.js": { "version": "10.6.0", "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.6.0.tgz", @@ -2157,6 +2266,12 @@ "integrity": "sha512-gxtyfqMg7GKyhQmb056K7M3xszy/myH8w+B4RT+QXBQsvAOdc3XymqDDPHx1BgPgsdAA5SIifona89YtRATDzw==", "license": "Apache-2.0" }, + "node_modules/dijkstrajs": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/dijkstrajs/-/dijkstrajs-1.0.3.tgz", + "integrity": "sha512-qiSlmBq9+BCdCA/L46dw8Uy93mloxsPSbwnm5yrKn2vMPiy8KyAskTF6zuV/j5BMsmOGZDPs7KjU+mjb670kfA==", + "license": "MIT" + }, "node_modules/dlv": { "version": "1.1.3", "resolved": "https://registry.npmmirror.com/dlv/-/dlv-1.1.3.tgz", @@ -2363,6 +2478,19 @@ "node": ">=8" } }, + "node_modules/find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "license": "MIT", + "dependencies": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/foreground-child": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.1.tgz", @@ -2426,6 +2554,15 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "license": "ISC", + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, "node_modules/glob": { "version": "10.5.0", "resolved": "https://registry.npmjs.org/glob/-/glob-10.5.0.tgz", @@ -2577,7 +2714,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true, "license": "MIT", "engines": { "node": ">=8" @@ -3021,6 +3157,18 @@ "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==", "license": "MIT" }, + "node_modules/locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "license": "MIT", + "dependencies": { + "p-locate": "^4.1.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/lru-cache": { "version": "11.5.2", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.2.tgz", @@ -3262,6 +3410,42 @@ "node": ">=12.20.0" } }, + "node_modules/p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "license": "MIT", + "dependencies": { + "p-try": "^2.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "license": "MIT", + "dependencies": { + "p-limit": "^2.2.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/package-json-from-dist": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz", @@ -3318,6 +3502,15 @@ "dev": true, "license": "MIT" }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/path-key": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", @@ -3448,6 +3641,15 @@ "node": ">= 6" } }, + "node_modules/pngjs": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/pngjs/-/pngjs-5.0.0.tgz", + "integrity": "sha512-40QW5YalBNfQo5yRYmiw7Yz6TKKVr3h6970B2YE+3fQpsWcrbj1PzJgxeJ19DRQjhMbKPIuMY8rFaXc8moolVw==", + "license": "MIT", + "engines": { + "node": ">=10.13.0" + } + }, "node_modules/postcss": { "version": "8.5.21", "resolved": "https://registry.npmmirror.com/postcss/-/postcss-8.5.21.tgz", @@ -3639,6 +3841,23 @@ "node": ">=6" } }, + "node_modules/qrcode": { + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/qrcode/-/qrcode-1.5.4.tgz", + "integrity": "sha512-1ca71Zgiu6ORjHqFBDpnSMTR2ReToX4l1Au1VFLyVeBTFavzQnv5JxMFr3ukHVKpSrSA2MCk0lNJSykjUfz7Zg==", + "license": "MIT", + "dependencies": { + "dijkstrajs": "^1.0.1", + "pngjs": "^5.0.0", + "yargs": "^15.3.1" + }, + "bin": { + "qrcode": "bin/qrcode" + }, + "engines": { + "node": ">=10.13.0" + } + }, "node_modules/queue-microtask": { "version": "1.2.3", "resolved": "https://registry.npmmirror.com/queue-microtask/-/queue-microtask-1.2.3.tgz", @@ -3709,6 +3928,15 @@ "license": "MIT", "optional": true }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/require-from-string": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", @@ -3719,6 +3947,12 @@ "node": ">=0.10.0" } }, + "node_modules/require-main-filename": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", + "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", + "license": "ISC" + }, "node_modules/resolve": { "version": "1.22.12", "resolved": "https://registry.npmmirror.com/resolve/-/resolve-1.22.12.tgz", @@ -3849,6 +4083,12 @@ "node": ">=10" } }, + "node_modules/set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==", + "license": "ISC" + }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -4834,6 +5074,12 @@ "node": ">= 8" } }, + "node_modules/which-module": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.1.tgz", + "integrity": "sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ==", + "license": "ISC" + }, "node_modules/why-is-node-running": { "version": "2.3.0", "resolved": "https://registry.npmmirror.com/why-is-node-running/-/why-is-node-running-2.3.0.tgz", @@ -5005,6 +5251,12 @@ "dev": true, "license": "MIT" }, + "node_modules/y18n": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz", + "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==", + "license": "ISC" + }, "node_modules/yaml": { "version": "2.8.2", "resolved": "https://mirrors.tencent.com/npm/yaml/-/yaml-2.8.2.tgz", @@ -5019,6 +5271,82 @@ "funding": { "url": "https://github.com/sponsors/eemeli" } + }, + "node_modules/yargs": { + "version": "15.4.1", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz", + "integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==", + "license": "MIT", + "dependencies": { + "cliui": "^6.0.0", + "decamelize": "^1.2.0", + "find-up": "^4.1.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^4.2.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^18.1.2" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/yargs-parser": { + "version": "18.1.3", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", + "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", + "license": "ISC", + "dependencies": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/yargs/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/yargs/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "license": "MIT" + }, + "node_modules/yargs/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/yargs/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } } } } diff --git a/frontend/package.json b/frontend/package.json index 98b9ffbe..568accf1 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -22,6 +22,7 @@ "marked": "^17.0.3", "pdfjs-dist": "^5.6.205", "pinia": "^3.0.4", + "qrcode": "^1.5.4", "vue": "^3.5.25", "vue-i18n": "^11.2.8", "vue-router": "^4.6.4", @@ -30,6 +31,7 @@ "devDependencies": { "@types/node": "^24.10.1", "@types/pdfjs-dist": "^2.10.377", + "@types/qrcode": "^1.5.6", "@vitejs/plugin-vue": "^6.0.2", "@vue/test-utils": "^2.4.11", "@vue/tsconfig": "^0.8.1", diff --git a/frontend/src/app/router/guards.ts b/frontend/src/app/router/guards.ts index ee80cf3c..810c6e32 100644 --- a/frontend/src/app/router/guards.ts +++ b/frontend/src/app/router/guards.ts @@ -2,7 +2,8 @@ * app/router/guards.ts * 全局路由守卫:认证、权限、旧 URL 兼容、document.title。 * 依赖:vue-router、config、auth.store、i18n、adminModulePath、isPublicPath、useMessage、contract-payment 权限常量。 - * 逻辑:beforeEach 做登录/管理员/功能权限校验;afterEach 将 meta.title(i18n key 或字面量)解析为浏览器标题。 + * 逻辑:beforeEach 做登录/管理员/功能权限校验,未登录跳登录页时携带 redirect 深链参数(登录后原样回跳); + * afterEach 将 meta.title(i18n key 或字面量)解析为浏览器标题。 */ import type { Router } from 'vue-router'; import { config } from '@/config'; @@ -11,6 +12,7 @@ import { useAuthStore } from '@/features/auth/stores/auth.store'; import { CONTRACT_PAYMENT_ACCESS_PERMISSION } from '@/features/contract-payment/constants'; import { isPublicPath } from '@/shared/constants/routes'; import { useMessage } from '@/shared/composables/useMessage'; +import { resolveSafeRedirect } from '@/shared/utils/redirect'; import i18n from '@/i18n'; /** @@ -57,7 +59,7 @@ function setupChunkLoadRecovery(router: Router): void { } /** - 注册全局 beforeEach / afterEach:登录、管理员、功能权限与页面标题。 + * 注册全局 beforeEach / afterEach:登录、管理员、功能权限与页面标题。 * 核心逻辑:requiresAdmin 仍静默回应用管理;requiresFeaturePermission 会提示后再跳转,避免用户以为入口损坏。 * @param router - 应用根路由实例 */ @@ -79,12 +81,15 @@ export function setupRouterGuards(router: Router): void { } if (to.path === '/login' && auth.isLoggedIn) { - next('/workspace/applications'); + // 已登录访问登录页:优先回跳 redirect 深链(如企微卡片点入),避免丢失原目标 + const redirect = resolveSafeRedirect(to.query.redirect); + next(redirect || '/workspace/applications'); return; } if (!auth.isLoggedIn && !isPublicPath(to.path)) { - next('/login'); + // 未登录:携带完整深链(含 query)跳登录页,登录成功后原样回跳,保证企微卡片“点击直达” + next({ path: '/login', query: { redirect: to.fullPath } }); return; } diff --git a/frontend/src/features/auth/composables/useLogin.ts b/frontend/src/features/auth/composables/useLogin.ts index 894fd19e..d891f00d 100644 --- a/frontend/src/features/auth/composables/useLogin.ts +++ b/frontend/src/features/auth/composables/useLogin.ts @@ -2,10 +2,12 @@ * features/auth/composables/useLogin.ts * 登录页编排层:组合认证、公告展示与 OAuth 回调,provide 给 LoginView 子组件。 * 依赖:auth.store、linked-nav.store、useLoginAuth、useLoginLanding。 - * 逻辑:登录成功后预取关联服务侧栏入口,减少进入 Chat/工作台后的入口闪现。 + * 逻辑:登录成功后优先按守卫携带的 redirect 深链回跳(企微提醒卡片“点击直达”场景), + * 无 redirect 时按 SSO continuation 或默认页落地;登录成功前预取关联服务侧栏入口,减少进入 Chat/工作台后的闪现。 */ import { onMounted, reactive } from 'vue'; import { useRouter, useRoute } from 'vue-router'; +import type { RouteLocationRaw } from 'vue-router'; import { useI18n } from 'vue-i18n'; import { config } from '@/config'; import { useTheme } from '@/shared/composables/useTheme'; @@ -16,6 +18,7 @@ import { DEFAULT_POST_LOGIN_AGENT_ID } from '@/features/workspace/types/workspac import { useWorkspaceLocale } from '@/features/workspace/composables/useWorkspaceLocale'; import { continuationLocation, readSsoContinuation } from '@/features/sso'; import { useLinkedNavStore } from '@/features/sso/stores/linked-nav.store'; +import { resolveSafeRedirect } from '@/shared/utils/redirect'; import { useLoginAuth } from './useLoginAuth'; import { useLoginLanding } from './useLoginLanding'; @@ -31,26 +34,34 @@ export function useLogin() { const deps = { t, locale, msg, router, route, setThemePreference, appliedTheme }; const landing = useLoginLanding(); + /** + * 解析本次登录的最终落地页。 + * AI 触发时机:密码/OAuth 登录成功后、以及已登录用户访问登录页时调用。 + * 核心逻辑:优先取守卫写入的 redirect 深链(如企微精益提醒卡片 /chat/16?training_type=lean_management), + * 保证“点卡片 → 登录 → 直达精益模块”;其次 SSO continuation;最后由调用方按登录方式给默认页。 + * redirect 已由 resolveSafeRedirect 做站内路径校验,防开放重定向(如 //evil.com)。 + * Returns:站内跳转目标(字符串路径或路由对象);无可回跳目标时返回空串。 + */ + const resolvePostLoginLocation = (): RouteLocationRaw | '' => { + const redirect = resolveSafeRedirect(route.query.redirect); + if (redirect) return redirect; + const continuation = readSsoContinuation(); + if (continuation) return continuationLocation(continuation); + return ''; + }; + const completePasswordLogin = async () => { authStore.syncFromStorage(); void linkedNav.ensureLoaded({ force: true }); - const continuation = readSsoContinuation(); - if (continuation) { - await router.replace(continuationLocation(continuation)); - return; - } - await router.replace(`/chat/${DEFAULT_POST_LOGIN_AGENT_ID}`); + const target = resolvePostLoginLocation(); + await router.replace(target || `/chat/${DEFAULT_POST_LOGIN_AGENT_ID}`); }; const completeOAuthLogin = async () => { authStore.syncFromStorage(); void linkedNav.ensureLoaded({ force: true }); - const continuation = readSsoContinuation(); - if (continuation) { - await router.replace(continuationLocation(continuation)); - return; - } - await router.replace('/workspace/applications'); + const target = resolvePostLoginLocation(); + await router.replace(target || '/workspace/applications'); }; const loginAuth = useLoginAuth(deps, { completePasswordLogin, completeOAuthLogin }); @@ -75,8 +86,9 @@ export function useLogin() { authStore.syncFromStorage(); if (authStore.isLoggedIn) { - const continuation = readSsoContinuation(); - await router.replace(continuation ? continuationLocation(continuation) : '/workspace/applications'); + // 已登录访问登录页:优先回跳 redirect 深链(如企微卡片点入),避免丢失原目标 + const target = resolvePostLoginLocation(); + await router.replace(target || '/workspace/applications'); return; } diff --git a/frontend/src/features/chat/components/TrainingShareModal.vue b/frontend/src/features/chat/components/TrainingShareModal.vue new file mode 100644 index 00000000..2325243c --- /dev/null +++ b/frontend/src/features/chat/components/TrainingShareModal.vue @@ -0,0 +1,160 @@ + + + + diff --git a/frontend/src/features/chat/components/TrainingWorkspacePanel.vue b/frontend/src/features/chat/components/TrainingWorkspacePanel.vue index 91a6e049..4ea72992 100644 --- a/frontend/src/features/chat/components/TrainingWorkspacePanel.vue +++ b/frontend/src/features/chat/components/TrainingWorkspacePanel.vue @@ -21,6 +21,7 @@ import { FileText, PlayCircle, RefreshCcw, + Share2, ShieldCheck, Target, User, @@ -30,6 +31,7 @@ import { } from 'lucide-vue-next'; import { useTrainingWorkspace } from '@/features/chat/composables/useTrainingWorkspace'; import FilePreviewModal from '@/shared/components/FilePreviewModal.vue'; +import TrainingShareModal from './TrainingShareModal.vue'; import { useMessage } from '@/shared/composables/useMessage'; import { resolveTrainingExamPdfGuide, type TrainingGuideLike } from '@/features/chat/training/trainingWorkspace.utils'; import { getMyTrainingConfig } from '@/features/chat/api/training.api'; @@ -293,33 +295,52 @@ const openWorkspaceView = (view: typeof workspace.activeView) => { setWorkspaceExpanded(true, true); }; -// [STEP] 企微提醒卡片深链支持:/chat/?training_type=lean_management&weekly_task_id= -// AI 触发时机:员工/HR 从企微“和信AI智能工作台”精益提醒卡片点入时,自动展开精益培训对应页签 -// (管理员进管理端看板、学员进学员侧学习页),无需手动点页签,保证卡片“点击直达”体验。 +// [STEP] 培训深链支持:/chat/?training_type=<培训类型code> +// 来源 1:企微“和信AI智能工作台”精益提醒卡片(training_type=lean_management&weekly_task_id=) +// 来源 2:员工培训分享链接(HR 在分享弹窗复制/生成二维码,员工扫码或点击后进入) +// AI 触发时机:员工/HR 从企微卡片或分享链接点入时,自动展开并定位到对应培训模块, +// 无需手动点页签,保证“点击直达”体验;精益卡片的管理员仍直达管理端精益看板。 const route = useRoute(); const router = useRouter(); -let leanJumpConsumed = false; +let trainingDeepLinkConsumed = false; watch( () => [workspace.isTrainingAgent, Boolean(props.currentUser), workspace.canManageTrainingWorkspace] as const, ([isTraining, loggedIn]) => { // 仅在培训 Agent 且登录态就绪后消费一次,避免身份权限异步未加载时误判视图归属 - if (!isTraining || !loggedIn || leanJumpConsumed) return; - leanJumpConsumed = true; - if (route.query.training_type !== 'lean_management') return; - if (workspace.canManageTrainingWorkspace) { + if (!isTraining || !loggedIn || trainingDeepLinkConsumed) return; + const targetTrainingType = String(route.query.training_type || '').trim(); + if (!targetTrainingType) return; + trainingDeepLinkConsumed = true; + if (targetTrainingType === 'lean_management' && workspace.canManageTrainingWorkspace) { + // 兼容企微精益提醒卡片:管理员直达管理端精益看板,学员进学员侧精益学习页。 workspace.activeView = 'admin'; workspace.hrTrainingTab = 'lean'; } else { + // 分享链接与其余培训类型:统一进员工培训页并定位到目标模块 + //(learnerTab 直接赋值即可,loadTrainingTypes 拉取后若类型有效会保留)。 workspace.activeView = 'learner'; - workspace.learnerTab = 'lean_management'; + workspace.learnerTab = targetTrainingType; } setWorkspaceExpanded(true, true); - // 消费后清理深链参数,避免刷新或分享链接时重复自动展开 + // 消费后清理深链参数,避免刷新或二次分享时重复自动展开 void router.replace({ query: { ...route.query, training_type: undefined, weekly_task_id: undefined } }); }, { immediate: true }, ); +/** + * 组装当前培训模块的分享深链(绝对地址),供分享弹窗展示链接与生成二维码。 + * AI 触发时机:有培训管理权限的用户点击“分享”时使用;必须带上 training_type 参数, + * 接收方登录后会自动定位到当前正在查看的培训模块。 + */ +const shareModalOpen = ref(false); +const trainingShareUrl = computed(() => { + const agentId = workspace.currentTrainingAgentId; + if (!agentId) return ''; + return `${window.location.origin}/chat/${agentId}?training_type=${encodeURIComponent(workspace.learnerTab)}`; +}); +const trainingShareName = computed(() => workspace.resolveTrainingTypeName(workspace.learnerTab)); + /** * 收起培训工作区并回到纯聊天页面。 * AI 触发时机:点击“收起工作区”时,必须立即恢复聊天消息区与输入栏,而不是仅折叠局部内容。 @@ -811,7 +832,7 @@ const currentSafetyStageText = computed(() => {
-
+
+ +
@@ -1906,6 +1937,13 @@ const currentSafetyStageText = computed(() => { :required-duration="workspace.currentViewingMaterialRequiredDuration" @update:modelValue="handlePreviewClose" /> + + +
diff --git a/frontend/src/features/chat/components/messages/ContractReviewResultCard.vue b/frontend/src/features/chat/components/messages/ContractReviewResultCard.vue index 92ffbce3..c0e91a18 100644 --- a/frontend/src/features/chat/components/messages/ContractReviewResultCard.vue +++ b/frontend/src/features/chat/components/messages/ContractReviewResultCard.vue @@ -25,7 +25,9 @@ const msg = useMessage(); const downloading = ref(false); const downloadingAnnotated = ref(false); const latestReview = ref(null); -let refreshTimer: ReturnType | undefined; +// 浏览器端 window.setTimeout 返回 number;勿用 ReturnType, +// 其在 @types/node 与 DOM lib 混用时会解析为 NodeJS.Timeout 导致 TS2322。 +let refreshTimer: number | undefined; let refreshing = false; let disposed = false; diff --git a/frontend/src/features/chat/shipping-review/useShippingOrderReview.ts b/frontend/src/features/chat/shipping-review/useShippingOrderReview.ts index cfe51453..6e8c197e 100644 --- a/frontend/src/features/chat/shipping-review/useShippingOrderReview.ts +++ b/frontend/src/features/chat/shipping-review/useShippingOrderReview.ts @@ -446,9 +446,11 @@ export function useShippingOrderReview(options: { const workflowProgressPolling = ref(false); let contextConversationId = ''; let contextItemNo = ''; - let progressPollTimer: ReturnType | null = null; - let stpCreatePollTimer: ReturnType | null = null; - let reparseCaseRefreshTimer: ReturnType | null = null; + // 浏览器端 window.setInterval 返回 number;勿用 ReturnType, + // 其在 @types/node 与 DOM lib 混用时会解析为 NodeJS.Timeout 导致 TS2322。 + let progressPollTimer: number | null = null; + let stpCreatePollTimer: number | null = null; + let reparseCaseRefreshTimer: number | null = null; /** * 应用后端返回的完整 Case 快照。 diff --git a/frontend/src/features/chat/shipping/useShippingProcessingWorkItem.ts b/frontend/src/features/chat/shipping/useShippingProcessingWorkItem.ts index 0185d17c..e6e3cdae 100644 --- a/frontend/src/features/chat/shipping/useShippingProcessingWorkItem.ts +++ b/frontend/src/features/chat/shipping/useShippingProcessingWorkItem.ts @@ -65,7 +65,9 @@ export function useShippingProcessingWorkItem( const projection = ref(null); const loading = ref(false); const error = ref(null); - let timer: ReturnType | null = null; + // 浏览器端 window.setTimeout 返回 number;勿用 ReturnType, + // 其在 @types/node 与 DOM lib 混用时会解析为 NodeJS.Timeout 导致 TS2322。 + let timer: number | null = null; let generation = 0; let stopped = false; let refreshInFlight: { no: string; promise: Promise } | null = null; diff --git a/frontend/src/locales/en/chat.json b/frontend/src/locales/en/chat.json index e00614d3..7a491c3b 100644 --- a/frontend/src/locales/en/chat.json +++ b/frontend/src/locales/en/chat.json @@ -997,6 +997,18 @@ "collapseWorkspace": "Collapse Workspace", "viewExamPdf": "View Exam PDF" }, + "share": { + "button": "Share", + "title": "Share Training", + "description": "Copy the link or download the QR code to share with employees. After signing in, they will land directly on the \"{name}\" training module.", + "linkLabel": "Training link", + "qrLabel": "Training QR code", + "copyLink": "Copy link", + "copied": "Link copied", + "copyFailed": "Copy failed. Please copy manually", + "downloadQr": "Download QR code", + "close": "Close" + }, "steps": { "video": "Watch Video", "summary": "Review Key Points", diff --git a/frontend/src/locales/th/chat.json b/frontend/src/locales/th/chat.json index 57691210..96dbce37 100644 --- a/frontend/src/locales/th/chat.json +++ b/frontend/src/locales/th/chat.json @@ -997,6 +997,18 @@ "collapseWorkspace": "ย่อพื้นที่ทำงาน", "viewExamPdf": "ดู PDF ข้อสอบ" }, + "share": { + "button": "แชร์", + "title": "แชร์การอบรม", + "description": "คัดลอกลิงก์หรือดาวน์โหลดคิวอาร์โค้ดเพื่อแชร์ให้พนักงาน เมื่อเข้าสู่ระบบแล้วจะไปยังโมดูลการอบรม \"{name}\" โดยอัตโนมัติ", + "linkLabel": "ลิงก์การอบรม", + "qrLabel": "คิวอาร์โค้ดการอบรม", + "copyLink": "คัดลอกลิงก์", + "copied": "คัดลอกลิงก์แล้ว", + "copyFailed": "คัดลอกไม่สำเร็จ โปรดคัดลอกด้วยตนเอง", + "downloadQr": "ดาวน์โหลดคิวอาร์โค้ด", + "close": "ปิด" + }, "steps": { "video": "ดูวิดีโอ", "summary": "ทบทวนความรู้", diff --git a/frontend/src/locales/zh-CN/chat.json b/frontend/src/locales/zh-CN/chat.json index 01deceea..1de7587d 100644 --- a/frontend/src/locales/zh-CN/chat.json +++ b/frontend/src/locales/zh-CN/chat.json @@ -1031,6 +1031,18 @@ "collapseWorkspace": "收起工作区", "viewExamPdf": "查看试题 PDF" }, + "share": { + "button": "分享", + "title": "分享培训", + "description": "复制链接或下载二维码发给员工,对方登录后自动进入「{name}」培训模块。", + "linkLabel": "培训链接", + "qrLabel": "培训二维码", + "copyLink": "复制链接", + "copied": "链接已复制", + "copyFailed": "复制失败,请手动复制", + "downloadQr": "下载二维码", + "close": "关闭" + }, "steps": { "video": "观看视频", "summary": "复盘知识点", diff --git a/frontend/src/locales/zh-TW/chat.json b/frontend/src/locales/zh-TW/chat.json index 3b3e523d..d9e7765e 100644 --- a/frontend/src/locales/zh-TW/chat.json +++ b/frontend/src/locales/zh-TW/chat.json @@ -997,6 +997,18 @@ "collapseWorkspace": "收起工作區", "viewExamPdf": "查看試題 PDF" }, + "share": { + "button": "分享", + "title": "分享培訓", + "description": "複製連結或下載二維碼發給員工,對方登入後自動進入「{name}」培訓模組。", + "linkLabel": "培訓連結", + "qrLabel": "培訓二維碼", + "copyLink": "複製連結", + "copied": "連結已複製", + "copyFailed": "複製失敗,請手動複製", + "downloadQr": "下載二維碼", + "close": "關閉" + }, "steps": { "video": "觀看影片", "summary": "複盤知識點", diff --git a/frontend/src/shared/utils/redirect.ts b/frontend/src/shared/utils/redirect.ts new file mode 100644 index 00000000..2cf251b5 --- /dev/null +++ b/frontend/src/shared/utils/redirect.ts @@ -0,0 +1,18 @@ +/** + * shared/utils/redirect.ts + * 登录回跳目标解析:企微提醒卡片等深链场景下,登录页按 redirect 参数原样回跳。 + * 依赖:无。被 app/router/guards.ts(守卫放行/跳转)与 features/auth(登录成功后回跳)共用。 + */ + +/** + * 校验并解析登录后回跳目标(企微提醒卡片等深链场景)。 + * AI 触发时机:路由守卫拦截未登录访问时,以及密码/OAuth 登录成功后决定跳转目标时调用。 + * 核心逻辑:仅接受站内相对路径(以 / 开头且不以 // 开头),拒绝外链与协议相对地址,防开放重定向。 + * @param raw - 待校验的 redirect 参数(可能为 string | string[] | undefined) + * @returns 安全的站内路径;不合法时返回 null + */ +export function resolveSafeRedirect(raw: unknown): string | null { + const value = Array.isArray(raw) ? String(raw[0] ?? '') : String(raw ?? ''); + if (!value.startsWith('/') || value.startsWith('//')) return null; + return value; +}