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;