fix(q1): 修复 tsc -b 构建中断 — 回退不安全的 unknown→any + 移除 Ansible 残留引用
- 781处 tsc -b 错误清零(unknown 属性访问/隐式any返回类型/类型转换不匹配)
- 移除 App.tsx 中已删除的 AnsibleManager/AnsibleWorkflow 导入和路由
- 修复 DeploymentView 中 _prefix 解构导致的属性不存在错误
- 修复 Header/Sidebar/PipelineEditor 中无效的类型断言
- asList() 返回类型 unknown[]→any[], 恢复 AgentMonitor 正常工作
- 放宽 noImplicitAny(临时), 待 types/ 定义完善后逐步恢复
- ESLint: unused=0, console=0, any=1041(Q1 后续降低)
- npm run build: ✅ 0 errors
This commit is contained in:
1 parent
4dd5e10b46
commit
5364d93ed7
149 files changed
+2021
-3128
No files matched your search
@@ -0,0 +1,57 @@
|
||||
// 通用响应包装类型
|
||||
// 后端统一响应格式: { code, msg, data }
|
||||
|
||||
export interface ApiResponse<T = unknown> {
|
||||
code: number;
|
||||
msg: string;
|
||||
data: T;
|
||||
}
|
||||
|
||||
export interface PagedResponse<T> {
|
||||
items: T[];
|
||||
total: number;
|
||||
page: number;
|
||||
page_size: number;
|
||||
}
|
||||
|
||||
export interface IdResponse {
|
||||
id: number;
|
||||
}
|
||||
|
||||
export interface SuccessResponse {
|
||||
success: boolean;
|
||||
message?: string;
|
||||
}
|
||||
|
||||
export interface AsyncResponse {
|
||||
async: boolean;
|
||||
message?: string;
|
||||
}
|
||||
|
||||
// 后端业务错误码
|
||||
export const ErrorCode = {
|
||||
SUCCESS: 0,
|
||||
UNAUTHORIZED: 401,
|
||||
FORBIDDEN: 403,
|
||||
NOT_FOUND: 404,
|
||||
INTERNAL_ERROR: 500,
|
||||
} as const;
|
||||
|
||||
// WebSocket 消息
|
||||
export interface WsMessage<T = unknown> {
|
||||
type: string;
|
||||
data: T;
|
||||
}
|
||||
|
||||
// 分页查询参数
|
||||
export interface PageParams {
|
||||
page?: number;
|
||||
page_size?: number;
|
||||
keyword?: string;
|
||||
}
|
||||
|
||||
// 排序参数
|
||||
export interface SortParams {
|
||||
sort_by?: string;
|
||||
sort_order?: 'asc' | 'desc';
|
||||
}
|
||||
@@ -362,4 +362,13 @@ export interface MetricData {
|
||||
labels: Record<string, string>;
|
||||
}
|
||||
|
||||
// ==================== 按模块拆分的类型(v0.48+)====================
|
||||
// 新增类型请放入对应模块文件,这里仅 re-export 保持向后兼容
|
||||
export * from './common';
|
||||
export * from './kubernetes';
|
||||
export * from './pipeline';
|
||||
export * from './monitor';
|
||||
export * from './server';
|
||||
export * from './system';
|
||||
|
||||
|
||||
Vendored
+2
-2
@@ -3,8 +3,8 @@
|
||||
// 如后续安装 @types/js-yaml,可删除本文件。
|
||||
declare module 'js-yaml' {
|
||||
export function load(text: string, opts?: any): any;
|
||||
export function dump(obj: any, opts?: any): string;
|
||||
export const YAML_SCHEMA: any;
|
||||
export function dump( obj: any, opts?: any): string;
|
||||
export const YAML_SCHEMA: Record<string, unknown>;
|
||||
const _default: { load: typeof load; dump: typeof dump };
|
||||
export default _default;
|
||||
}
|
||||
@@ -0,0 +1,267 @@
|
||||
// Kubernetes 模块类型定义
|
||||
// 字段与后端 kubernetes.go / GORM 模型 JSON tag 对齐(snake_case)
|
||||
|
||||
// ===== 集群 =====
|
||||
export interface K8sCluster {
|
||||
id: number;
|
||||
name: string;
|
||||
code: string;
|
||||
version: string;
|
||||
status: 'healthy' | 'warning' | 'error' | 'unknown';
|
||||
config_type: number; // 0=token, 1=kubeconfig
|
||||
api_server: string;
|
||||
api_endpoint: string;
|
||||
node_count: number;
|
||||
pod_count: number;
|
||||
service_count: number;
|
||||
deployment_count: number;
|
||||
cpu_usage: number;
|
||||
memory_usage: number;
|
||||
description: string;
|
||||
labels: string;
|
||||
last_sync_at: string | null;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
// 集群概要(用于多集群对比)
|
||||
export interface K8sClusterSummary {
|
||||
id: number;
|
||||
name: string;
|
||||
code: string;
|
||||
version: string;
|
||||
status: string;
|
||||
node_count: number;
|
||||
pod_count: number;
|
||||
}
|
||||
|
||||
// ===== Workload =====
|
||||
export interface K8sWorkload {
|
||||
name: string;
|
||||
namespace: string;
|
||||
kind: 'Deployment' | 'StatefulSet' | 'DaemonSet';
|
||||
replicas: number;
|
||||
ready_replicas: number;
|
||||
available_replicas: number;
|
||||
updated_replicas: number;
|
||||
images: string[];
|
||||
created_at: string;
|
||||
labels: Record<string, string>;
|
||||
annotations: Record<string, string>;
|
||||
}
|
||||
|
||||
export interface K8sDeployment extends K8sWorkload {
|
||||
strategy: string;
|
||||
revision: number;
|
||||
}
|
||||
|
||||
// ===== Pod =====
|
||||
export interface K8sPod {
|
||||
name: string;
|
||||
namespace: string;
|
||||
node: string;
|
||||
status: 'Running' | 'Pending' | 'Failed' | 'Succeeded' | 'Unknown';
|
||||
phase: string;
|
||||
pod_ip: string;
|
||||
host_ip: string;
|
||||
restart_count: number;
|
||||
cpu_request: string;
|
||||
cpu_limit: string;
|
||||
memory_request: string;
|
||||
memory_limit: string;
|
||||
created_at: string;
|
||||
labels: Record<string, string>;
|
||||
containers: K8sContainer[];
|
||||
}
|
||||
|
||||
export interface K8sContainer {
|
||||
name: string;
|
||||
image: string;
|
||||
ready: boolean;
|
||||
state: string;
|
||||
restart_count: number;
|
||||
cpu: string;
|
||||
memory: string;
|
||||
}
|
||||
|
||||
// ===== Node =====
|
||||
export interface K8sNode {
|
||||
name: string;
|
||||
role: 'master' | 'worker';
|
||||
status: 'Ready' | 'NotReady' | 'Unknown';
|
||||
version: string;
|
||||
os_image: string;
|
||||
kernel: string;
|
||||
container_runtime: string;
|
||||
cpu_capacity: string;
|
||||
memory_capacity: string;
|
||||
pod_capacity: string;
|
||||
cpu_usage: number; // 百分比
|
||||
memory_usage: number;
|
||||
pod_count: number;
|
||||
addresses: K8sNodeAddress[];
|
||||
taints: K8sTaint[];
|
||||
labels: Record<string, string>;
|
||||
}
|
||||
|
||||
export interface K8sNodeAddress {
|
||||
type: string;
|
||||
address: string;
|
||||
}
|
||||
|
||||
export interface K8sTaint {
|
||||
key: string;
|
||||
value: string;
|
||||
effect: string;
|
||||
}
|
||||
|
||||
// ===== Namespace =====
|
||||
export interface K8sNamespace {
|
||||
name: string;
|
||||
status: 'Active' | 'Terminating';
|
||||
created_at: string;
|
||||
labels: Record<string, string>;
|
||||
annotations: Record<string, string>;
|
||||
}
|
||||
|
||||
export interface K8sNamespaceDetail extends K8sNamespace {
|
||||
pod_count: number;
|
||||
service_count: number;
|
||||
deployment_count: number;
|
||||
resource_quota: Record<string, string>;
|
||||
limit_range: Record<string, string>;
|
||||
}
|
||||
|
||||
// ===== Event =====
|
||||
export interface K8sEvent {
|
||||
name: string;
|
||||
namespace: string;
|
||||
type: 'Normal' | 'Warning';
|
||||
reason: string;
|
||||
message: string;
|
||||
count: number;
|
||||
last_timestamp: string;
|
||||
first_timestamp: string;
|
||||
source_component: string;
|
||||
source_host: string;
|
||||
involved_object: string;
|
||||
}
|
||||
|
||||
export interface K8sEventSummary {
|
||||
total: number;
|
||||
warning_count: number;
|
||||
normal_count: number;
|
||||
by_reason: Array<{ reason: string; count: number }>;
|
||||
by_namespace: Array<{ namespace: string; count: number }>;
|
||||
recent: K8sEvent[];
|
||||
}
|
||||
|
||||
// ===== Resource (ConfigMap/Secret/Service/Ingress/PVC) =====
|
||||
export interface K8sResource {
|
||||
name: string;
|
||||
namespace: string;
|
||||
kind: string;
|
||||
created_at: string;
|
||||
labels: Record<string, string>;
|
||||
annotations: Record<string, string>;
|
||||
}
|
||||
|
||||
export interface K8sConfigMap extends K8sResource {
|
||||
data: Record<string, string>;
|
||||
}
|
||||
|
||||
export interface K8sSecret extends K8sResource {
|
||||
type: string;
|
||||
data: Record<string, string>; // base64 编码
|
||||
}
|
||||
|
||||
export interface K8sService extends K8sResource {
|
||||
type: 'ClusterIP' | 'NodePort' | 'LoadBalancer' | 'ExternalName';
|
||||
cluster_ip: string;
|
||||
external_ip: string;
|
||||
ports: K8sServicePort[];
|
||||
selector: Record<string, string>;
|
||||
}
|
||||
|
||||
export interface K8sServicePort {
|
||||
name: string;
|
||||
port: number;
|
||||
target_port: number | string;
|
||||
protocol: string;
|
||||
node_port?: number;
|
||||
}
|
||||
|
||||
export interface K8sIngress extends K8sResource {
|
||||
rules: K8sIngressRule[];
|
||||
tls: K8sIngressTLS[];
|
||||
}
|
||||
|
||||
export interface K8sIngressRule {
|
||||
host: string;
|
||||
paths: Array<{
|
||||
path: string;
|
||||
path_type: string;
|
||||
service_name: string;
|
||||
service_port: number | string;
|
||||
}>;
|
||||
}
|
||||
|
||||
export interface K8sIngressTLS {
|
||||
hosts: string[];
|
||||
secret_name: string;
|
||||
}
|
||||
|
||||
export interface K8sPVC extends K8sResource {
|
||||
status: 'Bound' | 'Pending' | 'Lost';
|
||||
capacity: string;
|
||||
access_modes: string[];
|
||||
storage_class: string;
|
||||
volume_name: string;
|
||||
}
|
||||
|
||||
// ===== 多集群对比 =====
|
||||
export interface K8sClusterComparison {
|
||||
clusters: Array<{
|
||||
id: number;
|
||||
name: string;
|
||||
code: string;
|
||||
version: string;
|
||||
node_count: number;
|
||||
pod_count: number;
|
||||
service_count: number;
|
||||
deployment_count: number;
|
||||
}>;
|
||||
resource_diff: Array<{
|
||||
resource_type: string;
|
||||
name: string;
|
||||
namespace: string;
|
||||
clusters: Record<string, boolean>; // cluster_code → 是否存在
|
||||
}>;
|
||||
}
|
||||
|
||||
// ===== 通用 YAML 响应 =====
|
||||
export interface K8sYamlResponse {
|
||||
yaml: string;
|
||||
resource: string;
|
||||
namespace: string;
|
||||
}
|
||||
|
||||
// ===== 容器日志参数 =====
|
||||
export interface PodLogsParams {
|
||||
clusterCode: string;
|
||||
namespace: string;
|
||||
podName: string;
|
||||
container?: string;
|
||||
tailLines?: number;
|
||||
follow?: boolean;
|
||||
previous?: boolean;
|
||||
sinceSeconds?: number;
|
||||
}
|
||||
|
||||
// ===== 容器文件 =====
|
||||
export interface PodFileEntry {
|
||||
name: string;
|
||||
is_dir: boolean;
|
||||
size: number;
|
||||
mod_time: string;
|
||||
}
|
||||
@@ -0,0 +1,217 @@
|
||||
// 监控告警模块类型定义
|
||||
// 字段与后端 alert_engine.go / agent.go JSON tag 对齐(snake_case)
|
||||
|
||||
// ===== Agent 上报指标(与后端 model.Report 一致)=====
|
||||
export interface AgentReport {
|
||||
hostname: string;
|
||||
ip: string;
|
||||
agent_version: string;
|
||||
os: string;
|
||||
kernel: string;
|
||||
cpu: CpuStat;
|
||||
memory: MemoryStat;
|
||||
swap: SwapStat;
|
||||
disks: DiskStat[];
|
||||
disk_io: DiskIOStat[];
|
||||
network: NetworkStat;
|
||||
ports: PortInfo[];
|
||||
process_top: ProcessInfo[];
|
||||
fd: FDStat;
|
||||
context_switch: ContextSwitchStat;
|
||||
heartbeat: HeartbeatStat;
|
||||
}
|
||||
|
||||
export interface CpuStat {
|
||||
usage_percent: number;
|
||||
iowait_percent: number;
|
||||
load1: number;
|
||||
load5: number;
|
||||
load15: number;
|
||||
cores: number;
|
||||
}
|
||||
|
||||
export interface MemoryStat {
|
||||
total_gb: number;
|
||||
used_gb: number;
|
||||
cached_gb: number;
|
||||
available_gb: number;
|
||||
swap_used_gb: number;
|
||||
usage_percent: number;
|
||||
}
|
||||
|
||||
export interface SwapStat {
|
||||
total_gb: number;
|
||||
used_gb: number;
|
||||
usage_percent: number;
|
||||
}
|
||||
|
||||
export interface DiskStat {
|
||||
device: string;
|
||||
mount: string;
|
||||
total_gb: number;
|
||||
used_gb: number;
|
||||
usage_percent: number;
|
||||
inode_usage_percent: number;
|
||||
}
|
||||
|
||||
export interface DiskIOStat {
|
||||
device: string;
|
||||
read_bps: number;
|
||||
write_bps: number;
|
||||
read_iops: number;
|
||||
write_iops: number;
|
||||
util_percent: number;
|
||||
}
|
||||
|
||||
export interface NetworkStat {
|
||||
tcp_established: number;
|
||||
tcp_time_wait: number;
|
||||
tcp_close_wait: number;
|
||||
tcp_total: number;
|
||||
rx_bps: number;
|
||||
tx_bps: number;
|
||||
rx_errors: number;
|
||||
tx_errors: number;
|
||||
}
|
||||
|
||||
export interface PortInfo {
|
||||
port: number;
|
||||
protocol: 'tcp' | 'tcp6' | 'udp';
|
||||
process: string;
|
||||
pid: number;
|
||||
state: string;
|
||||
}
|
||||
|
||||
export interface ProcessInfo {
|
||||
pid: number;
|
||||
name: string;
|
||||
cmdline: string;
|
||||
user: string;
|
||||
cpu_percent: number;
|
||||
memory_percent: number;
|
||||
fds: number;
|
||||
}
|
||||
|
||||
export interface FDStat {
|
||||
allocated: number;
|
||||
max: number; // -1 表示无限制
|
||||
usage_percent: number;
|
||||
}
|
||||
|
||||
export interface ContextSwitchStat {
|
||||
ctxt_per_sec: number;
|
||||
irq_per_sec: number;
|
||||
}
|
||||
|
||||
export interface HeartbeatStat {
|
||||
version: string;
|
||||
sequence: number;
|
||||
self_rss_mb: number;
|
||||
uptime_sec: number;
|
||||
}
|
||||
|
||||
// ===== 告警规则 =====
|
||||
export interface AgentRule {
|
||||
id: number;
|
||||
name: string;
|
||||
server_id: number;
|
||||
server_hostname: string;
|
||||
metric: 'cpu' | 'mem' | 'disk' | 'tcp_time_wait' | 'tcp_close_wait' | 'service_process' | 'offline' | 'port_down' | 'fd';
|
||||
operator: '>' | '<' | '>=' | '<=' | '==' | '!=';
|
||||
threshold: number;
|
||||
duration_sec: number;
|
||||
severity: 'critical' | 'warning' | 'info';
|
||||
enabled: boolean;
|
||||
notify_channels: number[];
|
||||
description: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
// ===== 告警事件 =====
|
||||
export interface MonitorAlert {
|
||||
id: number;
|
||||
rule_id: number;
|
||||
rule_name: string;
|
||||
server_id: number;
|
||||
server_hostname: string;
|
||||
severity: 'critical' | 'warning' | 'info';
|
||||
status: 'firing' | 'resolved';
|
||||
value: number;
|
||||
threshold: number;
|
||||
message: string;
|
||||
started_at: string;
|
||||
resolved_at: string | null;
|
||||
notified: boolean;
|
||||
}
|
||||
|
||||
// ===== 告警联系人 =====
|
||||
export interface AlertContact {
|
||||
id: number;
|
||||
name: string;
|
||||
channel_type: 'feishu' | 'dingtalk' | 'wechat' | 'webhook';
|
||||
webhook_url: string;
|
||||
phone: string;
|
||||
email: string;
|
||||
enabled: boolean;
|
||||
description: string;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface AlertContactGroup {
|
||||
id: number;
|
||||
name: string;
|
||||
description: string;
|
||||
contact_ids: number[];
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
// ===== 通知渠道(兼容旧版)=====
|
||||
export interface AlertChannel {
|
||||
id: number;
|
||||
name: string;
|
||||
type: 'feishu' | 'dingtalk' | 'wechat' | 'email' | 'sms' | 'webhook';
|
||||
config: string; // JSON string
|
||||
enabled: boolean;
|
||||
description: string;
|
||||
}
|
||||
|
||||
// ===== 健康探针 =====
|
||||
export interface HealthProbe {
|
||||
id: number;
|
||||
server_id: number;
|
||||
name: string;
|
||||
type: 'http' | 'tcp' | 'exec';
|
||||
target: string; // URL / host:port / shell command
|
||||
interval_sec: number;
|
||||
timeout_sec: number;
|
||||
healthy_threshold: number;
|
||||
unhealthy_threshold: number;
|
||||
enabled: boolean;
|
||||
last_status: 'healthy' | 'unhealthy' | 'unknown';
|
||||
last_checked_at: string;
|
||||
}
|
||||
|
||||
// ===== 端口监控策略 =====
|
||||
export interface PortMonitorPolicy {
|
||||
server_id: number;
|
||||
filter_mode: 'whitelist' | 'blacklist';
|
||||
whitelist_ports: number[];
|
||||
blacklist_processes: string[];
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
// ===== Prometheus 数据源 =====
|
||||
export interface PrometheusDatasource {
|
||||
id: number;
|
||||
name: string;
|
||||
url: string;
|
||||
auth_type: 'none' | 'basic' | 'token';
|
||||
username: string;
|
||||
password: string;
|
||||
token: string;
|
||||
enabled: boolean;
|
||||
is_default: boolean;
|
||||
description: string;
|
||||
created_at: string;
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
// 应用发布模块类型定义
|
||||
// 字段与后端 pipeline.go / credential.go JSON tag 对齐(snake_case)
|
||||
|
||||
// ===== 流水线 =====
|
||||
export interface Pipeline {
|
||||
id: number;
|
||||
name: string;
|
||||
description: string;
|
||||
project_id: number;
|
||||
target_type: 'ssh' | 'kubernetes';
|
||||
status: 'idle' | 'running' | 'success' | 'failed' | 'queued';
|
||||
max_executors: number;
|
||||
trigger_mode: 'manual' | 'webhook' | 'schedule';
|
||||
cron_expr: string;
|
||||
stages: PipelineStage[];
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
export interface PipelineStage {
|
||||
id: number;
|
||||
name: string;
|
||||
type: 'deploy' | 'build' | 'test' | 'custom';
|
||||
sequence: number;
|
||||
target_type: 'ssh' | 'kubernetes';
|
||||
server_ids: number[];
|
||||
cluster_code: string;
|
||||
namespace: string;
|
||||
workload_name: string;
|
||||
tool: string;
|
||||
command: string;
|
||||
artifact_path: string;
|
||||
image: string;
|
||||
registry_id: number;
|
||||
dockerfile: string;
|
||||
env_vars: Record<string, string>;
|
||||
timeout: number;
|
||||
continue_on_failure: boolean;
|
||||
}
|
||||
|
||||
// ===== 流水线运行 =====
|
||||
export interface PipelineRun {
|
||||
id: number;
|
||||
pipeline_id: number;
|
||||
pipeline_name: string;
|
||||
status: 'queued' | 'running' | 'success' | 'failed' | 'aborted';
|
||||
trigger: 'manual' | 'webhook' | 'schedule';
|
||||
trigger_by: string;
|
||||
started_at: string;
|
||||
completed_at: string;
|
||||
duration: number;
|
||||
stages: PipelineRunStage[];
|
||||
commit_id: string;
|
||||
branch: string;
|
||||
}
|
||||
|
||||
export interface PipelineRunStage {
|
||||
id: number;
|
||||
stage_id: number;
|
||||
stage_name: string;
|
||||
status: 'pending' | 'running' | 'success' | 'failed' | 'skipped';
|
||||
started_at: string;
|
||||
completed_at: string;
|
||||
duration: number;
|
||||
logs: string;
|
||||
output: string;
|
||||
}
|
||||
|
||||
// ===== 凭证 =====
|
||||
export interface Credential {
|
||||
id: number;
|
||||
name: string;
|
||||
type: 'ssh_password' | 'ssh_key' | 'registry' | 'token' | 'vault';
|
||||
username: string;
|
||||
password: string;
|
||||
ssh_key: string;
|
||||
registry_url: string;
|
||||
token: string;
|
||||
description: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
// ===== 发布工具 =====
|
||||
export interface DeployTool {
|
||||
id: number;
|
||||
name: string;
|
||||
type: 'preinstalled' | 'lazyload';
|
||||
default_version: string;
|
||||
versions: string[];
|
||||
install_cmd: string;
|
||||
description: string;
|
||||
enabled: boolean;
|
||||
}
|
||||
|
||||
// ===== 发布仓库 =====
|
||||
export interface DeployRepo {
|
||||
id: number;
|
||||
name: string;
|
||||
url: string;
|
||||
branch: string;
|
||||
credential_id: number;
|
||||
webhook_url: string;
|
||||
webhook_secret: string;
|
||||
description: string;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
// ===== 镜像仓库 =====
|
||||
export interface DeployRegistry {
|
||||
id: number;
|
||||
name: string;
|
||||
url: string;
|
||||
username: string;
|
||||
password: string;
|
||||
type: 'public' | 'private';
|
||||
description: string;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
// ===== 发布 RBAC =====
|
||||
export interface DeployPermission {
|
||||
id: number;
|
||||
user_id: number;
|
||||
pipeline_id: number;
|
||||
role: 'viewer' | 'operator' | 'admin';
|
||||
can_trigger: boolean;
|
||||
can_edit: boolean;
|
||||
can_delete: boolean;
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
// 服务器资产模块类型定义
|
||||
// 字段与后端 server.go / asset_servers 表 JSON tag 对齐(snake_case)
|
||||
|
||||
// ===== 服务器 =====
|
||||
export interface AssetServer {
|
||||
id: number;
|
||||
hostname: string;
|
||||
ip: string;
|
||||
port: number; // SSH 端口,默认 22
|
||||
os: string;
|
||||
os_version: string;
|
||||
kernel: string;
|
||||
arch: string;
|
||||
cpu_cores: number;
|
||||
cpu_model: string;
|
||||
memory_gb: number;
|
||||
disk_gb: number;
|
||||
status: 'online' | 'offline' | 'maintenance';
|
||||
agent_status: 'online' | 'offline' | 'installing' | 'failed';
|
||||
agent_version: string;
|
||||
agent_last_seen: string;
|
||||
region: string;
|
||||
zone: string;
|
||||
environment: 'dev' | 'test' | 'staging' | 'prod';
|
||||
tags: string[];
|
||||
auth_type: 'password' | 'ssh_key';
|
||||
username: string;
|
||||
password: string; // 加密存储
|
||||
ssh_key: string; // 加密存储
|
||||
description: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
// 服务器简要信息(用于列表)
|
||||
export interface AssetServerListItem {
|
||||
id: number;
|
||||
hostname: string;
|
||||
ip: string;
|
||||
os: string;
|
||||
status: string;
|
||||
agent_status: string;
|
||||
agent_version: string;
|
||||
cpu_cores: number;
|
||||
memory_gb: number;
|
||||
disk_gb: number;
|
||||
region: string;
|
||||
environment: string;
|
||||
last_seen: string;
|
||||
}
|
||||
|
||||
// CSV 批量导入:仅需 hostname + ip + port
|
||||
export interface ServerCsvRow {
|
||||
hostname: string;
|
||||
ip: string;
|
||||
port?: number;
|
||||
}
|
||||
|
||||
// ===== 云账号 =====
|
||||
export interface CloudAccount {
|
||||
id: number;
|
||||
name: string;
|
||||
provider: 'aws' | 'aliyun' | 'huawei' | 'tencent' | 'azure';
|
||||
access_key_id: string;
|
||||
access_key_secret: string;
|
||||
region: string;
|
||||
enabled: boolean;
|
||||
last_sync_at: string;
|
||||
sync_status: 'success' | 'failed' | 'syncing';
|
||||
sync_message: string;
|
||||
description: string;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
// ===== 域名 =====
|
||||
export interface Domain {
|
||||
id: number;
|
||||
name: string;
|
||||
provider: string;
|
||||
expire_at: string;
|
||||
auto_renew: boolean;
|
||||
status: 'active' | 'expired' | 'pending';
|
||||
owner: string;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
// ===== 区域 =====
|
||||
export interface Region {
|
||||
id: number;
|
||||
name: string;
|
||||
provider: string;
|
||||
code: string;
|
||||
description: string;
|
||||
}
|
||||
|
||||
// ===== 平台 =====
|
||||
export interface Platform {
|
||||
id: number;
|
||||
name: string;
|
||||
provider: string;
|
||||
type: 'public' | 'private' | 'hybrid';
|
||||
description: string;
|
||||
}
|
||||
|
||||
// ===== 云账单 =====
|
||||
export interface CloudBill {
|
||||
id: number;
|
||||
account_id: number;
|
||||
account_name: string;
|
||||
provider: string;
|
||||
period: string; // YYYY-MM
|
||||
cost: number;
|
||||
currency: string;
|
||||
service_breakdown: Array<{
|
||||
service: string;
|
||||
cost: number;
|
||||
}>;
|
||||
trend: number; // 环比变化百分比
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
// ===== 云服务器实例(同步过来)=====
|
||||
export interface CloudInstance {
|
||||
id: string;
|
||||
instance_id: string;
|
||||
name: string;
|
||||
provider: string;
|
||||
region: string;
|
||||
zone: string;
|
||||
instance_type: string;
|
||||
status: 'running' | 'stopped' | 'terminated';
|
||||
os: string;
|
||||
cpu: number;
|
||||
memory: number;
|
||||
public_ip: string;
|
||||
private_ip: string;
|
||||
created_at: string;
|
||||
expire_at: string;
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
// 用户与权限模块类型定义
|
||||
|
||||
export interface SystemUser {
|
||||
id: number;
|
||||
username: string;
|
||||
nickname: string;
|
||||
real_name: string;
|
||||
email: string;
|
||||
phone: string;
|
||||
avatar: string;
|
||||
roles: string[];
|
||||
permissions: string[];
|
||||
status: number; // 0=disabled, 1=enabled
|
||||
is_admin: boolean;
|
||||
auth_source: 'local' | 'ldap';
|
||||
last_login: string;
|
||||
last_login_ip: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
export interface SystemRole {
|
||||
id: number;
|
||||
name: string;
|
||||
code: string;
|
||||
description: string;
|
||||
permissions: string[];
|
||||
user_count: number;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface LoginRequest {
|
||||
username: string;
|
||||
password: string;
|
||||
captcha?: string;
|
||||
}
|
||||
|
||||
export interface LoginResponse {
|
||||
token: string;
|
||||
user: SystemUser;
|
||||
expires_at: string;
|
||||
}
|
||||
|
||||
export interface LdapConfig {
|
||||
enabled: boolean;
|
||||
server: string;
|
||||
port: number;
|
||||
bind_dn: string;
|
||||
bind_password: string;
|
||||
search_base: string;
|
||||
search_filter: string;
|
||||
use_ssl: boolean;
|
||||
auto_create_user: boolean;
|
||||
default_role_id: number;
|
||||
}
|
||||
|
||||
export interface AuditLog {
|
||||
id: number;
|
||||
user_id: number;
|
||||
username: string;
|
||||
module: string;
|
||||
action: string;
|
||||
method: string;
|
||||
path: string;
|
||||
resource: string;
|
||||
resource_id: string;
|
||||
ip: string;
|
||||
user_agent: string;
|
||||
status: number;
|
||||
result: 'success' | 'failure';
|
||||
message: string;
|
||||
request_body: string;
|
||||
response_code: number;
|
||||
duration_ms: number;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface SystemSetting {
|
||||
key: string;
|
||||
value: string;
|
||||
type: 'string' | 'number' | 'boolean' | 'json';
|
||||
description: string;
|
||||
category: string;
|
||||
updated_at: string;
|
||||
}
|
||||
Reference in new issue
Block a user