From 73cab6a6ee69b4392f38a8aa47a91335b4fcca2c Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Thu, 4 Jun 2026 18:28:15 +0800 Subject: [PATCH] =?UTF-8?q?chore(auth):=20=E6=B8=85=E7=90=86=E5=B7=B2?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E7=9A=84=E9=82=80=E8=AF=B7=E7=A0=81=E7=BC=93?= =?UTF-8?q?=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/ui/certd-client/src/store/user/index.ts | 7 +++++++ packages/ui/certd-client/src/utils/util.invite.ts | 4 ++++ .../src/views/framework/oauth/oauth-callback.vue | 6 +++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/ui/certd-client/src/store/user/index.ts b/packages/ui/certd-client/src/store/user/index.ts index dfe3ecf41..bbc760587 100644 --- a/packages/ui/certd-client/src/store/user/index.ts +++ b/packages/ui/certd-client/src/store/user/index.ts @@ -15,6 +15,7 @@ import { resetAllStores, useAccessStore } from "/@/vben/stores"; import { useUserStore as vbenUserStore } from "/@/vben/stores/modules/user"; import { request } from "/@/api/service"; +import { inviteUtils } from "/@/utils/util.invite"; interface UserState { userInfo: Nullable; @@ -66,6 +67,9 @@ export const useUserStore = defineStore({ }, async register(user: RegisterReq) { await UserApi.register(user); + if (user.inviteCode) { + inviteUtils.clear(); + } notification.success({ message: "注册成功,请登录", }); @@ -85,6 +89,9 @@ export const useUserStore = defineStore({ let loginRes: any = null; if (loginType === "sms") { loginRes = await UserApi.loginBySms(params as SmsLoginReq); + if ((params as SmsLoginReq).inviteCode) { + inviteUtils.clear(); + } } else { loginRes = await UserApi.login(params as LoginReq); } diff --git a/packages/ui/certd-client/src/utils/util.invite.ts b/packages/ui/certd-client/src/utils/util.invite.ts index 37c0cf5b6..8daa1c769 100644 --- a/packages/ui/certd-client/src/utils/util.invite.ts +++ b/packages/ui/certd-client/src/utils/util.invite.ts @@ -41,6 +41,10 @@ export const inviteUtils = { } }, + clear() { + localStorage.removeItem(INVITE_STORAGE_KEY); + }, + captureFromLocation() { const hashQuery = window.location.hash?.split("?")[1] || ""; const search = window.location.search?.replace(/^\?/, "") || ""; diff --git a/packages/ui/certd-client/src/views/framework/oauth/oauth-callback.vue b/packages/ui/certd-client/src/views/framework/oauth/oauth-callback.vue index 3500b85a9..99f78a99b 100644 --- a/packages/ui/certd-client/src/views/framework/oauth/oauth-callback.vue +++ b/packages/ui/certd-client/src/views/framework/oauth/oauth-callback.vue @@ -100,7 +100,11 @@ async function goBindUser() { async function autoRegister() { //自动注册账号 - const res = await api.AutoRegister(oauthType, bindCode.value, inviteUtils.get()); + const inviteCode = inviteUtils.get(); + const res = await api.AutoRegister(oauthType, bindCode.value, inviteCode); + if (inviteCode) { + inviteUtils.clear(); + } //登录成功 userStore.onLoginSuccess(res); //跳转到首页