refactor(frontend): api/components/pages 目录架构统一对齐菜单域 + 日志中心修复
1. 目录架构统一(API = components = 菜单域,一域一目录 + barrel) - log/ 提为独立顶层域(日志中心在菜单中与监控中心平级,不再塞在 monitor/) - task/ 拆分原 automation.ts → cron-job / script / remote-exec - aiops/ 合并 ai.ts + agentCli.ts → assistant + agent-cli - agent/ approval/ audit/ 提升为域目录 - auth 拆分:authApi(认证自服务) + system/user.ts(userApi+ldapApi 管理端) - components/automation → components/task,菜单"自动化运维"→"作业任务" - pages/ 按域分子目录(approval/audit/monitor),删孤儿 AuditPage.tsx - 所有 API 符号名不变,组件经 @/api 聚合引用,运行时行为零变化 2. Loki 查询无返回修复:aiops 容器 DNS 解析外网域名失败 (宿主机 systemd-resolved 转发链路异常),docker-compose 显式配 dns 上游 3. ES 查询框布局:工具栏单行挤 7 控件(ES 多 150px 索引框),拆两行—— 查询输入独占一行(+查询按钮),次级控件换行 flex-wrap Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
da01cbb119
commit
c0ee8e4ddd
74 files changed
+229
-216
No files matched your search
@@ -0,0 +1,66 @@
|
||||
// 日志中心 API — 无状态代理查询,平台不落库海量日志 // Logan.Li
|
||||
|
||||
import { http, type ListResponse } from '@/utils/request';
|
||||
|
||||
export interface LogDataSource {
|
||||
id: number;
|
||||
name: string;
|
||||
type: 'loki' | 'elasticsearch';
|
||||
url: string;
|
||||
auth_type?: 'none' | 'basic' | 'bearer' | 'custom';
|
||||
basic_auth?: boolean;
|
||||
basic_auth_user?: string;
|
||||
basic_auth_pass?: string;
|
||||
token?: string;
|
||||
headers?: string; // JSON 字符串,如 [{"name":"X-Scope-OrgID","value":"tenant-1"}]
|
||||
skip_tls_verify?: boolean;
|
||||
default_index?: string;
|
||||
is_default?: boolean;
|
||||
status?: number;
|
||||
}
|
||||
|
||||
/** 查询结果行 — 仅用于当前页展示,不持久化 // Logan.Li */
|
||||
export interface LogQueryEntry {
|
||||
timestamp: string;
|
||||
level?: string;
|
||||
message: string;
|
||||
labels?: Record<string, string>;
|
||||
raw?: string;
|
||||
}
|
||||
|
||||
/** 数据源连接测试结果 // Logan.Li */
|
||||
export interface TestConnectionResult {
|
||||
status: 'ok' | 'failed';
|
||||
error?: string;
|
||||
}
|
||||
|
||||
export const logCenterApi = {
|
||||
listDatasources: (type?: string) =>
|
||||
http.get<ListResponse<LogDataSource>>('/log-datasources', type ? { type } : undefined),
|
||||
createDatasource: (data: Record<string, unknown>) => http.post('/log-datasources', data),
|
||||
updateDatasource: (id: number | string, data: Record<string, unknown>) =>
|
||||
http.put(`/log-datasources/${id}`, data),
|
||||
deleteDatasource: (id: number | string) => http.delete(`/log-datasources/${id}`),
|
||||
setDefaultDatasource: (id: number | string) => http.post(`/log-datasources/${id}/default`),
|
||||
testDatasource: (data: Record<string, unknown>) => http.post<TestConnectionResult>('/log-datasources/test', data),
|
||||
/** 通过代理查询 ES 集群索引列表 // Logan.Li */
|
||||
listIndices: (params: Record<string, string>) =>
|
||||
http.get<string[]>('/log-datasources/indices', params),
|
||||
queryLoki: (data: {
|
||||
datasource_id: number;
|
||||
query: string;
|
||||
limit?: number;
|
||||
start?: string;
|
||||
end?: string;
|
||||
direction?: string;
|
||||
}) => http.post<{ entries: LogQueryEntry[]; total: number }>('/logs/loki/query', data),
|
||||
queryElasticsearch: (data: {
|
||||
datasource_id: number;
|
||||
index?: string;
|
||||
query?: string;
|
||||
query_body?: Record<string, unknown>;
|
||||
size?: number;
|
||||
start?: string;
|
||||
end?: string;
|
||||
}) => http.post<{ entries: LogQueryEntry[]; total: number }>('/logs/elasticsearch/query', data),
|
||||
};
|
||||
Reference in new issue
Block a user