From 2fa2261949d555b8b5e07ececcc9578d89a9be2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?cls=5F=E5=AE=81=E6=B3=A2=E6=9C=AC=E6=9C=BA?= <908705107@qq.com> Date: Tue, 9 Jun 2026 17:10:45 +0800 Subject: [PATCH] Trim admin runtime imports --- backend-fastapi/core/menu/service.py | 6 +---- .../notification/NotificationPopup.vue | 2 ++ web/apps/web-ele/src/layouts/basic.vue | 26 ++++++++++++++----- web/apps/web-ele/src/preferences.ts | 1 + web/apps/web-ele/src/router/access.ts | 2 +- web/apps/web-ele/src/store/auth.ts | 3 ++- .../src/views/_core/authentication/login.vue | 2 +- .../_core/authentication/oauth-callback.vue | 5 ++-- .../web-ele/src/views/_core/user/index.vue | 4 +-- .../src/views/_core/user/modules/form.vue | 4 +-- 10 files changed, 34 insertions(+), 21 deletions(-) diff --git a/backend-fastapi/core/menu/service.py b/backend-fastapi/core/menu/service.py index 31edeef..ba9d9ef 100644 --- a/backend-fastapi/core/menu/service.py +++ b/backend-fastapi/core/menu/service.py @@ -17,7 +17,7 @@ from core.menu.schema import MenuCreate, MenuUpdate menu_cache = CacheManager(prefix="menu:") # 缓存key -AI_AGENT_ADMIN_MENU_CACHE_VERSION = "v3" +AI_AGENT_ADMIN_MENU_CACHE_VERSION = "v4" MENU_TREE_CACHE_KEY = f"tree:ai_agent_admin:{AI_AGENT_ADMIN_MENU_CACHE_VERSION}" USER_ROUTE_CACHE_PREFIX = f"user_route:ai_agent_admin:{AI_AGENT_ADMIN_MENU_CACHE_VERSION}:" @@ -35,13 +35,9 @@ AI_AGENT_ADMIN_MENU_NAMES = { "UserManagement", "SystemMenu", "SystemRole", - "SystemTools", - "系统工具", "Message", "AnnouncementList", "AnnouncementManage", - "userCenter", - "userSettings", } diff --git a/web/apps/web-ele/src/components/notification/NotificationPopup.vue b/web/apps/web-ele/src/components/notification/NotificationPopup.vue index bc86e77..e99278b 100644 --- a/web/apps/web-ele/src/components/notification/NotificationPopup.vue +++ b/web/apps/web-ele/src/components/notification/NotificationPopup.vue @@ -50,6 +50,7 @@ const emit = defineEmits<{ clear: []; clickChat: [ChatMessage]; makeAll: []; + open: []; readAnnouncement: [AnnouncementItem]; readMessage: [NotificationItem]; 'update:activeTab': ['announcement' | 'chat' | 'message']; @@ -91,6 +92,7 @@ const drawerListeners = { }; function openDrawer() { + emit('open'); drawerApi.open(); } diff --git a/web/apps/web-ele/src/layouts/basic.vue b/web/apps/web-ele/src/layouts/basic.vue index 4b37680..cf0dfdf 100644 --- a/web/apps/web-ele/src/layouts/basic.vue +++ b/web/apps/web-ele/src/layouts/basic.vue @@ -9,7 +9,6 @@ import type { WatchStopHandle } from 'vue'; import { computed, defineAsyncComponent, - onMounted, onUnmounted, ref, watch, @@ -61,14 +60,11 @@ const { destroyWatermark, updateWatermark } = useWatermark(); const router = useRouter(); let notificationApi: any = null; let chatApi: any = null; -let layoutActive = false; +let layoutActive = true; +let realtimeInitializing: Promise | null = null; +let realtimeInitialized = false; let stopRealtimeWatches: WatchStopHandle[] = []; -onMounted(() => { - layoutActive = true; - initRealtimeFeatures(); -}); - onUnmounted(() => { layoutActive = false; stopRealtimeWatches.forEach((stop) => stop()); @@ -78,6 +74,16 @@ onUnmounted(() => { }); async function initRealtimeFeatures() { + if (realtimeInitialized) return; + if (realtimeInitializing) return realtimeInitializing; + + realtimeInitializing = doInitRealtimeFeatures().finally(() => { + realtimeInitializing = null; + }); + await realtimeInitializing; +} + +async function doInitRealtimeFeatures() { const [notificationModule, chatModule] = await Promise.all([ import('#/composables/useNotification'), import('#/views/_core/chat/composables/useChat'), @@ -144,6 +150,7 @@ async function initRealtimeFeatures() { chatApi.connectChat(); chatApi.loadConversations(); chatApi.loadUnreadChatMessages(); + realtimeInitialized = true; } const menus = computed(() => [ @@ -228,6 +235,10 @@ function handleTabChange(tab: 'announcement' | 'chat' | 'message') { } } +function handleNotificationOpen() { + void initRealtimeFeatures(); +} + function handleChatClick(msg: ChatMessage) { // 新开tab跳转到聊天页面,带上会话ID const url = router.resolve( @@ -290,6 +301,7 @@ watch( @clear="handleNoticeClear" @click-chat="handleChatClick" @make-all="handleMakeAll" + @open="handleNotificationOpen" @read-message="handleNoticeRead" @read-announcement="handleAnnouncementRead" @view-all="handleViewAll" diff --git a/web/apps/web-ele/src/preferences.ts b/web/apps/web-ele/src/preferences.ts index 86c2342..c152d94 100644 --- a/web/apps/web-ele/src/preferences.ts +++ b/web/apps/web-ele/src/preferences.ts @@ -14,6 +14,7 @@ export const overridesPreferences = defineOverridesPreferences({ enableRefreshToken: true, accessMode: 'mixed', authPageLayout: 'panel-center', + defaultHomePath: '/control-center', layout: 'header-sidebar-nav', }, theme: { diff --git a/web/apps/web-ele/src/router/access.ts b/web/apps/web-ele/src/router/access.ts index 546b634..b19ca9b 100644 --- a/web/apps/web-ele/src/router/access.ts +++ b/web/apps/web-ele/src/router/access.ts @@ -6,7 +6,7 @@ import type { import { generateAccessible } from '@vben/access'; import { preferences } from '@vben/preferences'; -import { getAllMenusApi } from '#/api'; +import { getAllMenusApi } from '#/api/core/menu'; import { BasicLayout, IFrameView } from '#/layouts'; import { $t } from '#/locales'; import { useAppContextStore } from '#/store/app-context'; diff --git a/web/apps/web-ele/src/store/auth.ts b/web/apps/web-ele/src/store/auth.ts index 7babf7a..6f77751 100644 --- a/web/apps/web-ele/src/store/auth.ts +++ b/web/apps/web-ele/src/store/auth.ts @@ -9,7 +9,8 @@ import { resetAllStores, useAccessStore, useUserStore } from '@vben/stores'; import { defineStore } from 'pinia'; -import { getAccessCodesApi, getUserInfoApi, loginApi, logoutApi } from '#/api'; +import { getAccessCodesApi, loginApi, logoutApi } from '#/api/core/auth'; +import { getUserInfoApi } from '#/api/core/user'; import { $t } from '#/locales'; export const useAuthStore = defineStore('auth', () => { diff --git a/web/apps/web-ele/src/views/_core/authentication/login.vue b/web/apps/web-ele/src/views/_core/authentication/login.vue index 59d6274..4f3e9eb 100644 --- a/web/apps/web-ele/src/views/_core/authentication/login.vue +++ b/web/apps/web-ele/src/views/_core/authentication/login.vue @@ -20,7 +20,7 @@ import { getQQAuthorizeUrlApi, getWeChatAuthorizeUrlApi, getWeComAuthorizeUrlApi, -} from '#/api/core'; +} from '#/api/core/oauth'; import { getPreferencesConfigApi } from '#/api/core/ui-config'; import { useAuthStore } from '#/store'; diff --git a/web/apps/web-ele/src/views/_core/authentication/oauth-callback.vue b/web/apps/web-ele/src/views/_core/authentication/oauth-callback.vue index adfd90b..cc4e9e6 100644 --- a/web/apps/web-ele/src/views/_core/authentication/oauth-callback.vue +++ b/web/apps/web-ele/src/views/_core/authentication/oauth-callback.vue @@ -1,5 +1,5 @@