mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 09:20:22 +08:00
feat: 实现功能模块系统,支持模块的动态注册与启用控制
- 新增 ModuleRegistry 核心,支持模块注册、可用性检查和启用状态管理 - 新增模块管理 API(管理端和公共端),提供模块状态查询和启用控制 - 将 LDAP 功能迁移到模块系统,支持通过环境变量和数据库配置控制 - 前端新增模块管理页面和 store,支持模块启用/禁用操作 - 路由守卫集成模块状态检查,未激活模块的页面自动重定向 - 面包屑导航支持模块配置页面的层级显示 - Switch 组件新增 disabled 属性支持
This commit is contained in:
63
frontend/src/api/modules.ts
Normal file
63
frontend/src/api/modules.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
import apiClient from './client'
|
||||
|
||||
export interface ModuleStatus {
|
||||
name: string
|
||||
available: boolean
|
||||
enabled: boolean
|
||||
active: boolean
|
||||
display_name: string
|
||||
description: string
|
||||
category: 'auth' | 'monitoring' | 'security' | 'integration'
|
||||
admin_route: string | null
|
||||
admin_menu_icon: string | null
|
||||
admin_menu_group: string | null
|
||||
admin_menu_order: number
|
||||
health: 'healthy' | 'degraded' | 'unhealthy' | 'unknown'
|
||||
}
|
||||
|
||||
export interface AuthModuleInfo {
|
||||
name: string
|
||||
display_name: string
|
||||
active: boolean
|
||||
}
|
||||
|
||||
export const modulesApi = {
|
||||
/**
|
||||
* 获取所有模块状态(管理员)
|
||||
*/
|
||||
async getAllStatus(): Promise<Record<string, ModuleStatus>> {
|
||||
const response = await apiClient.get<Record<string, ModuleStatus>>(
|
||||
'/api/admin/modules/status'
|
||||
)
|
||||
return response.data
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取单个模块状态(管理员)
|
||||
*/
|
||||
async getStatus(moduleName: string): Promise<ModuleStatus> {
|
||||
const response = await apiClient.get<ModuleStatus>(
|
||||
`/api/admin/modules/status/${moduleName}`
|
||||
)
|
||||
return response.data
|
||||
},
|
||||
|
||||
/**
|
||||
* 设置模块启用状态(管理员)
|
||||
*/
|
||||
async setEnabled(moduleName: string, enabled: boolean): Promise<ModuleStatus> {
|
||||
const response = await apiClient.put<ModuleStatus>(
|
||||
`/api/admin/modules/status/${moduleName}/enabled`,
|
||||
{ enabled }
|
||||
)
|
||||
return response.data
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取认证模块状态(公开接口,供登录页使用)
|
||||
*/
|
||||
async getAuthModulesStatus(): Promise<AuthModuleInfo[]> {
|
||||
const response = await apiClient.get<AuthModuleInfo[]>('/api/modules/auth-status')
|
||||
return response.data
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user