From 839ccddc95efed09c897254de2d5f7e5aef766bc Mon Sep 17 00:00:00 2001 From: DaxPay Dev Date: Sun, 28 Jun 2026 12:44:12 +0800 Subject: [PATCH] =?UTF-8?q?feat(authentication):=20=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E9=A1=B5=E6=96=B0=E5=A2=9E=E7=94=A8=E6=88=B7=E5=8D=8F=E8=AE=AE?= =?UTF-8?q?=E4=B8=8E=E9=9A=90=E7=A7=81=E6=94=BF=E7=AD=96=E5=8B=BE=E9=80=89?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 登录前必须勾选《用户协议》和《隐私政策》,未勾选时表单红字校验并触发协议行左右抖动动画;勾选状态在登录成功后持久化到 localStorage,后续登录自动勾选免重复操作;账号登录与第三方登录统一拦截,未同意均阻断并联动红字提示;新增用户协议/隐私政策占位页与公开路由,协议链接新标签页打开;同步 zh-CN/en-US 国际化文案 --- apps/daxpay-admin/src/router/routes/core.ts | 22 ++++ .../authentication/agreement-privacy.vue | 15 +++ .../_core/authentication/agreement-terms.vue | 15 +++ .../components/AuthThirdPartyPanel.vue | 9 ++ .../src/views/_core/authentication/login.vue | 114 +++++++++++++++++- .../src/langs/en-US/authentication.json | 8 ++ .../src/langs/zh-CN/authentication.json | 8 ++ 7 files changed, 189 insertions(+), 2 deletions(-) create mode 100644 apps/daxpay-admin/src/views/_core/authentication/agreement-privacy.vue create mode 100644 apps/daxpay-admin/src/views/_core/authentication/agreement-terms.vue diff --git a/apps/daxpay-admin/src/router/routes/core.ts b/apps/daxpay-admin/src/router/routes/core.ts index ce06f7599..daa229c6a 100644 --- a/apps/daxpay-admin/src/router/routes/core.ts +++ b/apps/daxpay-admin/src/router/routes/core.ts @@ -122,6 +122,28 @@ const coreRoutes: RouteRecordRaw[] = [ hideInMenu: true, }, }, + // 国际化:用户协议(公开页,登录前可访问) + { + name: 'AgreementTerms', + path: 'agreement/terms', + component: () => import('#/views/_core/authentication/agreement-terms.vue'), + meta: { + // 用户协议 + title: $t('authentication.termsTitle'), + hideInMenu: true, + }, + }, + // 国际化:隐私政策(公开页,登录前可访问) + { + name: 'AgreementPrivacy', + path: 'agreement/privacy', + component: () => import('#/views/_core/authentication/agreement-privacy.vue'), + meta: { + // 隐私政策 + title: $t('authentication.privacyTitle'), + hideInMenu: true, + }, + }, ], }, // 第三方绑定回调(独立路由,弹窗模式) diff --git a/apps/daxpay-admin/src/views/_core/authentication/agreement-privacy.vue b/apps/daxpay-admin/src/views/_core/authentication/agreement-privacy.vue new file mode 100644 index 000000000..d178586e3 --- /dev/null +++ b/apps/daxpay-admin/src/views/_core/authentication/agreement-privacy.vue @@ -0,0 +1,15 @@ + + + diff --git a/apps/daxpay-admin/src/views/_core/authentication/agreement-terms.vue b/apps/daxpay-admin/src/views/_core/authentication/agreement-terms.vue new file mode 100644 index 000000000..8f2f6a8ea --- /dev/null +++ b/apps/daxpay-admin/src/views/_core/authentication/agreement-terms.vue @@ -0,0 +1,15 @@ + + + diff --git a/apps/daxpay-admin/src/views/_core/authentication/components/AuthThirdPartyPanel.vue b/apps/daxpay-admin/src/views/_core/authentication/components/AuthThirdPartyPanel.vue index 884265ba4..6e08e2cc8 100644 --- a/apps/daxpay-admin/src/views/_core/authentication/components/AuthThirdPartyPanel.vue +++ b/apps/daxpay-admin/src/views/_core/authentication/components/AuthThirdPartyPanel.vue @@ -11,12 +11,16 @@ const props = withDefaults(defineProps(), { showDivider: true, mode: 'LOGIN', + // 登录前的协议勾选守卫(触发调用方表单校验,返回是否已同意) + ensureAgreement: undefined, }); interface Props { showDivider?: boolean; // 授权场景: LOGIN=未登录直接登录, BIND=已登录绑定 mode?: 'BIND' | 'LOGIN'; + // 登录前的协议勾选守卫(触发调用方表单校验,返回是否已同意) + ensureAgreement?: () => Promise; } // 已启用的第三方平台列表(由后端配置驱动) @@ -34,6 +38,11 @@ * 点击三方图标, 获取授权地址并跳转 */ async function handleSocialLogin(source: string) { + // 仅登录场景校验协议勾选,提示由父表单红字显示(绑定场景不校验) + if (props.mode === 'LOGIN' && props.ensureAgreement) { + const ok = await props.ensureAgreement(); + if (!ok) return; + } const { data: url } = await SocialApi.render(source, 'admin', props.mode); if (url) { // 跳转到第三方授权页, 授权后由后端回调处理并重定向回前端 /oauth-callback diff --git a/apps/daxpay-admin/src/views/_core/authentication/login.vue b/apps/daxpay-admin/src/views/_core/authentication/login.vue index 1657dfed8..eb77c6fc3 100644 --- a/apps/daxpay-admin/src/views/_core/authentication/login.vue +++ b/apps/daxpay-admin/src/views/_core/authentication/login.vue @@ -1,7 +1,7 @@