wangfumin 3 месяцев назад
Родитель
Сommit
616a60137d
2 измененных файлов с 12 добавлено и 4 удалено
  1. 2 2
      src/api/instance.ts
  2. 10 2
      src/views/setting/select-back.vue

+ 2 - 2
src/api/instance.ts

@@ -37,8 +37,8 @@ const gotoLogin = () => {
     //   setTimeout(() => location.reload())
     // });
   } else {
-    const loginHref = `/admin/#/statistics/scene`
-    location.href = loginHref + '?redirect=' + escape(location.href)
+    // const loginHref = `/admin/#/statistics/scene`
+    // location.href = loginHref + '?redirect=' + escape(location.href)
   }
 };
 

+ 10 - 2
src/views/setting/select-back.vue

@@ -51,7 +51,7 @@
 
 <script lang="ts" setup>
 import { Dropdown, MenuItem, Menu } from "ant-design-vue";
-import { computed, ref } from "vue";
+import { computed, ref, watch, onMounted } from "vue";
 import BackItem from "./back-item.vue";
 import { fetchMapTiles } from "@/api/map-tile";
 import { sysTiles } from "@/store";
@@ -59,7 +59,7 @@ import { sysTiles } from "@/store";
 const props = defineProps<{
   value: [string | null | undefined, number | null | undefined];
 }>();
-defineEmits<{
+const emit = defineEmits<{
   (e: "update:value", value: [string | null, number | null]): void;
 }>();
 
@@ -98,6 +98,14 @@ const backs = computed(() => [
   },
 ]);
 
+// 添加默认选中逻辑
+onMounted(() => {
+  // 如果没有获取到默认值(value[0]和value[1]都为空),则默认选中"无"选项
+  if (!props.value[0] && !props.value[1]) {
+    emit("update:value", ["none", null]);
+  }
+});
+
 const activeParent = computed(() => {
   for (const back of backs.value) {
     if (back.value === props.value[0]) {