refactor: 重构项目结构
- 优化 `车站-设备-告警` 轮询机制 - 改进设备卡片的布局 - 支持修改设备 - 告警轮询中获取完整告警数据 - 车站告警详情支持导出完整的 `今日告警列表` - 支持将状态持久化到 `IndexedDB` - 新增轮询控制 (调试模式) - 新增离线开发模式 (调试模式) - 新增 `IndexedDB` 数据控制 (调试模式)
This commit is contained in:
1
src/apis/request/biz/storage/index.ts
Normal file
1
src/apis/request/biz/storage/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './ndm-nvr';
|
||||
81
src/apis/request/biz/storage/ndm-nvr.ts
Normal file
81
src/apis/request/biz/storage/ndm-nvr.ts
Normal file
@@ -0,0 +1,81 @@
|
||||
import { ndmClient, userClient, type NdmNvrPageQuery, type NdmNvrResultVO, type NdmNvrSaveVO, type NdmNvrUpdateVO, type PageParams, type PageResult, type Station } from '@/apis';
|
||||
|
||||
export const pageNvrPageApi = async (pageQuery: PageParams<NdmNvrPageQuery>, options?: { stationCode: Station['code']; signal?: AbortSignal }) => {
|
||||
const { stationCode, signal } = options ?? {};
|
||||
const client = stationCode ? ndmClient : userClient;
|
||||
const prefix = stationCode ? `/${stationCode}` : '';
|
||||
const endpoint = `${prefix}/api/ndm/ndmNvr/page`;
|
||||
const resp = await client.post<PageResult<NdmNvrResultVO>>(endpoint, pageQuery, { signal });
|
||||
const [err, data] = resp;
|
||||
if (err) throw err;
|
||||
if (!data) throw new Error(`${data}`);
|
||||
return data;
|
||||
};
|
||||
|
||||
export const detailNvrApi = async (id: string, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
|
||||
const { stationCode, signal } = options ?? {};
|
||||
const client = stationCode ? ndmClient : userClient;
|
||||
const prefix = stationCode ? `/${stationCode}` : '';
|
||||
const endpoint = `${prefix}/api/ndm/ndmNvr/detail`;
|
||||
const resp = await client.get<NdmNvrResultVO>(endpoint, { params: { id }, signal });
|
||||
const [err, data] = resp;
|
||||
if (err) throw err;
|
||||
if (!data) throw new Error(`${data}`);
|
||||
return data;
|
||||
};
|
||||
|
||||
export const saveNvrApi = async (saveVO: NdmNvrSaveVO, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
|
||||
const { stationCode, signal } = options ?? {};
|
||||
const client = stationCode ? ndmClient : userClient;
|
||||
const prefix = stationCode ? `/${stationCode}` : '';
|
||||
const endpoint = `${prefix}/api/ndm/ndmNvr`;
|
||||
const resp = await client.post<NdmNvrResultVO>(endpoint, saveVO, { signal });
|
||||
const [err, data] = resp;
|
||||
if (err) throw err;
|
||||
if (!data) throw new Error(`${data}`);
|
||||
return data;
|
||||
};
|
||||
|
||||
export const updateNvrApi = async (updateVO: NdmNvrUpdateVO, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
|
||||
const { stationCode, signal } = options ?? {};
|
||||
const client = stationCode ? ndmClient : userClient;
|
||||
const prefix = stationCode ? `/${stationCode}` : '';
|
||||
const endpoint = `${prefix}/api/ndm/ndmNvr`;
|
||||
const resp = await client.put<NdmNvrResultVO>(endpoint, updateVO, { signal });
|
||||
const [err, data] = resp;
|
||||
if (err) throw err;
|
||||
if (!data) throw new Error(`${data}`);
|
||||
return data;
|
||||
};
|
||||
|
||||
export const deleteNvrApi = async (ids: string[], options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
|
||||
const { stationCode, signal } = options ?? {};
|
||||
const client = stationCode ? ndmClient : userClient;
|
||||
const prefix = stationCode ? `/${stationCode}` : '';
|
||||
const endpoint = `${prefix}/api/ndm/ndmNvr`;
|
||||
const resp = await client.delete<boolean>(endpoint, ids, { signal });
|
||||
const [err, data] = resp;
|
||||
if (err) throw err;
|
||||
if (!data) throw new Error(`${data}`);
|
||||
return data;
|
||||
};
|
||||
|
||||
export const probeNvrApi = async (ids: string[], options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
|
||||
const { stationCode, signal } = options ?? {};
|
||||
const client = stationCode ? ndmClient : userClient;
|
||||
const prefix = stationCode ? `/${stationCode}` : '';
|
||||
const endpoint = `${prefix}/api/ndm/ndmNvr/probeByIds`;
|
||||
const resp = await client.post<void>(endpoint, ids, { signal });
|
||||
const [err] = resp;
|
||||
if (err) throw err;
|
||||
};
|
||||
|
||||
export const syncNvrChannelsApi = async (options?: { stationCode?: string; signal?: AbortSignal }) => {
|
||||
const { stationCode, signal } = options ?? {};
|
||||
const client = stationCode ? ndmClient : userClient;
|
||||
const prefix = stationCode ? `/${stationCode}` : '';
|
||||
const endpoint = `${prefix}/api/ndm/ndmNvr/syncNvrChannels`;
|
||||
const resp = await client.get<void>(endpoint, { signal });
|
||||
const [err] = resp;
|
||||
if (err) throw err;
|
||||
};
|
||||
Reference in New Issue
Block a user