From cf32ae9a00460cb7c9c6aeb5e022da90702d187d Mon Sep 17 00:00:00 2001 From: maggieyyy <61950669+maggieyyy@users.noreply.github.com> Date: Mon, 21 Oct 2024 14:41:49 +0800 Subject: [PATCH] fix: Add MF --- .../components/aoplatform/RenderRoutes.tsx | 339 ++++++++++++------ .../businessEntry/src/consts/const.tsx | 333 +++++++++++++++++ .../businessEntry/src/hooks/pluginLoader.ts | 273 ++++++++++++++ .../businessEntry/src/utils/plugin.ts | 214 +++++++++++ .../packages/businessEntry/vite.config.ts | 30 +- ....timestamp-1722480612803-56fa594878983.mjs | 85 ----- .../components/aoplatform/RemotePlugin.tsx | 0 frontend/packages/common/src/const/const.tsx | 3 +- .../src/contexts/GlobalStateContext.tsx | 20 +- .../components/aoplatform/RenderRoutes.tsx | 139 ++++--- .../src/pages/system/SystemInsidePage.tsx | 2 +- frontend/packages/core/vite.config.ts | 2 +- .../src/pages/serviceHub/ServiceHubList.tsx | 2 +- .../openApi/src/pages/OpenApiList.tsx | 4 +- frontend/packages/openApi/tsconfig.json | 2 +- 15 files changed, 1154 insertions(+), 294 deletions(-) create mode 100644 frontend/packages/businessEntry/src/consts/const.tsx create mode 100644 frontend/packages/businessEntry/src/hooks/pluginLoader.ts create mode 100644 frontend/packages/businessEntry/src/utils/plugin.ts delete mode 100644 frontend/packages/businessEntry/vite.config.ts.timestamp-1722480612803-56fa594878983.mjs create mode 100644 frontend/packages/common/src/components/aoplatform/RemotePlugin.tsx diff --git a/frontend/packages/businessEntry/src/components/aoplatform/RenderRoutes.tsx b/frontend/packages/businessEntry/src/components/aoplatform/RenderRoutes.tsx index 76e06bfd..22fcb660 100644 --- a/frontend/packages/businessEntry/src/components/aoplatform/RenderRoutes.tsx +++ b/frontend/packages/businessEntry/src/components/aoplatform/RenderRoutes.tsx @@ -1,7 +1,7 @@ import { BrowserRouter as Router, Routes, Route, Navigate, Outlet } from 'react-router-dom'; import Login from "@core/pages/Login.tsx" import BasicLayout from '@common/components/aoplatform/BasicLayout'; -import {createElement, ReactElement,ReactNode,Suspense} from 'react'; +import {createElement, ReactElement,ReactNode,Suspense, useEffect, useState} from 'react'; import { v4 as uuidv4 } from 'uuid' import {App, Skeleton} from "antd"; import ApprovalPage from "@core/pages/approval/ApprovalPage.tsx"; @@ -12,8 +12,13 @@ import { TeamProvider } from '@core/contexts/TeamContext.tsx'; import SystemOutlet from '@core/pages/system/SystemOutlet.tsx'; import { DashboardProvider } from '@core/contexts/DashboardContext.tsx'; import { TenantManagementProvider } from '@market/contexts/TenantManagementContext.tsx'; +import React from 'react'; +import usePluginLoader from '@businessEntry/hooks/pluginLoader.ts'; +import Guide from '@core/pages/guide/Guide.tsx'; +import AiServiceOutlet from '@core/pages/aiService/AiServiceOutlet.tsx'; +import { AiServiceProvider } from '@core/contexts/AiServiceContext.tsx'; -type RouteConfig = { +export type RouteConfig = { path:string component?:ReactElement children?:(RouteConfig|false)[] @@ -46,52 +51,52 @@ const PUBLIC_ROUTES:RouteConfig[] = [ { path:'/', component:, - key: uuidv4(), + key: 'root', }, { path:'/login', component:, - key: uuidv4() + key: 'login' }, { path:'/', component:, - key: uuidv4(), + key: 'layout', children:[ { - path:'approval/*', - component:, - key:uuidv4() + path:'guide/*', + component:, + key:'guide' }, { path:'team', component:, - key: uuidv4(), + key: 'team', provider: TeamProvider, children:[ { path:'', - key: uuidv4(), + key: 'teamList', component: }, { path:'list', - key: uuidv4(), + key: 'teamList2', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/team/TeamList.tsx')) }, { path:'inside/:teamId', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/team/TeamInsidePage.tsx')), - key: uuidv4(), + key: 'teamInside', children:[ { path:'member', - key: uuidv4(), + key: 'teamMember', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/team/TeamInsideMember.tsx')), }, { path:'setting', - key: uuidv4(), + key: 'teamSetting', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/team/TeamConfig.tsx')), }, ] @@ -101,57 +106,57 @@ const PUBLIC_ROUTES:RouteConfig[] = [ { path:'service', component:, - key: uuidv4(), + key: 'restService', provider: SystemProvider, children:[ { path:'', - key:uuidv4(), + key:'restServiceList', component: }, { path:'list', - key: uuidv4(), + key: 'restServiceList2', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/SystemList.tsx')), }, { path:'list/:teamId', - key: uuidv4(), + key: 'restServiceList3', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/SystemList.tsx')), }, { path:':teamId', component:, - key: uuidv4(), + key: 'restServiceInside', children:[ { path:'inside/:serviceId', - key: uuidv4(), + key: 'restServiceInside2', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/SystemInsidePage.tsx')), children:[ { path:'api', - key: uuidv4(), + key: 'restServiceInsideApi', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/api/SystemInsideApiDocument.tsx')), }, { - path:'router', - key: uuidv4(), + path:'route', + key: 'restServiceInsideRoute', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/api/SystemInsideRouterList')), }, { path:'upstream', - key: uuidv4(), + key: 'restServiceInsideUpstream', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/upstream/SystemInsideUpstreamContent.tsx')), }, { path:'document', - key: uuidv4(), + key: 'restServiceInsideDocument', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/SystemInsideDocument.tsx')), }, { path:'subscriber', - key: uuidv4(), + key: 'restServiceInsideSubscriber', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/SystemInsideSubscriber.tsx')), children:[ @@ -159,17 +164,17 @@ const PUBLIC_ROUTES:RouteConfig[] = [ }, { path:'approval', - key: uuidv4(), + key: 'restServiceInsideApproval', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/approval/SystemInsideApproval.tsx')), children:[ { path:'', - key: uuidv4(), + key: 'restServiceInsideApprovalList', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/approval/SystemInsideApprovalList.tsx')), }, { path:'*', - key: uuidv4(), + key: 'restServiceInsideApprovalList2', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/approval/SystemInsideApprovalList.tsx')), } ] @@ -177,30 +182,30 @@ const PUBLIC_ROUTES:RouteConfig[] = [ { path:'topology', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/SystemTopology.tsx')), - key: uuidv4(), + key: 'systemTopology', children:[ ] }, { path:'publish', - key: uuidv4(), + key: 'systemPublish', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/publish/SystemInsidePublish.tsx')), children:[ { path:'', - key: uuidv4(), + key: 'systemPublishList', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/publish/SystemInsidePublishList.tsx')), }, { path:'*', - key: uuidv4(), + key: 'systemPublishList2', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/publish/SystemInsidePublishList.tsx')), } ] }, { path:'setting', - key: uuidv4(), + key: 'systemConfig', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/SystemConfig.tsx')), children:[ @@ -211,39 +216,160 @@ const PUBLIC_ROUTES:RouteConfig[] = [ ] } ] - },{ + }, + + { + path:'aiservice', + component:, + key: 'aiService', + provider: AiServiceProvider, + children:[ + { + path:'', + key:'aiServiceList', + component: + }, + { + path:'list', + key: 'aiServiceList2', + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/aiService/AiServiceList.tsx')), + }, + { + path:'list/:teamId', + key: 'aiServiceList3', + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/aiService/AiServiceList.tsx')), + }, + { + path:':teamId', + component:, + key: 'aiServiceInside', + children:[ + { + path:'inside/:serviceId', + key: '', + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/aiService/AiServiceInsidePage.tsx')), + children:[ + { + path:'api', + key: 'aiServiceInsideApi', + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/aiService/api/AiServiceInsideApiDocument')), + }, + { + + path:'route/create', + key: 'aiServiceInsideRoute', + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/aiService/api/AiServiceInsideRouterCreate')), + }, + { + + path:'route/:routeId', + key: 'aiServiceInsideRoute2', + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/aiService/api/AiServiceInsideRouterCreate')), + }, + { + path:'route', + key: 'aiServiceInsideList', + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/aiService/api/AiServiceInsideRouterList')), + }, + { + path:'document', + key: 'aiServiceInsideDocument', + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/aiService/AiServiceInsideDocument.tsx')), + }, + { + path:'subscriber', + key: 'aiServiceInsideSubscriber', + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/aiService/AiServiceInsideSubscriber.tsx')), + children:[ + + ] + }, + { + path:'approval', + key: 'aiServiceInsideApproval', + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/aiService/approval/AiServiceInsideApproval')), + children:[ + { + path:'', + key: 'aiServiceInsideApprovalList', + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/aiService/approval/AiServiceInsideApprovalList')), + }, + { + path:'*', + key: 'aiServiceInsideApprovalList', + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/aiService/approval/AiServiceInsideApprovalList')), + } + ] + }, + { + path:'publish', + key: 'aiServiceInsidePublish', + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/aiService/publish/AiServiceInsidePublish')), + children:[ + { + path:'', + key: 'aiServiceInsidePublishList', + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/aiService/publish/AiServiceInsidePublishList')), + }, + { + path:'*', + key: 'aiServiceInsidePublishList2', + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/aiService/publish/AiServiceInsidePublishList')), + } + ] + }, + { + path:'setting', + key: 'aiServiceSetting', + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/aiService/AiServiceConfig.tsx')), + children:[ + + ] + }, + ] + } + ] + } + ] + }, + { path:'datasourcing', - key: uuidv4(), + key: 'dataSourcing', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/partitions/PartitionInsideDashboardSetting.tsx')), }, { path:'cluster', - key: uuidv4(), + key: 'cluster', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/partitions/PartitionInsideCluster.tsx')), }, + { + path:'aisetting', + key: 'aiSetting', + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/aiSetting/AiSettingList.tsx')), + }, { path:'cert', - key: uuidv4(), + key: 'cert', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/partitions/PartitionInsideCert.tsx')), }, { path:'serviceHub', component:, - key:uuidv4(), + key:'serviceHub', children:[ { path:'', - key: uuidv4(), + key: 'serviceHubList', component: }, { path:'list', - key:uuidv4(), + key:'serviceHubList2', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@market/pages/serviceHub/ServiceHubList.tsx')), }, { path:'detail/:serviceId', - key:uuidv4(), + key:'serviceHubDetail', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@market/pages/serviceHub/ServiceHubDetail.tsx')), }] }, @@ -256,184 +382,173 @@ const PUBLIC_ROUTES:RouteConfig[] = [ path:'tenantManagement', component:, provider:TenantManagementProvider, - key:uuidv4(), + key:'tenantManagement', children:[ { path:'', - key:uuidv4(), + key:'tenantManagementList', component: }, { path:':teamId/inside/:appId', - key:uuidv4(), + key:'tenantManagementInside', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@market/pages/serviceHub/management/ManagementInsidePage.tsx')), children:[ { path:'service', - key:uuidv4(), + key:'tenantManagementInsideService', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@market/pages/serviceHub/management/ManagementInsideService.tsx')), }, { path:'authorization', - key:uuidv4(), + key:'tenantManagementInsideAuthorization', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@market/pages/serviceHub/management/ManagementInsideAuth.tsx')), }, { path:'setting', - key:uuidv4(), + key:'tenantManagementSetting', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@market/pages/serviceHub/management/ManagementAppSetting.tsx')), }, ] }, { path:'list', - key:uuidv4(), + key:'serviceHubManagementList', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@market/pages/serviceHub/management/ServiceHubManagement.tsx')), }, { path:'list/:teamId', - key:uuidv4(), + key:'serviceHubManagementList2', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@market/pages/serviceHub/management/ServiceHubManagement.tsx')), }, ] }, { path:'member', - key:uuidv4(), + key:'member', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/member/MemberPage.tsx')), children:[ { path:'', - key:uuidv4(), + key:'memberList', component: }, { path:'list', - key:uuidv4(), + key:'memberList2', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/member/MemberList.tsx')), }, { path:'list/:memberGroupId', - key:uuidv4(), + key:'memberList3', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/member/MemberList.tsx')), } ] }, { path:'role', - key:uuidv4(), - component:, + key:'role', + component:, children:[ { path: '', - key: uuidv4(), + key: 'roleList', component: }, { path:'list', - key:uuidv4(), + key:'roleList2', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/role/RoleList.tsx')), - }, - { - path:':roleType/config', - key:uuidv4(), - lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/role/RoleConfig.tsx')), - }, - { + },{ path:':roleType/config/:roleId', - key:uuidv4(), + key:'roleConfig', + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/role/RoleConfig.tsx')), + },{ + path:':roleType/config', + key:'roleConfig2', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/role/RoleConfig.tsx')), } ] }, - APP_MODE === 'pro' &&{ - path:'openapi', - lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@openApi/pages/OpenApiList.tsx')), - key:uuidv4(), - }, { - path:'assets', - component:

设计中

, - key:uuidv4() - }, - APP_MODE === 'pro' &&{ path:'analytics', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@dashboard/pages/Dashboard.tsx')), - key:uuidv4(), + key:'analytics', children:[ { - path:':dashboardType', - component:, - key:uuidv4(), - provider:DashboardProvider, - children:[ - { - path:'list', - lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@dashboard/pages/DashboardList.tsx')), - key:uuidv4() - }, - { - path:'detail/:dashboardDetailId', - lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@dashboard/pages/DashboardDetail.tsx')), - key:uuidv4() - }, - ] + path:'total', + key:'analytics2', + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@dashboard/pages/DashboardTotal.tsx')), }, ] }, - { - path:'systemrunning', - lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@systemRunning/pages/SystemRunning.tsx')), - key:uuidv4() - }, { path:'template/:moduleId', - lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '../../../../common/src/components/aoplatform/intelligent-plugin/IntelligentPluginList.tsx')), - key:uuidv4() + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@common/components/aoplatform/intelligent-plugin/IntelligentPluginList.tsx')), + key:'intelligentPlugin' }, { path:'logsettings/*', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/logsettings/LogSettings.tsx')), - key: uuidv4(), + key: 'logSettings', children:[{ path:'template/:moduleId', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@common/components/aoplatform/intelligent-plugin/IntelligentPluginList.tsx')), - key:uuidv4() + key:'logSettings2' }] }, APP_MODE ==='pro' && { path:'resourcesettings/*', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/resourcesettings/ResourceSettings.tsx')), - key: uuidv4(), + key: 'resourceSettings', children:[{ path:'template/:moduleId', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@common/components/aoplatform/intelligent-plugin/IntelligentPluginList.tsx')), - key:uuidv4() + key:'resourceSettings2' }] - + }, { path:'userProfile/*', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/userProfile/UserProfile.tsx')), - key:uuidv4(), + key:'userProfile', children:[{ path:'changepsw', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/userProfile/ChangePsw.tsx')), - key:uuidv4() + key:'changePsw' }] - } + }, + APP_MODE === 'pro' &&{ + path:'openapi', + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@openApi/pages/OpenApiList.tsx')), + key:'openApi', + }, + { + path:'systemrunning', + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@systemRunning/pages/SystemRunning.tsx')), + key:'systemRunning' + }, ] - }, + } ] const RenderRoutes = ()=> { + const { loadPlugins } = usePluginLoader() + const [routeConfig , setRouteConfig] = useState(PUBLIC_ROUTES) + useEffect(()=>{ + loadPlugins().then((res)=>{ + console.log('newRouteConfig',res) + setRouteConfig(res as RouteConfig[]) + }) + },[]) + return ( - {generateRoutes(PUBLIC_ROUTES)} - + {generateRoutes(routeConfig)} + ) @@ -476,7 +591,7 @@ const generateRoutes = (routerConfig: RouteConfig[]) => { } // 保护的路由组件 -function ProtectedRoute() { +export function ProtectedRoute() { const {state} = useGlobalContext() return state.isAuthenticated? : ; } diff --git a/frontend/packages/businessEntry/src/consts/const.tsx b/frontend/packages/businessEntry/src/consts/const.tsx new file mode 100644 index 00000000..85248e36 --- /dev/null +++ b/frontend/packages/businessEntry/src/consts/const.tsx @@ -0,0 +1,333 @@ +import { DashboardProvider } from '@core/contexts/DashboardContext'; +import { SystemProvider } from '@core/contexts/SystemContext'; +import { TeamProvider } from '@core/contexts/TeamContext'; +import Login from '@core/pages/Login'; +import SystemOutlet from '@core/pages/system/SystemOutlet'; +import { TenantManagementProvider } from '@market/contexts/TenantManagementContext'; +import { lazy } from 'react'; +import { Outlet, Navigate } from 'react-router-dom'; +import { v4 as uuidv4 } from 'uuid'; +import {ProtectedRoute} from '@businessEntry/components/aoplatform/RenderRoutes'; +import Guide from '@core/pages/guide/Guide'; + + // 内置插件与对应组件/模块 + export const routerMap:Map = new Map([ + ['basicLayout', { type: 'component', component: }], + ['navHidden', { type: 'component', component: }], + ['login', { type: 'component', component: }], + ['guide',{ + type:'component', + component: + }], + ['team', {type: 'module', + component:, + key: 'team', + provider: TeamProvider, + children:[ + { + path:'', + key: 'teamList', + component: + }, + { + path:'list', + key: 'teamList2', + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/team/TeamList.tsx')) + }, + { + path:'inside/:teamId', + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/team/TeamInsidePage.tsx')), + key: 'teamInside', + children:[ + { + path:'member', + key: 'teamMember', + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/team/TeamInsideMember.tsx')), + }, + { + path:'setting', + key: 'teamSetting', + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/team/TeamConfig.tsx')), + }, + ] + } + ] + }], + ['service', { + type: 'module', + path:'service', + component:, + key: uuidv4(), + provider: SystemProvider, + children:[ + { + path:'', + key:uuidv4(), + component: + }, + { + path:'list', + key: uuidv4(), + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/SystemList.tsx')), + }, + { + path:'list/:teamId', + key: uuidv4(), + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/SystemList.tsx')), + }, + { + path:':teamId', + component:, + key: uuidv4(), + children:[ + { + path:'inside/:serviceId', + key: uuidv4(), + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/SystemInsidePage.tsx')), + children:[ + { + path:'api', + key: uuidv4(), + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/api/SystemInsideApiDocument.tsx')), + }, + { + path:'router', + key: uuidv4(), + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/api/SystemInsideRouterList')), + }, + { + path:'upstream', + key: uuidv4(), + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/upstream/SystemInsideUpstreamContent.tsx')), + }, + { + path:'document', + key: uuidv4(), + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/SystemInsideDocument.tsx')), + }, + { + path:'subscriber', + key: uuidv4(), + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/SystemInsideSubscriber.tsx')), + children:[ + + ] + }, + { + path:'approval', + key: uuidv4(), + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/approval/SystemInsideApproval.tsx')), + children:[ + { + path:'', + key: uuidv4(), + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/approval/SystemInsideApprovalList.tsx')), + }, + { + path:'*', + key: uuidv4(), + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/approval/SystemInsideApprovalList.tsx')), + } + ] + }, + { + path:'topology', + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/SystemTopology.tsx')), + key: uuidv4(), + children:[ + ] + }, + { + path:'publish', + key: uuidv4(), + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/publish/SystemInsidePublish.tsx')), + children:[ + { + path:'', + key: uuidv4(), + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/publish/SystemInsidePublishList.tsx')), + }, + { + path:'*', + key: uuidv4(), + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/publish/SystemInsidePublishList.tsx')), + } + ] + }, + { + path:'setting', + key: uuidv4(), + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/SystemConfig.tsx')), + children:[ + + ] + }, + ] + } + ] + } + ] + }], + ['datasourcing', { type: 'module', + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/partitions/PartitionInsideDashboardSetting.tsx')) + }], + ['cluster', { type: 'module', + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/partitions/PartitionInsideCluster.tsx')), + }], + ['cert', { type: 'module', + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/partitions/PartitionInsideCert.tsx')), + }], + + ['serviceHub', { + type: 'module', + component:, + key:uuidv4(), + children:[ + { + path:'', + key: uuidv4(), + component: + }, + { + path:'list', + key:uuidv4(), + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@market/pages/serviceHub/ServiceHubList.tsx')), + }, + { + path:'detail/:serviceId', + key:uuidv4(), + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@market/pages/serviceHub/ServiceHubDetail.tsx')), + }] + }], + + ['servicecategories', { type: 'module', + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/serviceCategory/ServiceCategory.tsx')), + }], + + ['tenantManagement', { type: 'module', + component:, + provider:TenantManagementProvider, + key:uuidv4(), + children:[ + { + path:'', + key:uuidv4(), + component: + }, + { + path:':teamId/inside/:appId', + key:uuidv4(), + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@market/pages/serviceHub/management/ManagementInsidePage.tsx')), + children:[ + { + path:'service', + key:uuidv4(), + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@market/pages/serviceHub/management/ManagementInsideService.tsx')), + }, + { + path:'authorization', + key:uuidv4(), + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@market/pages/serviceHub/management/ManagementInsideAuth.tsx')), + }, + { + path:'setting', + key:uuidv4(), + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@market/pages/serviceHub/management/ManagementAppSetting.tsx')), + }, + ] + }, + { + path:'list', + key:uuidv4(), + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@market/pages/serviceHub/management/ServiceHubManagement.tsx')), + }, + { + path:'list/:teamId', + key:uuidv4(), + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@market/pages/serviceHub/management/ServiceHubManagement.tsx')), + }, + ]}], + ['member', { type: 'module', + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/member/MemberPage.tsx')), + children:[ + { + path:'', + key:uuidv4(), + component: + }, + { + path:'list', + key:uuidv4(), + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/member/MemberList.tsx')), + }, + { + path:'list/:memberGroupId', + key:uuidv4(), + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/member/MemberList.tsx')), + } + ], + }], + ['role', { type: 'module', + component:, + children:[ + { + path: '', + key: uuidv4(), + component: + }, + { + path:'list', + key:uuidv4(), + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/role/RoleList.tsx')), + }, + { + path:':roleType/config', + key:uuidv4(), + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/role/RoleConfig.tsx')), + }, + { + path:':roleType/config/:roleId', + key:uuidv4(), + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/role/RoleConfig.tsx')), + } + ] + }], + ['openapi', { type: 'module', + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@openApi/pages/OpenApiList.tsx')), + }], + ['analytics', { type: 'module', + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@dashboard/pages/Dashboard.tsx')), + key:uuidv4(), + children:[ + { + path:':dashboardType', + component:, + key:uuidv4(), + provider:DashboardProvider, + children:[ + { + path:'list', + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@dashboard/pages/DashboardList.tsx')), + key:uuidv4() + }, + { + path:'detail/:dashboardDetailId', + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@dashboard/pages/DashboardDetail.tsx')), + key:uuidv4() + }, + ] + }, + ] + }], + ['systemrunning', { type: 'module', + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@systemRunning/pages/SystemRunning.tsx')), + }], + ['userProfile', { type: 'module', + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/userProfile/UserProfile.tsx')), + key:uuidv4(), + children:[{ + path:'changepsw', + lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/userProfile/ChangePsw.tsx')), + key:uuidv4() + }]}] + ]) \ No newline at end of file diff --git a/frontend/packages/businessEntry/src/hooks/pluginLoader.ts b/frontend/packages/businessEntry/src/hooks/pluginLoader.ts new file mode 100644 index 00000000..8d13bc44 --- /dev/null +++ b/frontend/packages/businessEntry/src/hooks/pluginLoader.ts @@ -0,0 +1,273 @@ +import { useState } from "react"; +import { useGlobalContext } from "@common/contexts/GlobalStateContext"; +import { App } from "antd"; +import { ApiparkPluginDriver as apipark, CoreObj, generateRemoteModuleTemplate, loadRemoteModule, validateExportLifecycle } from "@businessEntry/utils/plugin"; +import { useFetch } from "@common/hooks/http"; +import { RouteConfig } from "@businessEntry/components/aoplatform/RenderRoutes"; +import { routerMap } from "@businessEntry/consts/const"; + +const usePluginLoader = () => { + const [modules, setModules] = useState(new Map()); + const [executeList, setExecuteList] = useState([]); + const [baseHref, setBaseHref] = useState(''); + const [redirectUrl, setRedirectUrl] = useState(''); + const {fetchData} = useFetch(); + const pluginProvider = useGlobalContext(); + const {state, dispatch,pluginEventHub,pluginSlotHubService:pluginSlotHub} = pluginProvider + const { finalRouterConfig, setFinalRouterConfig} = useState([]) + const {message:messageService, modal:modalService} = App.useApp(); + + const getModule = (routerPrefix:string, specific = false) => { + if (routerPrefix.startsWith('/')) { + routerPrefix = routerPrefix.substring(1); + } + if (specific) { + return modules.get(routerPrefix); + } + let matchedModule = null; + let matchedLength = 0; + + modules.forEach((value, key) => { + if (routerPrefix.startsWith(key) && key.length > matchedLength) { + matchedModule = value; + matchedLength = key.length; + } + }); + return matchedModule; + }; + + const loadModule = async (routerPrefix: string, pluginName: any, exposedModule: string , pluginPath: any) => { + if (!modules.get(routerPrefix)) { + try { + const Module = await loadRemoteModule(generateRemoteModuleTemplate(pluginName, exposedModule, pluginPath)); + setModules(prevModules => new Map(prevModules).set(routerPrefix, Module)); + if (!validateExportLifecycle(Module)) { + console.error('需要导出插件生命周期函数'); + return; + } + await Module.bootstrap?.({ + pluginProvider, + pluginEventHub: pluginEventHub, + pluginSlotHub + }); + return Module[exposedModule]; + } catch (error) { + console.error('导入插件失败:', error); + } + } + return getModule(routerPrefix, true)[exposedModule]; + }; + + const loadExecutedPlugin = async () => { + for (const plugin of executeList) { + try { + const Module = await loadRemoteModule(generateRemoteModuleTemplate(plugin.name, plugin?.expose || 'Bootstrap', plugin.path || `${DEFAULT_LOCAL_PLUGIN_PATH}${plugin.name}/apipark.js`)); + const bootstrap = Module.bootstrap; + if (!bootstrap) { + console.warn('立即执行插件未导出Bootstrap模块或bootstrap函数'); + } else { + await bootstrap({ + pluginEventHub, + pluginSlotHub, + pluginProvider, + platformProvider:null, + closeModal, + messageService, + modalService, + apiService:fetchData + }); + } + } catch (error) { + console.error('执行插件失败:', error); + } + } + }; + + // TODO 暂未找到关闭弹窗的全局方法 + const closeModal = () => { + }; + + const loadPlugins = () => { + return new Promise((resolve) => { + const routerConfig: RouteConfig[] = []; + apipark['builtIn'].default({ routerConfig } as CoreObj); + // Assuming you have a way to reset router config in React + // resetRouterConfig(routerConfig); + console.log(routerConfig) + // setFinalRouterConfig(routerConfig) + installPlugin(routerConfig, executeList).then((res)=>{ + resolve(res) + }) + // .then(async () => { + // // resetRouterConfig(routerConfig); + // await loadExecutedPlugin(); + // resolve(true); + // }); + }); + }; + + const installPlugin = (routerConfig: any[], executeList: never[]) => { + return new Promise((resolve, reject) => { + // fetchData('system/plugins',{method:'GET'}).then((resp) => { + // if (resp.code === 0){ + const resp = {data:{ + "buildAt": "2024-09-13T03:51:25Z", + "build_user": "gitlab-runner", + "git_commint": "6438d5aaff146dc560ed0d8563788e64a49640a5", + "goversion": "go version go1.21.4 linux/amd64", + "guide": true, + "plugins": [ + { + "driver": "apipark.builtIn.component", + "name": "guide", + "router": [ + { + "path": "guide/*", + "type": "normal" + } + ] + }, + { + "driver": "apipark.builtIn.component", + "name": "team", + "router": [ + { + "path": "team", + "type": "normal" + } + ] + }, + // { + // "driver": "apipark.remote.normal", + // "name": "remote", + // "router": [ + // { + // "path": "remote", + // "type": "normal" + // } + // ] + // }, + // { + // "driver": "apipark.local.preload", + // "name": "auth", + // "router": [ + // { + // "expose": "AppModule", + // "path": "auth", + // "type": "root" + // }, + // { + // "expose": "AuthInfoModule", + // "path": "auth-info", + // "type": "normal" + // } + // ] + // }, + // { + // "driver": "apipark.builtIn.component", + // "name": "email", + // "router": [ + // { + // "path": "system/email", + // "type": "normal" + // } + // ] + // }, + // { + // "driver": "apipark.builtIn.module", + // "name": "open-api", + // "router": [ + // { + // "path": "system/ext-app", + // "type": "normal" + // } + // ] + // }, + // { + // "driver": "apipark.local.router", + // "name": "monitor", + // "router": [ + // { + // "expose": "AppModule", + // "path": "monitor", + // "type": "normal" + // } + // ] + // }, + // { + // "driver": "apipark.remote.normal", + // "name": "apispace", + // "router": [ + // { + // "path": "remote/apispace", + // "type": "normal" + // } + // ] + // } + ], + "powered": "Powered by https://eolink.com", + "product": "apipark", + "version": "6438d5aa" + }} + dispatch({type:'UPDATE_VERSION',version:resp.data.version}) + dispatch({type:'UPDATE_DATE',updateDate:resp.data.buildAt}) + dispatch({type:'UPDATE_POWER',powered:resp.data.powered}) + const driverMethod = { apipark: apipark }; + const pluginConfigList = resp.data.plugins; + const pluginLoader = { loadModule }; + const pluginLifecycleGuard ={}; + const builtInPluginLoader = loadBuiltInModule; + + // pluginSlotHub.addSlot('renewMenu', () => { + // // navigation.dataUpdated = true; + // // Assuming you have a way to get menu list in React + // // getMenuList().then(() => {}); + // }); + console.log('pluginConfigList', pluginConfigList) + for (const plugin of pluginConfigList) { + try { + const driverName = plugin.driver; + if (!driverName) { + console.error('no driver name'); + continue; + } + console.log(driverName) + const driver = driverName.split('.').reduce((driverMethod: { [x: string]: any; }, driverName: string | number) => driverMethod[driverName], driverMethod); + driver({ routerConfig, executeList, pluginLoader, pluginProvider, pluginLifecycleGuard, builtInPluginLoader }, plugin); + } catch (err) { + console.warn('安装插件出错:', err); + } + } + // resetRouterConfig(routerConfig); + console.log('get router', routerConfig) + // setFinalRouterConfig(routerConfig) + resolve(routerConfig); + // } else { + // messageService.error(resp.msg || '获取插件配置列表失败,请重试!'); + // reject(new Error(resp.msg || '获取插件配置列表失败')); + // } + // }); + } + ); + }; + + const loadBuiltInModule = (pluginName: any) => { + try { + const { module } = routerMap.get(pluginName); + return module; + } catch (err) { + console.warn(`安装内置插件[${pluginName}]出错:`, err); + } + }; + + return { + loadPlugins, + loadModule, + loadExecutedPlugin, + closeModal, + setBaseHref, + getModule + }; + }; + + export default usePluginLoader; \ No newline at end of file diff --git a/frontend/packages/businessEntry/src/utils/plugin.ts b/frontend/packages/businessEntry/src/utils/plugin.ts new file mode 100644 index 00000000..e2c5acd6 --- /dev/null +++ b/frontend/packages/businessEntry/src/utils/plugin.ts @@ -0,0 +1,214 @@ +import { RouteConfig } from '@businessEntry/components/aoplatform/RenderRoutes'; +import { routerMap } from '@businessEntry/consts/const'; +import { isFunction } from 'lodash-es' +// @ts-expect-error module cannot find +import { __federation_method_setRemote,__federation_method_getRemote,__federation_method_unwrapDefault } from 'virtual:__federation__'; + +interface RemoteModuleConfig{ + type:string + remoteEntry:string + exposedModule:string + remoteName:string +} + +export async function loadRemoteModule(remoteModuleConfig:RemoteModuleConfig){ + __federation_method_setRemote(remoteModuleConfig.remoteName, { + url: () => Promise.resolve(remoteModuleConfig.remoteEntry), + format: 'esm', + from: 'vite', + }); + + return await __federation_method_getRemote( + remoteModuleConfig.remoteName, + `./${remoteModuleConfig.exposedModule}` + ) +} + +export function generateRemoteModuleTemplate( + pluginName: string, + exposedModule: string, + pluginPath: string +):RemoteModuleConfig { + return { + type: 'module', + remoteEntry: pluginPath, + exposedModule: `./${exposedModule}`, + remoteName: pluginName + } +} + +/** 校验子应用导出的 生命周期 对象是否正确 */ +export function validateExportLifecycle(exports: unknown) { + const { bootstrap, mount, unmount } = exports ?? {} + return isFunction(bootstrap) && isFunction(mount) && isFunction(unmount) +} + + + +export const DEFAULT_LOCAL_PLUGIN_PATH = '/plugin-frontend/' +interface PluginRouterConfig { + path:string; + type:string; + expose?:string +} +interface PluginConfig { + name: string; + router: Array; + path?: string; + driver:string +} + +export interface CoreObj { + routerConfig: RouteConfig[]; + executeList: unknown[]; + pluginLoader: PluginLoaderService; + pluginLifecycleGuard: PluginLifecycleGuard; + pluginProvider: PluginProviderService; + builtInPluginLoader: (name: string) => any; +} + +const defaultBuiltInPlugin:Array<{path:string, pathMatch?:'full' | 'prefix', componentName?:string, type?:string}> = [ + { path: '/', pathMatch: 'full', componentName: 'login' }, + { path: '/login', componentName: 'login' }, + { path: '/', componentName: 'basicLayout' }, + // { path: '**', componentName: 'redirectPage' } + +] + + +export const ApiparkPluginDriver:{[key:string]:{[key:string]:(coreObj?:CoreObj, pluginConfig?:PluginConfig)=>(CoreObj|undefined)}} = { + builtIn: { + // apinto主项目驱动,在core中自动调,不根据插件配置表 + default: (coreObj?:CoreObj) => { + if(!coreObj) return coreObj + const url = new URL(window.location.href) + const navHidden = url.searchParams.get('nav_hidden') || sessionStorage.getItem('nav_hidden') + if (navHidden === 'true') sessionStorage.setItem('nav_hidden', navHidden) + const routes = defaultBuiltInPlugin.filter(plugin =>navHidden === 'true' && plugin.componentName === 'basicLayout' ? routerMap.get('navHidden')!.component : routerMap.get(plugin.componentName || plugin.path) ).map(plugin => ( + { + path: plugin.path, + component: navHidden === 'true' && plugin.componentName === 'basicLayout' ? routerMap.get('navHidden')!.component : routerMap.get(plugin.componentName || plugin.path)?.component, + children: [], + key:plugin.componentName, + data: { + type: plugin.type || plugin.componentName || plugin.path + }, + pathMatch: plugin.pathMatch || 'prefix' + }) + ) + console.log(routes) + coreObj.routerConfig.push(...routes) + return coreObj + }, + component: (coreObj?:CoreObj, pluginConfig?:PluginConfig) => { + if(!coreObj || !pluginConfig) return coreObj + for (const pluginRouter of pluginConfig.router) { + console.log(pluginRouter,{path: pluginRouter.path,component: routerMap.get(pluginConfig.name)?.component}) + const routerToChanged:RouteConfig[] = pluginRouter.type === 'root' ? coreObj.routerConfig : coreObj.routerConfig.find((router: RouteConfig) => router.path === '/' && router?.pathMatch !== 'full')!.children as RouteConfig[] + // coreObj.pluginProvider.setRouterConfig(pluginRouter.type === 'root', { + // path: pluginRouter.path, + // component: routerMap.get(pluginConfig.name)!.component + // }, coreObj.routerConfig) + routerMap.get(pluginConfig.name) && routerToChanged.unshift({...routerMap.get(pluginConfig.name)!, key:pluginConfig.name, path:pluginRouter.path}) + } + return coreObj + }, + module: (coreObj?:CoreObj, pluginConfig?:PluginConfig) => { + if(!coreObj || !pluginConfig) return coreObj + for (const pluginRouter of pluginConfig.router) { + const routerToChanged:RouteConfig[] = pluginRouter.type === 'root' ? coreObj.routerConfig : coreObj.routerConfig.find((router: RouteConfig) => router.path === '/' && router?.pathMatch !== 'full')!.children as RouteConfig[] + console.log(pluginConfig,pluginRouter,routerMap.get(pluginRouter.name), { + path: pluginRouter.path, + }) + // coreObj.pluginProvider.setRouterConfig(pluginRouter.type === 'root', { + // path: pluginRouter.path, + // component: routerMap.get(pluginConfig.name)!.component, + // children: coreObj.builtInPluginLoader(pluginConfig.name) + // }, coreObj.routerConfig) + routerMap.get(pluginRouter.name) && routerToChanged.unshift({...routerMap.get(pluginRouter.name)!, key:pluginRouter.name, path:pluginRouter.path}) + } + return coreObj + }, + httpApi: () => { + return undefined + } + }, + remote: { + normal: (coreObj?:CoreObj, pluginConfig?:PluginConfig) => { + if(!coreObj || !pluginConfig) return coreObj + const remoteRouter = coreObj.routerConfig.find((item:RouteConfig) => item?.data?.['type'] === 'remotePlugin') + if (!remoteRouter) { + // coreObj.pluginProvider.setRouterConfig(false, { + // path: 'remote', + // children: [ + // { + // path: ':moduleName', + // component: routerMap.get('remote').component + // } + // ], + // data: { + // type: 'remotePlugin' + // } + // }, coreObj.routerConfig) + } + return coreObj + } + }, + intelligent: { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + normal: (coreObj?:CoreObj, pluginConfig?:PluginConfig) => { + if(!coreObj || !pluginConfig) return coreObj + const remoteRouter = coreObj.routerConfig.find((item:RouteConfig) => item?.data?.['type'] === 'intelligentPlugin') + if (!remoteRouter) { + // coreObj.pluginProvider.setRouterConfig(false, { + // path: 'template', + // loadChildren: coreObj.builtInPluginLoader('intelligent'), + // data: { + // type: 'intelligentPlugin' + // } + // }, coreObj.routerConfig) + } + return coreObj + } + }, + local: { + router: (coreObj?:CoreObj, pluginConfig?:PluginConfig) => { + if(!coreObj || !pluginConfig) return coreObj + for (const pluginRouter of pluginConfig.router) { + if (pluginRouter.type === 'sub') { + continue + } + updateRouterConfigWithPlugin(coreObj, pluginRouter, pluginConfig) + } + return coreObj + }, + preload: (coreObj?:CoreObj, pluginConfig?:PluginConfig) => { + if(!coreObj || !pluginConfig) return coreObj + coreObj.executeList.push({ ...pluginConfig, expose: 'Bootstrap', bootstrap: 'BootstrapModule.bootstrap' }) + for (const pluginRouter of pluginConfig.router) { + updateRouterConfigWithPlugin(coreObj, pluginRouter, pluginConfig) + } + return coreObj + } + // extender: (coreObj?:CoreObj, pluginConfig?:PluginConfig) => {} + } +} +function updateRouterConfigWithPlugin (coreObj: CoreObj, pluginRouter: PluginRouterConfig, pluginConfig: PluginConfig) { + if (!pluginRouter.expose) { + throw new Error('pluginRouter.expose is required') + } else { + // coreObj.pluginProvider.setRouterConfig(pluginRouter.type === 'root', { + // path: pluginRouter.path, + // loadChildren: () => coreObj.pluginLoader.loadModule( + // pluginRouter.path, + // pluginConfig.name, + // pluginRouter.expose!, + // pluginConfig.path || `${DEFAULT_LOCAL_PLUGIN_PATH}${pluginConfig.name}/ApiparkPluginDriver.js` + // ), + // canActivate: [coreObj.pluginLifecycleGuard], + // canActivateChild: [coreObj.pluginLifecycleGuard], + // canDeactivate: [coreObj.pluginLifecycleGuard], + // canLoad: [coreObj.pluginLifecycleGuard] + // }, coreObj.routerConfig) + } +} diff --git a/frontend/packages/businessEntry/vite.config.ts b/frontend/packages/businessEntry/vite.config.ts index 895d5197..81624f0d 100644 --- a/frontend/packages/businessEntry/vite.config.ts +++ b/frontend/packages/businessEntry/vite.config.ts @@ -1,9 +1,10 @@ -import { defineConfig } from 'vite' +import { defineConfig, Plugin } from 'vite' import react from '@vitejs/plugin-react' import path from 'path' import dynamicImportVars from '@rollup/plugin-dynamic-import-vars'; import tailwindcss from 'tailwindcss'; import autoprefixer from 'autoprefixer'; +import federation from "@originjs/vite-plugin-federation"; export default defineConfig({ cacheDir: './node_modules/.vite', @@ -11,26 +12,17 @@ export default defineConfig({ outDir:'../../dist', sourcemap: false, chunkSizeWarningLimit: 50000, - cacheDir: './node_modules/.vite', + rollupOptions: { output: { - manualChunks(id) { - if (id.includes('node_modules')) { - return id.toString().split('node_modules/')[1].split('/')[0].toString(); - } - // 针对 pnpm 和 Monorepo 特殊处理 - if (id.includes('.pnpm')) { - const segments = id.split(path.sep); - const packageName = segments[segments.indexOf('.pnpm') + 1].split('@')[0]; - return packageName; - } - } + chunkFileNames: 'assets/eo-[name]-[hash].js', }, }, + }, css: { postcss: { plugins: [ tailwindcss(path.resolve(__dirname, '../common/tailwind.config.js')), - autoprefixer + autoprefixer, ], }, preprocessorOptions: { @@ -49,6 +41,16 @@ export default defineConfig({ exclude:[], warnOnError:false }), + federation({ + name:"container", + remotes:{ + remoteApp: 'http://localhost:5001/assets/remoteEntry.js' // 远程项目的URL + }, + shared:[ + "react", + "react-dom", + ] + }) ], resolve: { alias: [ diff --git a/frontend/packages/businessEntry/vite.config.ts.timestamp-1722480612803-56fa594878983.mjs b/frontend/packages/businessEntry/vite.config.ts.timestamp-1722480612803-56fa594878983.mjs deleted file mode 100644 index b2f55614..00000000 --- a/frontend/packages/businessEntry/vite.config.ts.timestamp-1722480612803-56fa594878983.mjs +++ /dev/null @@ -1,85 +0,0 @@ -// vite.config.ts -import { defineConfig } from "file:///D:/eolink/applatform/frontend/node_modules/.pnpm/vite@5.2.12_@types+node@20.14.2_less@4.2.0/node_modules/vite/dist/node/index.js"; -import react from "file:///D:/eolink/applatform/frontend/node_modules/.pnpm/@vitejs+plugin-react@4.3.0_vite@5.2.12_@types+node@20.14.2_less@4.2.0_/node_modules/@vitejs/plugin-react/dist/index.mjs"; -import path from "path"; -import dynamicImportVars from "file:///D:/eolink/applatform/frontend/node_modules/.pnpm/@rollup+plugin-dynamic-import-vars@2.1.2_rollup@4.18.0/node_modules/@rollup/plugin-dynamic-import-vars/dist/es/index.js"; -import tailwindcss from "file:///D:/eolink/applatform/frontend/node_modules/.pnpm/tailwindcss@3.4.4/node_modules/tailwindcss/lib/index.js"; -import autoprefixer from "file:///D:/eolink/applatform/frontend/node_modules/.pnpm/autoprefixer@10.4.19_postcss@8.4.38/node_modules/autoprefixer/lib/autoprefixer.js"; -var __vite_injected_original_dirname = "D:\\eolink\\applatform\\frontend\\packages\\businessEntry"; -var vite_config_default = defineConfig({ - cacheDir: "./node_modules/.vite", - build: { - outDir: "../../dist", - sourcemap: false, - chunkSizeWarningLimit: 5e4, - cacheDir: "./node_modules/.vite", - output: { - manualChunks(id) { - if (id.includes("node_modules")) { - return id.toString().split("node_modules/")[1].split("/")[0].toString(); - } - if (id.includes(".pnpm")) { - const segments = id.split(path.sep); - const packageName = segments[segments.indexOf(".pnpm") + 1].split("@")[0]; - return packageName; - } - } - } - }, - css: { - postcss: { - plugins: [ - tailwindcss(path.resolve(__vite_injected_original_dirname, "../common/tailwind.config.js")), - autoprefixer - ] - }, - preprocessorOptions: { - less: { - javascriptEnabled: true - } - }, - modules: { - localsConvention: "camelCase", - generateScopedName: "[local]_[hash:base64:2]" - } - }, - plugins: [ - react(), - dynamicImportVars({ - include: ["src"], - exclude: [], - warnOnError: false - }) - ], - resolve: { - alias: [ - { find: /^~/, replacement: "" }, - { find: "@common", replacement: path.resolve(__vite_injected_original_dirname, "../common/src") }, - { find: "@market", replacement: path.resolve(__vite_injected_original_dirname, "../market/src") }, - { find: "@core", replacement: path.resolve(__vite_injected_original_dirname, "../core/src") }, - { find: "@dashboard", replacement: path.resolve(__vite_injected_original_dirname, "../dashboard/src") }, - { find: "@openApi", replacement: path.resolve(__vite_injected_original_dirname, "../openApi/src") }, - { find: "@systemRunning", replacement: path.resolve(__vite_injected_original_dirname, "../systemRunning/src") }, - { find: "@businessEntry", replacement: path.resolve(__vite_injected_original_dirname, "./src") } - ] - }, - server: { - proxy: { - "/api/v1": { - // target: 'http://uat.apikit.com:11204/mockApi/aoplatform/', - target: "http://172.18.166.219:8288/", - changeOrigin: true - }, - "/api2/v1": { - // target: 'http://uat.apikit.com:11204/mockApi/aoplatform/', - target: "http://172.18.166.219:8288/", - changeOrigin: true - } - } - }, - logLevel: "info" -}); -export { - vite_config_default as default -}; -//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsidml0ZS5jb25maWcudHMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbImNvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9kaXJuYW1lID0gXCJEOlxcXFxlb2xpbmtcXFxcYXBwbGF0Zm9ybVxcXFxmcm9udGVuZFxcXFxwYWNrYWdlc1xcXFxidXNpbmVzc0VudHJ5XCI7Y29uc3QgX192aXRlX2luamVjdGVkX29yaWdpbmFsX2ZpbGVuYW1lID0gXCJEOlxcXFxlb2xpbmtcXFxcYXBwbGF0Zm9ybVxcXFxmcm9udGVuZFxcXFxwYWNrYWdlc1xcXFxidXNpbmVzc0VudHJ5XFxcXHZpdGUuY29uZmlnLnRzXCI7Y29uc3QgX192aXRlX2luamVjdGVkX29yaWdpbmFsX2ltcG9ydF9tZXRhX3VybCA9IFwiZmlsZTovLy9EOi9lb2xpbmsvYXBwbGF0Zm9ybS9mcm9udGVuZC9wYWNrYWdlcy9idX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DOUIsRUFBRSxNQUFNLFdBQVcsYUFBYSxLQUFLLFFBQVEsa0NBQVcsZUFBZSxFQUFFO0FBQUEsTUFDekUsRUFBRSxNQUFNLFdBQVcsYUFBYSxLQUFLLFFBQVEsa0NBQVcsZUFBZSxFQUFFO0FBQUEsTUFDekUsRUFBRSxNQUFNLFNBQVMsYUFBYSxLQUFLLFFBQVEsa0NBQVcsYUFBYSxFQUFFO0FBQUEsTUFDckUsRUFBRSxNQUFNLGNBQWMsYUFBYSxLQUFLLFFBQVEsa0NBQVcsa0JBQWtCLEVBQUU7QUFBQSxNQUMvRSxFQUFFLE1BQU0sWUFBWSxhQUFhLEtBQUssUUFBUSxrQ0FBVyxnQkFBZ0IsRUFBRTtBQUFBLE1BQzNFLEVBQUUsTUFBTSxrQkFBa0IsYUFBYSxLQUFLLFFBQVEsa0NBQVcsc0JBQXNCLEVBQUU7QUFBQSxNQUN2RixFQUFFLE1BQU0sa0JBQWtCLGFBQWEsS0FBSyxRQUFRLGtDQUFXLE9BQU8sRUFBRTtBQUFBLElBQzFFO0FBQUEsRUFDRjtBQUFBLEVBQ0EsUUFBUTtBQUFBLElBQ04sT0FBTztBQUFBLE1BQ0wsV0FBVztBQUFBO0FBQUEsUUFFVCxRQUFRO0FBQUEsUUFDUixjQUFjO0FBQUEsTUFDaEI7QUFBQSxNQUNBLFlBQVk7QUFBQTtBQUFBLFFBRVYsUUFBUTtBQUFBLFFBQ1IsY0FBYztBQUFBLE1BQ2hCO0FBQUEsSUFDRjtBQUFBLEVBQ0Y7QUFBQSxFQUNBLFVBQVM7QUFDWCxDQUFDOyIsCiAgIm5hbWVzIjogW10KfQo= diff --git a/frontend/packages/common/src/components/aoplatform/RemotePlugin.tsx b/frontend/packages/common/src/components/aoplatform/RemotePlugin.tsx new file mode 100644 index 00000000..e69de29b diff --git a/frontend/packages/common/src/const/const.tsx b/frontend/packages/common/src/const/const.tsx index 9046e1d2..31ca2866 100644 --- a/frontend/packages/common/src/const/const.tsx +++ b/frontend/packages/common/src/const/const.tsx @@ -1,11 +1,9 @@ - export type BasicResponse = { code:number data:T msg:string } - export const STATUS_CODE = { SUCCESS:0, UNANTHORIZED:401, @@ -29,6 +27,7 @@ export const routerKeyMap = new Map([ ['maintenanceCenter',['aisetting','datasourcing','cluster','cert','logsettings','resourcesettings','openapi'] ]]) + export const COLUMNS_TITLE = { operate : '' diff --git a/frontend/packages/common/src/contexts/GlobalStateContext.tsx b/frontend/packages/common/src/contexts/GlobalStateContext.tsx index b338b76a..f3fbede9 100644 --- a/frontend/packages/common/src/contexts/GlobalStateContext.tsx +++ b/frontend/packages/common/src/contexts/GlobalStateContext.tsx @@ -47,6 +47,14 @@ export const GlobalContext = createContext<{ checkPermission:(access:keyof typeof PERMISSION_DEFINITION[0] | Array)=>boolean teamDataFlushed:boolean accessInit:boolean + // 插件系统 + pluginEventHub:unknown + pluginSlotHubService:{ + addSlot:(name:string, content:unknown)=>void + addSlotArr:(name:string, content:unknown[])=>void + removeSlot:(name:string)=>void + getSlot:(name:string)=>unknown + } aiConfigFlushed:boolean setAiConfigFlushed:(flush:boolean)=>void } | undefined>(undefined); @@ -118,6 +126,8 @@ export const GlobalProvider: FC<{children:ReactNode}> = ({ children }) => { const [accessInit, setAccessInit] = useState(false) const [aiConfigFlushed, setAiConfigFlushed] = useState(false) let getGlobalAccessPromise: Promise> | null = null + const [pluginEventHub] = useState({}) + const [pluginSlotHub] = useState>(new Map()) const getGlobalAccessData = ()=>{ if(getGlobalAccessPromise){ @@ -176,6 +186,14 @@ export const GlobalProvider: FC<{children:ReactNode}> = ({ children }) => { return revs } + const pluginSlotHubService = { + addSlot:pluginSlotHub.set, + addSlotArr : (name:string, content:any[]) => {pluginSlotHub.get(name) ? pluginSlotHub.set(name, (pluginSlotHub.get(name) as Array).push(content)) : pluginSlotHub.set(name, content)}, + removeSlot:pluginSlotHub.delete, + getSlot:pluginSlotHub.get + } + + return ( = ({ children }) => { getTeamAccessData,teamDataFlushed, cleanTeamAccessData, resetAccess ,checkPermission,accessInit, - aiConfigFlushed, setAiConfigFlushed}}> + aiConfigFlushed, setAiConfigFlushed,pluginEventHub,pluginSlotHubService}}> {children} ); diff --git a/frontend/packages/core/src/components/aoplatform/RenderRoutes.tsx b/frontend/packages/core/src/components/aoplatform/RenderRoutes.tsx index 4cf2c011..0eb5322b 100644 --- a/frontend/packages/core/src/components/aoplatform/RenderRoutes.tsx +++ b/frontend/packages/core/src/components/aoplatform/RenderRoutes.tsx @@ -5,6 +5,7 @@ import BasicLayout from '@common/components/aoplatform/BasicLayout'; import {createElement, ReactElement,ReactNode,Suspense} from 'react'; import { v4 as uuidv4 } from 'uuid' import {App, Skeleton} from "antd"; +import {SystemProvider} from "@core/contexts/SystemContext.tsx"; import {useGlobalContext} from "@common/contexts/GlobalStateContext.tsx"; import {FC,lazy} from 'react'; import { TeamProvider } from '@core/contexts/TeamContext.tsx'; @@ -13,7 +14,6 @@ import Guide from '@core/pages/guide/Guide'; import { AiServiceProvider } from '@core/contexts/AiServiceContext'; import AiServiceOutlet from '@core/pages/aiService/AiServiceOutlet'; import SystemOutlet from '@core/pages/system/SystemOutlet'; -import { SystemProvider } from '@core/contexts/SystemContext'; type RouteConfig = { path:string @@ -50,57 +50,52 @@ const PUBLIC_ROUTES:RouteConfig[] = [ { path:'/', component:, - key: uuidv4(), + key: 'root', }, { path:'/login', component:, - key: uuidv4() + key: 'login' }, { path:'/', component:, - key: uuidv4(), + key: 'layout', children:[ - // { - // path:'approval/*', - // component:, - // key:uuidv4() - // }, { path:'guide/*', component:, - key:uuidv4() + key:'guide' }, { path:'team', component:, - key: uuidv4(), + key: 'team', provider: TeamProvider, children:[ { path:'', - key: uuidv4(), + key: 'teamList', component: }, { path:'list', - key: uuidv4(), + key: 'teamList2', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/team/TeamList.tsx')) }, { path:'inside/:teamId', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/team/TeamInsidePage.tsx')), - key: uuidv4(), + key: 'teamInside', children:[ { path:'member', - key: uuidv4(), + key: 'teamMember', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/team/TeamInsideMember.tsx')), }, { path:'setting', - key: uuidv4(), + key: 'teamSetting', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/team/TeamConfig.tsx')), }, ] @@ -111,36 +106,37 @@ const PUBLIC_ROUTES:RouteConfig[] = [ path:'service', key: uuidv4(), component:, + key: 'restService', provider: SystemProvider, children:[ { path:'', - key:uuidv4(), + key:'restServiceList', component: }, { path:'list', - key: uuidv4(), + key: 'restServiceList2', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/SystemList.tsx')), }, { path:'list/:teamId', - key: uuidv4(), + key: 'restServiceList3', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/SystemList.tsx')), }, { path:':teamId', component:, - key: uuidv4(), + key: 'restServiceInside', children:[ { path:'inside/:serviceId', - key: uuidv4(), + key: 'restServiceInside2', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/SystemInsidePage.tsx')), children:[ { path:'api', - key: uuidv4(), + key: 'restServiceInsideApi', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/api/SystemInsideApiDocument.tsx')), }, { @@ -157,22 +153,22 @@ const PUBLIC_ROUTES:RouteConfig[] = [ }, { path:'route', - key: uuidv4(), + key: 'restServiceInsideRoute', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/api/SystemInsideRouterList')), }, { path:'upstream', - key: uuidv4(), + key: 'restServiceInsideUpstream', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/upstream/SystemInsideUpstreamContent.tsx')), }, { path:'document', - key: uuidv4(), + key: 'restServiceInsideDocument', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/SystemInsideDocument.tsx')), }, { path:'subscriber', - key: uuidv4(), + key: 'restServiceInsideSubscriber', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/SystemInsideSubscriber.tsx')), children:[ @@ -180,17 +176,17 @@ const PUBLIC_ROUTES:RouteConfig[] = [ }, { path:'approval', - key: uuidv4(), + key: 'restServiceInsideApproval', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/approval/SystemInsideApproval.tsx')), children:[ { path:'', - key: uuidv4(), + key: 'restServiceInsideApprovalList', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/approval/SystemInsideApprovalList.tsx')), }, { path:'*', - key: uuidv4(), + key: 'restServiceInsideApprovalList2', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/approval/SystemInsideApprovalList.tsx')), } ] @@ -198,30 +194,30 @@ const PUBLIC_ROUTES:RouteConfig[] = [ { path:'topology', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/SystemTopology.tsx')), - key: uuidv4(), + key: 'systemTopology', children:[ ] }, { path:'publish', - key: uuidv4(), + key: 'systemPublish', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/publish/SystemInsidePublish.tsx')), children:[ { path:'', - key: uuidv4(), + key: 'systemPublishList', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/publish/SystemInsidePublishList.tsx')), }, { path:'*', - key: uuidv4(), + key: 'systemPublishList2', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/publish/SystemInsidePublishList.tsx')), } ] }, { path:'setting', - key: uuidv4(), + key: 'systemConfig', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/SystemConfig.tsx')), children:[ @@ -321,42 +317,42 @@ const PUBLIC_ROUTES:RouteConfig[] = [ }, { path:'datasourcing', - key: uuidv4(), + key: 'dataSourcing', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/partitions/PartitionInsideDashboardSetting.tsx')), }, { path:'cluster', - key: uuidv4(), + key: 'cluster', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/partitions/PartitionInsideCluster.tsx')), }, { path:'aisetting', - key: uuidv4(), + key: 'aiSetting', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/aiSetting/AiSettingList.tsx')), }, { path:'cert', - key: uuidv4(), + key: 'cert', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/partitions/PartitionInsideCert.tsx')), }, { path:'serviceHub', component:, - key:uuidv4(), + key:'serviceHub', children:[ { path:'', - key: uuidv4(), + key: 'serviceHubList', component: }, { path:'list', - key:uuidv4(), + key:'serviceHubList2', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@market/pages/serviceHub/ServiceHubList.tsx')), }, { path:'detail/:serviceId', - key:uuidv4(), + key:'serviceHubDetail', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@market/pages/serviceHub/ServiceHubDetail.tsx')), }] }, @@ -369,107 +365,102 @@ const PUBLIC_ROUTES:RouteConfig[] = [ path:'tenantManagement', component:, provider:TenantManagementProvider, - key:uuidv4(), + key:'tenantManagement', children:[ { path:'', - key:uuidv4(), + key:'tenantManagementList', component: }, { path:':teamId/inside/:appId', - key:uuidv4(), + key:'tenantManagementInside', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@market/pages/serviceHub/management/ManagementInsidePage.tsx')), children:[ { path:'service', - key:uuidv4(), + key:'tenantManagementInsideService', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@market/pages/serviceHub/management/ManagementInsideService.tsx')), }, { path:'authorization', - key:uuidv4(), + key:'tenantManagementInsideAuthorization', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@market/pages/serviceHub/management/ManagementInsideAuth.tsx')), }, { path:'setting', - key:uuidv4(), + key:'tenantManagementSetting', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@market/pages/serviceHub/management/ManagementAppSetting.tsx')), }, ] }, { path:'list', - key:uuidv4(), + key:'serviceHubManagementList', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@market/pages/serviceHub/management/ServiceHubManagement.tsx')), }, { path:'list/:teamId', - key:uuidv4(), + key:'serviceHubManagementList2', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@market/pages/serviceHub/management/ServiceHubManagement.tsx')), }, ] }, { path:'member', - key:uuidv4(), + key:'member', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/member/MemberPage.tsx')), children:[ { path:'', - key:uuidv4(), + key:'memberList', component: }, { path:'list', - key:uuidv4(), + key:'memberList2', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/member/MemberList.tsx')), }, { path:'list/:memberGroupId', - key:uuidv4(), + key:'memberList3', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/member/MemberList.tsx')), } ] }, { path:'role', - key:uuidv4(), + key:'role', component:, children:[ { path: '', - key: uuidv4(), + key: 'roleList', component: }, { path:'list', - key:uuidv4(), + key:'roleList2', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/role/RoleList.tsx')), },{ path:':roleType/config/:roleId', - key:uuidv4(), + key:'roleConfig', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/role/RoleConfig.tsx')), },{ path:':roleType/config', - key:uuidv4(), + key:'roleConfig2', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/role/RoleConfig.tsx')), } ] }, - { - path:'assets', - component:

设计中

, - key:uuidv4() - }, { path:'analytics', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@dashboard/pages/Dashboard.tsx')), - key:uuidv4(), + key:'analytics', children:[ { path:'total', - key:uuidv4(), + key:'analytics2', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@dashboard/pages/DashboardTotal.tsx')), }, ] @@ -477,38 +468,38 @@ const PUBLIC_ROUTES:RouteConfig[] = [ { path:'template/:moduleId', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@common/components/aoplatform/intelligent-plugin/IntelligentPluginList.tsx')), - key:uuidv4() + key:'intelligentPlugin' }, { path:'logsettings/*', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/logsettings/LogSettings.tsx')), - key: uuidv4(), + key: 'logSettings', children:[{ path:'template/:moduleId', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@common/components/aoplatform/intelligent-plugin/IntelligentPluginList.tsx')), - key:uuidv4() + key:'logSettings2' }] }, APP_MODE ==='pro' && { path:'resourcesettings/*', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/resourcesettings/ResourceSettings.tsx')), - key: uuidv4(), + key: 'resourceSettings', children:[{ path:'template/:moduleId', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@common/components/aoplatform/intelligent-plugin/IntelligentPluginList.tsx')), - key:uuidv4() + key:'resourceSettings2' }] }, { path:'userProfile/*', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/userProfile/UserProfile.tsx')), - key:uuidv4(), + key:'userProfile', children:[{ path:'changepsw', lazy:lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/userProfile/ChangePsw.tsx')), - key:uuidv4() + key:'changePsw' }] } ] @@ -520,7 +511,7 @@ const RenderRoutes = ()=> { - {generateRoutes(PUBLIC_ROUTES)} + { generateRoutes(PUBLIC_ROUTES)} diff --git a/frontend/packages/core/src/pages/system/SystemInsidePage.tsx b/frontend/packages/core/src/pages/system/SystemInsidePage.tsx index 34974408..85d89466 100644 --- a/frontend/packages/core/src/pages/system/SystemInsidePage.tsx +++ b/frontend/packages/core/src/pages/system/SystemInsidePage.tsx @@ -74,7 +74,7 @@ const SystemInsidePage:FC = ()=> { 'group'), getItem($t('管理'), 'mng', null, [ - APP_MODE === 'pro' ? getItem({$t('调用拓扑图')}, 'topology',undefined,undefined,undefined,'project.mySystem.topology.view'):null, + // APP_MODE === 'pro' ? getItem({$t('调用拓扑图')}, 'topology',undefined,undefined,undefined,'project.mySystem.topology.view'):null, getItem({$t('设置')}, 'setting',undefined,undefined,undefined,'')], 'group'), ],[state.language]) diff --git a/frontend/packages/core/vite.config.ts b/frontend/packages/core/vite.config.ts index c4334d68..7dc973e7 100644 --- a/frontend/packages/core/vite.config.ts +++ b/frontend/packages/core/vite.config.ts @@ -18,7 +18,7 @@ export default defineConfig({ chunkFileNames: 'assets/eo-[name]-[hash].js', }, }, - }, + }, css: { postcss: { plugins: [ diff --git a/frontend/packages/market/src/pages/serviceHub/ServiceHubList.tsx b/frontend/packages/market/src/pages/serviceHub/ServiceHubList.tsx index 1d5e3384..625a897b 100644 --- a/frontend/packages/market/src/pages/serviceHub/ServiceHubList.tsx +++ b/frontend/packages/market/src/pages/serviceHub/ServiceHubList.tsx @@ -138,7 +138,7 @@ const ServiceHubList:FC = ()=>{
showDocumentDetail(item)}> {item.description || $t('暂无服务描述')} + style={{wordBreak:'auto-phrase'}}>{item.description || $t('暂无服务描述')}
); diff --git a/frontend/packages/openApi/src/pages/OpenApiList.tsx b/frontend/packages/openApi/src/pages/OpenApiList.tsx index bb16eda2..3255aec9 100644 --- a/frontend/packages/openApi/src/pages/OpenApiList.tsx +++ b/frontend/packages/openApi/src/pages/OpenApiList.tsx @@ -10,8 +10,8 @@ import {OpenApiConfig, OpenApiConfigFieldType, OpenApiConfigHandle} from "./Open import { SimpleMemberItem } from "@common/const/type.ts"; import TableBtnWithPermission from "@common/components/aoplatform/TableBtnWithPermission.tsx"; import { frontendTimeSorter } from "@common/utils/dataTransfer.ts"; -import { OPENAPI_LIST_COLUMNS } from "@market/consts/const.tsx"; -import { OpenApiTableListItem } from "@market/consts/type.ts"; +import { OPENAPI_LIST_COLUMNS } from "@openApi/consts/const.tsx"; +import { OpenApiTableListItem } from "@openApi/consts/type.ts"; import { $t } from "@common/locales/index.ts"; diff --git a/frontend/packages/openApi/tsconfig.json b/frontend/packages/openApi/tsconfig.json index 9549c6dc..9260fb6d 100644 --- a/frontend/packages/openApi/tsconfig.json +++ b/frontend/packages/openApi/tsconfig.json @@ -21,7 +21,7 @@ "paths": { "@common/*": ["../common/src/*"], "@core/*": ["../core/src/*"], - "@market/*": ["./src/*"] + "@openApi/*": ["./src/*"] }, }, "include": ["src", "public/iconpark_eolink.js", "public/iconpark_apinto.js", "../common/src/component/aoplatform/EditableTableWithModal.tsx", "../common/src/components/aoplatform/TreeWithMore.tsx", "../common/src/components/aoplatform/DatePicker.tsx", "../common/src/components/aoplatform/TimeRangeSelector.tsx", "../common/src/components/aoplatform/TimePicker.tsx", "../common/src/components/aoplatform/MemberTransfer.tsx", "../common/src/components/aoplatform/PageList.tsx", "../common/src/components/aoplatform/ErrorBoundary.tsx", "../core/src/pages/serviceCategory/ServiceHubCategoryConfig.tsx"],