更新api.js

This commit is contained in:
2025-11-10 23:26:27 +08:00
parent 7fe6cee942
commit 4e7b02206f
2 changed files with 27 additions and 0 deletions

25
src/api/health.js Normal file
View File

@@ -0,0 +1,25 @@
import http from '../utils/http';
import { Response } from '../enums';
// --- API Functions ---
/**
* 检查服务进程是否运行正常,只要服务能响应就返回 200 OK。
* @returns {Promise<Response>}
*/
export const getHealthz = () => {
return http.get('/healthz');
};
/**
* 检查服务是否已准备好接收流量。当前实现为只要服务能响应即代表就绪。
* @returns {Promise<Response>}
*/
export const getReadyz = () => {
return http.get('/readyz');
};
export const HealthApi = {
getHealthz,
getReadyz,
};

View File

@@ -2,6 +2,7 @@ import { AreaControllerApi, DeviceApi } from './device.js';
import { PlanApi } from './plan.js';
import { UserApi } from './user.js';
import { AlarmApi } from './alarm.js'; // 导入告警API
import { HealthApi } from './health.js'; // 导入健康检查API
import { DeviceTemplateApi } from './deviceTemplate.js'; // 导入设备模板API
/**
@@ -13,6 +14,7 @@ export class ApiClient {
this.devices = DeviceApi;
this.plans = PlanApi;
this.users = UserApi;
this.health = HealthApi; // 添加健康检查API
this.alarms = AlarmApi; // 添加告警API
this.deviceTemplates = DeviceTemplateApi; // 添加设备模板API
}