From d3e1c62043f5cca46fed4157394a3ca96f7f2d18 Mon Sep 17 00:00:00 2001 From: zzh <1368735060@qq.com> Date: Sat, 18 Jul 2026 23:13:23 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E8=BF=9B=E7=B3=BB=E7=BB=9F=E9=93=BE=E8=B7=AF=EF=BC=8C=E5=87=8F?= =?UTF-8?q?=E8=BD=BB=E9=A6=96=E5=B1=8F=E4=B8=8E=E8=BF=9B=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E9=98=BB=E5=A1=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 登录页延后重型依赖与角色动画,i18n 拆登录轻量包;进系统只等待动态路由与完整语言包,EP/VXE 后台预热。兼容登录响应带回 userInfo。 Co-authored-by: Cursor --- src/App.vue | 20 ++- .../rbac/generated/models/LoginResultDto.ts | 5 + src/hooks/locale.ts | 7 +- src/locale/bootstrap-en-US.ts | 10 ++ src/locale/bootstrap-zh-CN.ts | 10 ++ src/locale/index.ts | 63 ++++++++- src/main.ts | 42 ++++-- src/plugins/heavy-plugins.ts | 4 +- src/router/dynamic-router-state.ts | 16 +++ src/router/dynamicRouter.ts | 13 +- src/router/ensure-dynamic-router.ts | 48 +++++++ src/router/guard/permission.ts | 66 ++++----- src/store/modules/rbac-user.ts | 17 ++- src/utils/enter-system.ts | 55 +++++--- .../login/components/LoginLangToggle.vue | 2 +- .../login/components/pwd-login/index.vue | 33 ++--- src/views/login/components/wechat-login.vue | 16 +-- src/views/login/index.vue | 129 +++++++++++------- vite.config.ts | 33 +++-- 19 files changed, 395 insertions(+), 194 deletions(-) create mode 100644 src/locale/bootstrap-en-US.ts create mode 100644 src/locale/bootstrap-zh-CN.ts create mode 100644 src/router/ensure-dynamic-router.ts diff --git a/src/App.vue b/src/App.vue index 4cce815..404668d 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,16 +1,30 @@ diff --git a/src/views/login/components/pwd-login/index.vue b/src/views/login/components/pwd-login/index.vue index d80339e..26e2e29 100644 --- a/src/views/login/components/pwd-login/index.vue +++ b/src/views/login/components/pwd-login/index.vue @@ -121,10 +121,9 @@ import { import { OmsLoginType } from '@/api/rbac'; import { useRbacUserStore } from '@/store/modules/rbac-user'; import { setToken } from '@/utils/auth'; -import { useUserStore } from '@/store'; import { getDefaultHomePathByType } from '@/utils/login-portal'; -import { resolveAvatarUrl } from '@/utils/avatar'; -import { enterSystemAfterLogin } from '@/utils/enter-system'; +import { enterSystemAfterLogin, applyRbacUserToUserStore } from '@/utils/enter-system'; +import { ensureHeavyPlugins } from '@/plugins/heavy-plugins'; import { LOGIN_CHARACTERS_KEY, type LoginCharactersApi } from '../../composables/useLoginCharacters'; import { LOGIN_EXIT_KEY, type LoginExitApi } from '../../composables/useLoginExit'; import LoginLockLogo from '../LoginLockLogo.vue'; @@ -146,7 +145,6 @@ const emit = defineEmits<{ }>(); const router = useRouter(); -const userStore = useUserStore(); const rbacUserStore = useRbacUserStore(); const passwordInputRef = ref(null); @@ -273,6 +271,7 @@ function togglePasswordVisible() { function onAccountFocus() { accountError.value = ''; loginCharacters.value?.onAccountFocus(); + void ensureHeavyPlugins(); } function onAccountBlur() { @@ -282,6 +281,7 @@ function onAccountBlur() { function onPasswordFocus() { passwordError.value = ''; loginCharacters.value?.onPasswordFocus(); + void ensureHeavyPlugins(); } function onPasswordBlur() { @@ -341,48 +341,31 @@ async function handleSubmit() { setToken(rbacUserStore.token); } - const displayName = - userInfoData.name || userInfoData.account || fallbackAccount || String(userInfoData.id ?? ''); - const userInfo: any = { - account: userInfoData.account || fallbackAccount, - name: displayName, - avatar: resolveAvatarUrl(userInfoData.avatar), - email: userInfoData.email, - id: userInfoData.id, - accountId: userInfoData.id, - defaultModule: undefined, - moduleList: [], - }; - - userStore.setInfo(userInfo); + applyRbacUserToUserStore(userInfoData, fallbackAccount); const { redirect, ...othersQuery } = router.currentRoute.value.query; const redirectStr = redirect as string | undefined; const defaultHomePath = getDefaultHomePathByType(props.loginType); - const defaultTarget = { path: defaultHomePath }; - const redirectParams: any = { + const redirectParams: Record = { query: { ...othersQuery }, }; if (redirectStr) { if (redirectStr.startsWith('/')) { redirectParams.path = redirectStr; - delete redirectParams.name; } else { redirectParams.name = redirectStr; - delete redirectParams.path; } } else { - redirectParams.path = defaultTarget.path; - delete redirectParams.name; + redirectParams.path = defaultHomePath; } Message.success(t('login.form.login.success')); await nextTick(); await enterSystemAfterLogin({ target: redirectParams, - fallbackPath: defaultTarget.path, + fallbackPath: defaultHomePath, playExit: () => loginExit?.playExitAnimation() ?? Promise.resolve(), }); } else { diff --git a/src/views/login/components/wechat-login.vue b/src/views/login/components/wechat-login.vue index c904be3..0abca58 100644 --- a/src/views/login/components/wechat-login.vue +++ b/src/views/login/components/wechat-login.vue @@ -64,11 +64,9 @@ import { IconUser } from '@arco-design/web-vue/es/icon'; import { OmsLoginType } from '@/api/rbac'; import { getLoginQrcode, getWxLoginStatus, isWxLoginPendingError, wxLogin } from '@/api/wechat'; import { useRbacUserStore } from '@/store/modules/rbac-user'; -import { useUserStore } from '@/store'; import { setToken } from '@/utils/auth'; -import { resolveAvatarUrl } from '@/utils/avatar'; import { getDefaultHomePathByType } from '@/utils/login-portal'; -import { enterSystemAfterLogin } from '@/utils/enter-system'; +import { enterSystemAfterLogin, applyRbacUserToUserStore } from '@/utils/enter-system'; import { LOGIN_EXIT_KEY, type LoginExitApi } from '../composables/useLoginExit'; const QR_EXPIRE_MS = 600_000; @@ -78,7 +76,6 @@ const POLL_INTERVAL_MS = 1800; const { t } = useI18n(); const router = useRouter(); const rbacUserStore = useRbacUserStore(); -const userStore = useUserStore(); const loginExit = inject(LOGIN_EXIT_KEY, null); const emit = defineEmits<{ @@ -145,16 +142,7 @@ async function navigateAfterLogin() { setToken(rbacUserStore.token); } - userStore.setInfo({ - account: userInfoData.account, - name: userInfoData.name || userInfoData.account || String(userInfoData.id ?? ''), - avatar: resolveAvatarUrl(userInfoData.avatar), - email: userInfoData.email, - id: userInfoData.id, - accountId: userInfoData.id, - defaultModule: undefined, - moduleList: [], - }); + applyRbacUserToUserStore(userInfoData); const { redirect, ...othersQuery } = router.currentRoute.value.query; const redirectStr = redirect as string | undefined; diff --git a/src/views/login/index.vue b/src/views/login/index.vue index 31b95b2..8dfa351 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -17,7 +17,7 @@ @@ -64,15 +64,21 @@