From c75338cb70e6b5810da6c568db892e95e2c329e0 Mon Sep 17 00:00:00 2001 From: yangsy Date: Fri, 10 Apr 2026 15:11:58 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=99=A8=E5=8F=8C=E6=9C=BA=E7=83=AD=E5=A4=87?= =?UTF-8?q?=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/domain/biz/high-available/index.ts | 5 ++ src/apis/domain/biz/index.ts | 1 + .../biz/other/ndm-service-available.ts | 25 ++++++- .../device/device-card/ndm-server/index.ts | 3 +- .../ndm-server/server-current-diag.vue | 3 +- .../ndm-server/server-high-available.vue | 67 +++++++++++++++++++ src/utils/http-client.ts | 11 +++ 7 files changed, 111 insertions(+), 4 deletions(-) create mode 100644 src/apis/domain/biz/high-available/index.ts create mode 100644 src/components/device/device-card/ndm-server/server-high-available.vue diff --git a/src/apis/domain/biz/high-available/index.ts b/src/apis/domain/biz/high-available/index.ts new file mode 100644 index 0000000..7a6c93a --- /dev/null +++ b/src/apis/domain/biz/high-available/index.ts @@ -0,0 +1,5 @@ +export interface HighAvailable { + pyip: string; + vip: string; + changeDate: string; +} diff --git a/src/apis/domain/biz/index.ts b/src/apis/domain/biz/index.ts index 35291e5..d2a4114 100644 --- a/src/apis/domain/biz/index.ts +++ b/src/apis/domain/biz/index.ts @@ -1,3 +1,4 @@ export * from './diag'; +export * from './high-available'; export * from './link-description'; export * from './station'; diff --git a/src/apis/request/biz/other/ndm-service-available.ts b/src/apis/request/biz/other/ndm-service-available.ts index 60b6a66..0358c2e 100644 --- a/src/apis/request/biz/other/ndm-service-available.ts +++ b/src/apis/request/biz/other/ndm-service-available.ts @@ -1,5 +1,26 @@ -import { ndmClient, userClient, type MediaServerStatus, type SendRtpInfo, type Station } from '@/apis'; -import { unwrapResponse } from '@/utils'; +import { ndmClient, userClient, type HighAvailable, type MediaServerStatus, type SendRtpInfo, type Station } from '@/apis'; +import { unwrapNullableResponse, unwrapResponse } from '@/utils'; +import destr from 'destr'; + +// { +// "code": 0, +// "data": "{pyip:\"10.18.128.14\",vip:\"10.18.128.6\",changeDate:\"2026-03-23 15:55:00\"}", +// "msg": "ok", +// "path": null, +// "extra": null, +// "timestamp": "1774421387908", +// "errorMsg": "", +// "isSuccess": true +// } +export const getHighAvailableApi = async (options?: { stationCode?: Station['code']; signal?: AbortSignal }) => { + const { stationCode, signal } = options ?? {}; + const client = stationCode ? ndmClient : userClient; + const prefix = stationCode ? `/${stationCode}` : ''; + const endpoint = `${prefix}/api/ndm/ndmServiceAvailable/highAvailable/get`; + const resp = await client.get(endpoint, { signal }); + const data = unwrapNullableResponse(resp); + return destr(data); +}; export const getAllPushApi = async (options?: { stationCode?: Station['code']; signal?: AbortSignal }) => { const { stationCode, signal } = options ?? {}; diff --git a/src/components/device/device-card/ndm-server/index.ts b/src/components/device/device-card/ndm-server/index.ts index 6b8db71..dbfccb9 100644 --- a/src/components/device/device-card/ndm-server/index.ts +++ b/src/components/device/device-card/ndm-server/index.ts @@ -1,8 +1,9 @@ import ServerAlive from './server-alive.vue'; import ServerCard from './server-card.vue'; import ServerCurrentDiag from './server-current-diag.vue'; +import ServerHighAvailable from './server-high-available.vue'; import ServerHistoryDiag from './server-history-diag.vue'; import ServerStreamPush from './server-stream-push.vue'; import ServerUpdate from './server-update.vue'; -export { ServerAlive, ServerCard, ServerCurrentDiag, ServerHistoryDiag, ServerUpdate, ServerStreamPush }; +export { ServerAlive, ServerCard, ServerCurrentDiag, ServerHighAvailable, ServerHistoryDiag, ServerUpdate, ServerStreamPush }; diff --git a/src/components/device/device-card/ndm-server/server-current-diag.vue b/src/components/device/device-card/ndm-server/server-current-diag.vue index 6c73766..e2db05a 100644 --- a/src/components/device/device-card/ndm-server/server-current-diag.vue +++ b/src/components/device/device-card/ndm-server/server-current-diag.vue @@ -1,6 +1,6 @@ + + + + diff --git a/src/utils/http-client.ts b/src/utils/http-client.ts index cd64dae..9dc642f 100644 --- a/src/utils/http-client.ts +++ b/src/utils/http-client.ts @@ -136,6 +136,17 @@ export const unwrapResponse = (resp: HttpResponse) => { return data; }; +export const unwrapNullableResponse = (resp: HttpResponse) => { + const [err, data, result] = resp; + if (err) throw err; + if (result) { + const { isSuccess, path, msg, errorMsg } = result; + if (!isSuccess) throw new Error(`${path ? `${path}: ` : ''}${msg || errorMsg || '请求失败'}`); + } + if (data === undefined) throw new Error('响应数据不存在'); + return data; +}; + // 针对没有数据的响应,直接判断是否存在错误 export const unwrapVoidResponse = (resp: HttpResponse) => { const [err, , result] = resp;