Kaynağa Gözat

feat: 从url中获取targetTenantId来跳转租户

louhangfei 1 yıl önce
ebeveyn
işleme
b7bbb14c47
1 değiştirilmiş dosya ile 9 ekleme ve 0 silme
  1. 9 0
      src/layout/components/Header/SwitchTenant.vue

+ 9 - 0
src/layout/components/Header/SwitchTenant.vue

@@ -21,6 +21,7 @@
   import { useTargetTenantIdSetting } from '@/utils/useTargetTenantIdSetting';
   import { replaceParams } from '@/utils/helper/treeHelper';
   import router from '@/router';
+  import { useRoute } from 'vue-router';
 
   interface TenantOption {
     label: string;
@@ -37,6 +38,8 @@
   const currentTenant = ref(localTId ? Number(localTId) : Number(tenantId.value));
   const options = ref<TenantOption[]>([]);
 
+  const route = useRoute();
+
   const optionsShown = computed(() => {
     // 列表空
     if (!options.value.length) return false;
@@ -46,6 +49,12 @@
   });
 
   onMounted(() => {
+    const routeTenantId = route.query.targetTenantId as string;
+    if (routeTenantId) {
+      const nextTenantId = Number(routeTenantId);
+      currentTenant.value = nextTenantId;
+      setValue(routeTenantId);
+    }
     queryListTenant().then((res) => {
       if (!res) return;
       options.value = replaceParams(res || [], 'tenantName', 'id');