feat: 添加视频服务器双机热备状态
This commit is contained in:
@@ -136,6 +136,17 @@ export const unwrapResponse = <T>(resp: HttpResponse<T>) => {
|
||||
return data;
|
||||
};
|
||||
|
||||
export const unwrapNullableResponse = <T>(resp: HttpResponse<T>) => {
|
||||
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<void>) => {
|
||||
const [err, , result] = resp;
|
||||
|
||||
Reference in New Issue
Block a user