refactor(vimp): 重构vimp模块的API目录与导入路径
重新梳理vimp模块的API代码结构,拆分为client、model、query、request子模块并添加统一导出入口;修正所有相关文件的导入路径,新增通用响应类型与工具函数,优化树组件的类型判断逻辑,同时新增设备查询相关API与查询hook。
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
<script setup lang="ts">
|
||||
import { NTabPane, NTabs, NTree, type TreeOverrideNodeClickBehavior, type TreeProps } from 'naive-ui';
|
||||
import { useVimpDeviceQuery } from '../api/query';
|
||||
import type { VimpChannel, VimpStation } from '../api/model';
|
||||
import { h, type CSSProperties } from 'vue';
|
||||
import { hasOwn } from '@vueuse/core';
|
||||
import { useAlarmStore } from '../stores';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useDeviceCenterQuery, type VimpChannel, type VimpStation } from '../apis';
|
||||
import { isAlarmNode, isAlarmSiteNode, isAlarmAreaNode } from '../types';
|
||||
|
||||
const { isLoading } = useVimpDeviceQuery();
|
||||
const { isLoading } = useDeviceCenterQuery();
|
||||
|
||||
const alarmStore = useAlarmStore();
|
||||
const { lineTabPanes } = storeToRefs(alarmStore);
|
||||
@@ -25,8 +24,8 @@ const overrideNodeClickBehavior: TreeOverrideNodeClickBehavior = ({ option }) =>
|
||||
|
||||
const renderNodeLabel: TreeProps['renderLabel'] = ({ option }) => {
|
||||
// 是车站节点
|
||||
if (hasOwn(option, 'online')) {
|
||||
const siteOnline = option['online'] as boolean;
|
||||
if (isAlarmSiteNode(option)) {
|
||||
const siteOnline = option.online;
|
||||
const siteNodeStyle: CSSProperties = {
|
||||
opacity: siteOnline ? 1 : 0.5,
|
||||
};
|
||||
@@ -34,8 +33,8 @@ const renderNodeLabel: TreeProps['renderLabel'] = ({ option }) => {
|
||||
}
|
||||
|
||||
// 是中间节点(一级/二级区域)
|
||||
if (!hasOwn(option, 'device') && hasOwn(option, 'site')) {
|
||||
const site = option['site'] as VimpStation;
|
||||
if (isAlarmAreaNode(option)) {
|
||||
const site = option.site;
|
||||
const nodeStyle: CSSProperties = {
|
||||
opacity: site.online ? 1 : 0.5,
|
||||
};
|
||||
@@ -43,9 +42,9 @@ const renderNodeLabel: TreeProps['renderLabel'] = ({ option }) => {
|
||||
}
|
||||
|
||||
// 是警报器节点
|
||||
if (hasOwn(option, 'alarm') && hasOwn(option, 'site')) {
|
||||
const alarm = option['alarm'] as VimpChannel;
|
||||
const site = option['site'] as VimpStation;
|
||||
if (isAlarmNode(option)) {
|
||||
const alarm = option.alarm;
|
||||
const site = option.site;
|
||||
|
||||
const alarmOnline = () => {
|
||||
return alarm.status === 1 && site.online;
|
||||
|
||||
Reference in New Issue
Block a user