WholeProcessPlatform/frontend/src/store/modules/ui.ts
2026-08-31 14:04:06 +08:00

100 lines
2.9 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { defineStore } from 'pinia';
import { ref } from 'vue';
export const useUiStore = defineStore('ui', () => {
// 右侧抽屉状态
const drawerOpen = ref(true);
const mapType = ref('2D');
const mapSwitchCompletedTick = ref(0);
// 3d 流域三维漫游
const isRoaming = ref(false);
// 智慧装备
const isSmartEquipment = ref(false);
// dim 切换时跳过漫游相机还原(由地图模式切换自行处理)
const skipRoamCameraRestore = ref(false);
// 搜索抽屉状态
const searchDrawerOpen = ref(false);
// 全局兜底抽屉状态AppMain 通用抽屉,给未自带抽屉的页面用)
const globalDrawerOpen = ref(false);
// 是否处于锚点搜索状态(选中命中 DRAWER_STTP_CODES 的锚点时 true清空/切页等 false
const isSearchActive = ref(false);
// 地图控件(地图控制器/底图切换器位置覆盖值null 表示回退组件自身默认(非电站专题页样式)
const mapControlsPosition = ref<{
controllerRight: string | null;
controllerBottom: string | null;
baselayerRight: string | null;
baselayerBottom: string | null;
}>({
controllerRight: null,
controllerBottom: null,
baselayerRight: null,
baselayerBottom: null
});
// 切换抽屉状态
const toggleDrawer = () => {
drawerOpen.value = !drawerOpen.value;
};
// 设置抽屉状态
const setDrawerOpen = (open: boolean) => {
drawerOpen.value = open;
};
// 设置搜索抽屉状态
const setSearchDrawerOpen = (open: boolean) => {
searchDrawerOpen.value = open;
};
// 设置全局兜底抽屉状态
const setGlobalDrawerOpen = (open: boolean) => {
globalDrawerOpen.value = open;
};
// 设置锚点搜索状态
const setIsSearchActive = (active: boolean) => {
isSearchActive.value = active;
};
// 部分更新地图控件位置覆盖
const setMapControlsPosition = (
partial: Partial<{
controllerRight: string | null;
controllerBottom: string | null;
baselayerRight: string | null;
baselayerBottom: string | null;
}>
) => {
mapControlsPosition.value = { ...mapControlsPosition.value, ...partial };
};
// 重置地图控件位置覆盖(恢复组件自身默认样式,即非电站专题页样式)
const resetMapControlsPosition = () => {
mapControlsPosition.value = {
controllerRight: null,
controllerBottom: null,
baselayerRight: null,
baselayerBottom: null
};
};
const markMapSwitchCompleted = () => {
mapSwitchCompletedTick.value += 1;
};
return {
drawerOpen,
isRoaming,
isSmartEquipment,
skipRoamCameraRestore,
toggleDrawer,
setDrawerOpen,
setSearchDrawerOpen,
searchDrawerOpen,
globalDrawerOpen,
setGlobalDrawerOpen,
isSearchActive,
setIsSearchActive,
mapControlsPosition,
setMapControlsPosition,
resetMapControlsPosition,
mapType,
mapSwitchCompletedTick,
markMapSwitchCompleted
};
});