Trim admin runtime imports
This commit is contained in:
@@ -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",
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -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<void> | 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"
|
||||
|
||||
@@ -14,6 +14,7 @@ export const overridesPreferences = defineOverridesPreferences({
|
||||
enableRefreshToken: true,
|
||||
accessMode: 'mixed',
|
||||
authPageLayout: 'panel-center',
|
||||
defaultHomePath: '/control-center',
|
||||
layout: 'header-sidebar-nav',
|
||||
},
|
||||
theme: {
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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', () => {
|
||||
|
||||
@@ -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';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts" setup>
|
||||
import type { OAuthApi } from '#/api/core';
|
||||
import type { OAuthApi } from '#/api/core/oauth';
|
||||
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
@@ -8,7 +8,8 @@ import { useAccessStore, useUserStore } from '@vben/stores';
|
||||
|
||||
import { ElMessage } from 'element-plus';
|
||||
|
||||
import { getAccessCodesApi, oauthCallbackApi } from '#/api/core';
|
||||
import { getAccessCodesApi } from '#/api/core/auth';
|
||||
import { oauthCallbackApi } from '#/api/core/oauth';
|
||||
|
||||
defineOptions({ name: 'OAuthCallback' });
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts" setup>
|
||||
import type { User } from '#/api/core';
|
||||
import type { User } from '#/api/core/user';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
deleteUserApi,
|
||||
getUserListApi,
|
||||
resetUserPasswordApi,
|
||||
} from '#/api/core';
|
||||
} from '#/api/core/user';
|
||||
import { UserAvatar } from '#/components/user-avatar';
|
||||
import { useZqTable } from '#/components/zq-table';
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<script lang="ts" setup>
|
||||
import type { User } from '#/api/core';
|
||||
import type { User } from '#/api/core/user';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { $t } from '@vben/locales';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { createUserApi, updateUserApi } from '#/api/core';
|
||||
import { createUserApi, updateUserApi } from '#/api/core/user';
|
||||
import { ZqDrawer } from '#/components/zq-drawer';
|
||||
|
||||
import { getFormSchema } from '../data';
|
||||
|
||||
Reference in New Issue
Block a user