refactor(vimp): 重构模块结构,优化代码组织

- 将设备中心查询逻辑从API层抽取至composables目录,封装为useDeviceCenterQuery组合式函数
- 拆分camera、alarm的状态管理为独立store文件,新增资源面板搜索状态store
- 更新相关组件的依赖导入路径,清理冗余导出并调整导出列表
This commit is contained in:
yangsy
2026-05-28 10:47:28 +08:00
parent 67dccc5011
commit bd1cc0483b
11 changed files with 23 additions and 10 deletions
-1
View File
@@ -1,4 +1,3 @@
export * from './client'; export * from './client';
export * from './model'; export * from './model';
export * from './query';
export * from './request'; export * from './request';
-1
View File
@@ -1 +0,0 @@
export * from './device-center-query';
+1 -1
View File
@@ -3,7 +3,7 @@ import { NTabPane, NTabs, NTree, type TreeOverrideNodeClickBehavior, type TreePr
import { h, type CSSProperties } from 'vue'; import { h, type CSSProperties } from 'vue';
import { useAlarmStore } from '../stores'; import { useAlarmStore } from '../stores';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
import { useDeviceCenterQuery } from '../apis'; import { useDeviceCenterQuery } from '../composables';
import { isAlarmNode, isAlarmSiteNode, isAlarmAreaNode } from '../types'; import { isAlarmNode, isAlarmSiteNode, isAlarmAreaNode } from '../types';
const { isLoading } = useDeviceCenterQuery(); const { isLoading } = useDeviceCenterQuery();
+1 -1
View File
@@ -3,7 +3,7 @@ import { NTabPane, NTabs, NTree, type TreeOverrideNodeClickBehavior, type TreePr
import { h, type CSSProperties } from 'vue'; import { h, type CSSProperties } from 'vue';
import { useCameraStore } from '../stores'; import { useCameraStore } from '../stores';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
import { useDeviceCenterQuery } from '../apis'; import { useDeviceCenterQuery } from '../composables';
import { isCameraNode, isCameraSiteNode, isCameraAreaNode } from '../types'; import { isCameraNode, isCameraSiteNode, isCameraAreaNode } from '../types';
const { isLoading } = useDeviceCenterQuery(); const { isLoading } = useDeviceCenterQuery();
+1
View File
@@ -0,0 +1 @@
export * from './query';
@@ -0,0 +1 @@
export * from './use-device-center-query';
@@ -1,11 +1,11 @@
import { useQuery } from '@tanstack/vue-query'; import { useQuery } from '@tanstack/vue-query';
import { computed } from 'vue'; import { computed } from 'vue';
import { catalogChannelApi, catalogAllDeviceApi } from '../request'; import { catalogChannelApi, catalogAllDeviceApi } from '../../apis/request';
import type { AxiosRequestConfig } from 'axios'; import type { AxiosRequestConfig } from 'axios';
import axios from 'axios'; import axios from 'axios';
import type { CodeArea, CodeLines, CodeSites } from '../../types'; import type { CodeArea, CodeLines, CodeSites } from '../../types';
import { useCameraStore, useAlarmStore } from '../../stores'; import { useCameraStore, useAlarmStore } from '../../stores';
import type { VimpChannel } from '../model'; import type { VimpChannel } from '../../apis/model';
export const useDeviceCenterQuery = () => { export const useDeviceCenterQuery = () => {
const cameraStore = useCameraStore(); const cameraStore = useCameraStore();
@@ -14,7 +14,7 @@ interface BuildLineTabPanesParams {
codeTrainAreas: CodeArea[]; codeTrainAreas: CodeArea[];
} }
export const useAlarmStore = defineStore('vimp-alarm', () => { export const useAlarmStore = defineStore('vimp-alarm-store', () => {
const lineTabPanes = ref<AlarmLineTabPane[]>([]); const lineTabPanes = ref<AlarmLineTabPane[]>([]);
const buildLineTabPanes = (params: BuildLineTabPanesParams) => { const buildLineTabPanes = (params: BuildLineTabPanesParams) => {
@@ -14,7 +14,7 @@ interface BuildLineTabPanesParams {
codeTrainAreas: CodeArea[]; codeTrainAreas: CodeArea[];
} }
export const useCameraStore = defineStore('vimp-camera', () => { export const useCameraStore = defineStore('vimp-camera-store', () => {
const lineTabPanes = ref<CameraLineTabPane[]>([]); const lineTabPanes = ref<CameraLineTabPane[]>([]);
const buildLineTabPanes = (params: BuildLineTabPanesParams) => { const buildLineTabPanes = (params: BuildLineTabPanesParams) => {
+3 -2
View File
@@ -1,2 +1,3 @@
export * from './camera-store'; export * from './alarm';
export * from './alarm-store'; export * from './camera';
export * from './resource-panel';
+12
View File
@@ -0,0 +1,12 @@
import { defineStore } from 'pinia';
import { ref } from 'vue';
export const useResourcePanelStore = defineStore('vimp-resource-panel', () => {
const showSearch = ref<boolean>(false);
const searchText = ref<string>('');
return {
showSearch,
searchText,
};
});