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:")
|
menu_cache = CacheManager(prefix="menu:")
|
||||||
|
|
||||||
# 缓存key
|
# 缓存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}"
|
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}:"
|
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",
|
"UserManagement",
|
||||||
"SystemMenu",
|
"SystemMenu",
|
||||||
"SystemRole",
|
"SystemRole",
|
||||||
"SystemTools",
|
|
||||||
"系统工具",
|
|
||||||
"Message",
|
"Message",
|
||||||
"AnnouncementList",
|
"AnnouncementList",
|
||||||
"AnnouncementManage",
|
"AnnouncementManage",
|
||||||
"userCenter",
|
|
||||||
"userSettings",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ const emit = defineEmits<{
|
|||||||
clear: [];
|
clear: [];
|
||||||
clickChat: [ChatMessage];
|
clickChat: [ChatMessage];
|
||||||
makeAll: [];
|
makeAll: [];
|
||||||
|
open: [];
|
||||||
readAnnouncement: [AnnouncementItem];
|
readAnnouncement: [AnnouncementItem];
|
||||||
readMessage: [NotificationItem];
|
readMessage: [NotificationItem];
|
||||||
'update:activeTab': ['announcement' | 'chat' | 'message'];
|
'update:activeTab': ['announcement' | 'chat' | 'message'];
|
||||||
@@ -91,6 +92,7 @@ const drawerListeners = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function openDrawer() {
|
function openDrawer() {
|
||||||
|
emit('open');
|
||||||
drawerApi.open();
|
drawerApi.open();
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import type { WatchStopHandle } from 'vue';
|
|||||||
import {
|
import {
|
||||||
computed,
|
computed,
|
||||||
defineAsyncComponent,
|
defineAsyncComponent,
|
||||||
onMounted,
|
|
||||||
onUnmounted,
|
onUnmounted,
|
||||||
ref,
|
ref,
|
||||||
watch,
|
watch,
|
||||||
@@ -61,14 +60,11 @@ const { destroyWatermark, updateWatermark } = useWatermark();
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
let notificationApi: any = null;
|
let notificationApi: any = null;
|
||||||
let chatApi: any = null;
|
let chatApi: any = null;
|
||||||
let layoutActive = false;
|
let layoutActive = true;
|
||||||
|
let realtimeInitializing: Promise<void> | null = null;
|
||||||
|
let realtimeInitialized = false;
|
||||||
let stopRealtimeWatches: WatchStopHandle[] = [];
|
let stopRealtimeWatches: WatchStopHandle[] = [];
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
layoutActive = true;
|
|
||||||
initRealtimeFeatures();
|
|
||||||
});
|
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
layoutActive = false;
|
layoutActive = false;
|
||||||
stopRealtimeWatches.forEach((stop) => stop());
|
stopRealtimeWatches.forEach((stop) => stop());
|
||||||
@@ -78,6 +74,16 @@ onUnmounted(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
async function initRealtimeFeatures() {
|
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([
|
const [notificationModule, chatModule] = await Promise.all([
|
||||||
import('#/composables/useNotification'),
|
import('#/composables/useNotification'),
|
||||||
import('#/views/_core/chat/composables/useChat'),
|
import('#/views/_core/chat/composables/useChat'),
|
||||||
@@ -144,6 +150,7 @@ async function initRealtimeFeatures() {
|
|||||||
chatApi.connectChat();
|
chatApi.connectChat();
|
||||||
chatApi.loadConversations();
|
chatApi.loadConversations();
|
||||||
chatApi.loadUnreadChatMessages();
|
chatApi.loadUnreadChatMessages();
|
||||||
|
realtimeInitialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const menus = computed(() => [
|
const menus = computed(() => [
|
||||||
@@ -228,6 +235,10 @@ function handleTabChange(tab: 'announcement' | 'chat' | 'message') {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleNotificationOpen() {
|
||||||
|
void initRealtimeFeatures();
|
||||||
|
}
|
||||||
|
|
||||||
function handleChatClick(msg: ChatMessage) {
|
function handleChatClick(msg: ChatMessage) {
|
||||||
// 新开tab跳转到聊天页面,带上会话ID
|
// 新开tab跳转到聊天页面,带上会话ID
|
||||||
const url = router.resolve(
|
const url = router.resolve(
|
||||||
@@ -290,6 +301,7 @@ watch(
|
|||||||
@clear="handleNoticeClear"
|
@clear="handleNoticeClear"
|
||||||
@click-chat="handleChatClick"
|
@click-chat="handleChatClick"
|
||||||
@make-all="handleMakeAll"
|
@make-all="handleMakeAll"
|
||||||
|
@open="handleNotificationOpen"
|
||||||
@read-message="handleNoticeRead"
|
@read-message="handleNoticeRead"
|
||||||
@read-announcement="handleAnnouncementRead"
|
@read-announcement="handleAnnouncementRead"
|
||||||
@view-all="handleViewAll"
|
@view-all="handleViewAll"
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ export const overridesPreferences = defineOverridesPreferences({
|
|||||||
enableRefreshToken: true,
|
enableRefreshToken: true,
|
||||||
accessMode: 'mixed',
|
accessMode: 'mixed',
|
||||||
authPageLayout: 'panel-center',
|
authPageLayout: 'panel-center',
|
||||||
|
defaultHomePath: '/control-center',
|
||||||
layout: 'header-sidebar-nav',
|
layout: 'header-sidebar-nav',
|
||||||
},
|
},
|
||||||
theme: {
|
theme: {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import type {
|
|||||||
import { generateAccessible } from '@vben/access';
|
import { generateAccessible } from '@vben/access';
|
||||||
import { preferences } from '@vben/preferences';
|
import { preferences } from '@vben/preferences';
|
||||||
|
|
||||||
import { getAllMenusApi } from '#/api';
|
import { getAllMenusApi } from '#/api/core/menu';
|
||||||
import { BasicLayout, IFrameView } from '#/layouts';
|
import { BasicLayout, IFrameView } from '#/layouts';
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
import { useAppContextStore } from '#/store/app-context';
|
import { useAppContextStore } from '#/store/app-context';
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ import { resetAllStores, useAccessStore, useUserStore } from '@vben/stores';
|
|||||||
|
|
||||||
import { defineStore } from 'pinia';
|
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';
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
export const useAuthStore = defineStore('auth', () => {
|
export const useAuthStore = defineStore('auth', () => {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import {
|
|||||||
getQQAuthorizeUrlApi,
|
getQQAuthorizeUrlApi,
|
||||||
getWeChatAuthorizeUrlApi,
|
getWeChatAuthorizeUrlApi,
|
||||||
getWeComAuthorizeUrlApi,
|
getWeComAuthorizeUrlApi,
|
||||||
} from '#/api/core';
|
} from '#/api/core/oauth';
|
||||||
import { getPreferencesConfigApi } from '#/api/core/ui-config';
|
import { getPreferencesConfigApi } from '#/api/core/ui-config';
|
||||||
import { useAuthStore } from '#/store';
|
import { useAuthStore } from '#/store';
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { OAuthApi } from '#/api/core';
|
import type { OAuthApi } from '#/api/core/oauth';
|
||||||
|
|
||||||
import { onMounted, ref } from 'vue';
|
import { onMounted, ref } from 'vue';
|
||||||
import { useRoute, useRouter } from 'vue-router';
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
@@ -8,7 +8,8 @@ import { useAccessStore, useUserStore } from '@vben/stores';
|
|||||||
|
|
||||||
import { ElMessage } from 'element-plus';
|
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' });
|
defineOptions({ name: 'OAuthCallback' });
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { User } from '#/api/core';
|
import type { User } from '#/api/core/user';
|
||||||
|
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@ import {
|
|||||||
deleteUserApi,
|
deleteUserApi,
|
||||||
getUserListApi,
|
getUserListApi,
|
||||||
resetUserPasswordApi,
|
resetUserPasswordApi,
|
||||||
} from '#/api/core';
|
} from '#/api/core/user';
|
||||||
import { UserAvatar } from '#/components/user-avatar';
|
import { UserAvatar } from '#/components/user-avatar';
|
||||||
import { useZqTable } from '#/components/zq-table';
|
import { useZqTable } from '#/components/zq-table';
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { User } from '#/api/core';
|
import type { User } from '#/api/core/user';
|
||||||
|
|
||||||
import { computed, ref } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
|
|
||||||
import { $t } from '@vben/locales';
|
import { $t } from '@vben/locales';
|
||||||
|
|
||||||
import { useVbenForm } from '#/adapter/form';
|
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 { ZqDrawer } from '#/components/zq-drawer';
|
||||||
|
|
||||||
import { getFormSchema } from '../data';
|
import { getFormSchema } from '../data';
|
||||||
|
|||||||
Reference in New Issue
Block a user