diff --git a/server/routers/base_router.py b/server/routers/base_router.py index 2cf61851..48c0290a 100644 --- a/server/routers/base_router.py +++ b/server/routers/base_router.py @@ -12,6 +12,11 @@ base = APIRouter() async def route_index(): return {"message": "You Got It!"} +@base.get("/health") +async def health_check(): + """简单的健康检查接口""" + return {"status": "ok", "message": "服务正常运行"} + @base.get("/config") def get_config(current_user: User = Depends(get_admin_user)): return config.dump_config() diff --git a/web/src/apis/base.js b/web/src/apis/base.js index aad20564..54ef4b56 100644 --- a/web/src/apis/base.js +++ b/web/src/apis/base.js @@ -153,4 +153,22 @@ export function apiPut(url, data = {}, options = {}, requiresAuth = false) { */ export function apiDelete(url, options = {}, requiresAuth = false) { return apiRequest(url, { method: 'DELETE', ...options }, requiresAuth) +} + +/** + * 健康检查API + */ +export const healthApi = { + /** + * 检查服务端健康状态 + * @returns {Promise} - 健康检查结果 + */ + async checkHealth() { + try { + const response = await apiGet('/api/health') + return { status: 'ok', data: response } + } catch (error) { + return { status: 'error', error: error.message } + } + } } \ No newline at end of file diff --git a/web/src/views/DataBaseView.vue b/web/src/views/DataBaseView.vue index 3cf17920..8f1d91c3 100644 --- a/web/src/views/DataBaseView.vue +++ b/web/src/views/DataBaseView.vue @@ -2,7 +2,12 @@