feat: 新增日志中心、功能优化与代码重构

- 新增 log_datasource.go / log_proxy.go / user_api_token.go 后端控制器
- 新增 log_datasource.go model
- 新增 monitor/log-center.ts API 模块
- 新增 LogCenter 前端组件及页面
- 重构 deployment 相关组件 (HPDA/UpdateImageModal/bundle-yaml 等)
- 新增 ResetPasswordDialog / code-snippet-block / copy-button 等 UI 组件
- 重构多个 k8s 相关组件 (TopologyView/ResourceVisualEditor/PodFileBrowser 等)
- 更新多个 API 和工具函数 (auth.ts/monitor/index.ts/request.ts 等)
- 更新静态资源 (index.html + 新 JS/CSS bundle)
- 删除废弃静态资源文件
This commit is contained in:
Logan committed 2026-06-26 23:18:05 +08:00
1 parent 5ca0e6d83a
commit 8d46e8f352
197 files changed
+5014 -815

No files matched your search

+57
View File
@@ -26,6 +26,63 @@ export const userApi = {
changePassword: async (data: { old_password: string; new_password: string }) => {
return http.put('/user/password', data);
},
getApiAccessKey: async () => {
return http.get<{
has_token: boolean;
key_id?: string;
prefix?: string;
access_key_mask?: string;
description?: string;
created_at?: string;
expires_at?: string;
last_used_at?: string;
status?: 'active' | 'expired';
expired?: boolean;
days_left?: number;
default_months?: number;
}>('/user/api-access-key');
},
regenerateApiAccessKey: async (opts?: { description?: string; expires_at?: string; duration_months?: number }) => {
return http.post<{
token: string;
prefix: string;
key_id: string;
description?: string;
created_at: string;
expires_at: string;
duration_months: number;
}>('/user/api-access-key/regenerate', {
description: opts?.description ?? '',
expires_at: opts?.expires_at ?? '',
duration_months: opts?.duration_months ?? 12,
});
},
updateApiAccessKey: async (data: { description?: string; expires_at?: string }) => {
return http.put<{
has_token: boolean;
key_id?: string;
access_key_mask?: string;
description?: string;
created_at?: string;
expires_at?: string;
last_used_at?: string;
status?: 'active' | 'expired';
expired?: boolean;
days_left?: number;
}>('/user/api-access-key', data);
},
extendApiAccessKey: async (durationMonths = 12) => {
return http.post<{ expires_at: string; duration_months: number }>(
'/user/api-access-key/extend',
{ duration_months: durationMonths },
);
},
revokeApiAccessKey: async () => {
return http.delete('/user/api-access-key');
},
resetUserPassword: async (id: number | string, new_password: string) => {
return http.post(`/admin/users/${id}/reset-password`, { new_password });
},
getUsers: async (params?: { page?: number; page_size?: number; keyword?: string }) => {
return http.get<ListResponse>('/admin/users', params);
},
+2
View File
@@ -66,4 +66,6 @@ export const podApi = {
getAllPods: async (clusterCode: string) => http.get(`/kubernetes/${clusterCode}/pods`),
getNamespacePods: async (clusterCode: string, namespace: string) =>
http.get(`/kubernetes/${clusterCode}/namespace/${namespace}/pods`),
deletePod: async (clusterCode: string, namespace: string, podName: string) =>
http.delete(`/kubernetes/${clusterCode}/namespace/${namespace}/pods/${podName}`),
};
+3
View File
@@ -7,6 +7,9 @@ export const resourceApi = {
http.get(`/kubernetes/${clusterCode}/namespace/${namespace}/services`),
getNamespaceIngresses: async (clusterCode: string, namespace: string) =>
http.get(`/kubernetes/${clusterCode}/namespace/${namespace}/ingresses`),
// 获取 IngressClass 列表,用于 Ingress 可视化编辑的下拉选择 // Logan.Li
getIngressClasses: async (clusterCode: string) =>
http.get(`/kubernetes/${clusterCode}/ingressclasses`),
getNamespaceConfigMaps: async (clusterCode: string, namespace: string) =>
http.get(`/kubernetes/${clusterCode}/namespace/${namespace}/configmaps`),
getNamespaceSecrets: async (clusterCode: string, namespace: string) =>
+1
View File
@@ -6,4 +6,5 @@ export { siteApi } from './site';
export { traceApi } from './trace';
export { dashboardApi } from './grafana';
export { promDatasourceApi, zabbixDatasourceApi } from './datasource';
export { logCenterApi, type LogDataSource, type LogQueryEntry } from './log-center';
export { metricsApi, snmpApi, prometheusProxyApi, zabbixProxyApi } from './metrics';
+54
View File
@@ -0,0 +1,54 @@
// 日志中心 API — 无状态代理查询,平台不落库海量日志 // Logan.Li
import { http } from '@/utils/request';
export interface LogDataSource {
id: number;
name: string;
type: 'loki' | 'elasticsearch';
url: string;
basic_auth?: boolean;
basic_auth_user?: string;
basic_auth_pass?: string;
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;
}
export const logCenterApi = {
listDatasources: (type?: string) =>
http.get<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('/log-datasources/test', data),
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),
};