Просмотр исходного кода

refactor: 优化如果处于小地图编辑状态,切换租户时候,返回布局列表逻辑

qindao 1 год назад
Родитель
Сommit
5fbd083020

+ 4 - 7
src/layout/components/Header/SwitchTenant.vue

@@ -21,12 +21,8 @@
   import { useTargetTenantIdSetting } from '@/utils/useTargetTenantIdSetting';
   import { replaceParams } from '@/utils/helper/treeHelper';
   import { useRoute } from 'vue-router';
-  import useMiniMap from '@/views/map-config/mini-map/use-mini-map.ts';
   import router from '@/router';
 
-  const miniMap = useMiniMap();
-  const { isInConfigEditor } = miniMap;
-
   interface TenantOption {
     label: string;
     value: string;
@@ -40,7 +36,8 @@
   });
   const currentTenant = ref(localTId ? Number(localTId) : Number(tenantId.value));
   const options = ref<TenantOption[]>([]);
-  const MESSAGE_ALARM_CONFIG_PAGE = 'MessageAlarmConfig';
+  const PAGE_MESSAGE_ALARM_CONFIG = 'MessageAlarmConfig';
+  const PAGE_LAYOUT_CONFIG = ['LayoutSceneConfig', 'LayoutCameraConfig'];
 
   onMounted(() => {
     queryListTenant().then((res) => {
@@ -64,10 +61,10 @@
         /**
          * 如果处于小地图编辑状态,切换租户时候,返回布局列表
          */
-        if (isInConfigEditor(route.name)) {
+        if (PAGE_LAYOUT_CONFIG.includes(route.name as string)) {
           sessionStorage.removeItem('selectCompanyId'); //切换租户的时候,下拉公司列表清空
           router.back();
-        } else if (route.name === MESSAGE_ALARM_CONFIG_PAGE) {
+        } else if (route.name === PAGE_MESSAGE_ALARM_CONFIG) {
           /* 当页面为报警推送详情,切换租户,返回列表页面 */
           router.push({
             name: 'MessageAlarm',

+ 2 - 2
src/views/map-config/mini-map/use-mini-map.ts

@@ -31,12 +31,12 @@ export const useMiniMap = defineStore('mini-map', () => {
   /**
    * 切换租户管理的时候需要判断是否在布局编辑器里面
    */
-  const isInConfigEditor = ((routerName)=>{
+  const isInConfigEditor = (routerName: string) => {
     if (routerName.includes('LayoutSceneConfig') || routerName.includes('LayoutCameraConfig')) {
       return true;
     }
     return false;
-  })
+  };
 
   // const shopCameraList = ref<ShopMapCamera[]>([]);