wangjuncheng
2025-04-17 c761bc5e98bd6b1fe0900f3cfb1bb4734e1aed47
src/views/Home.vue
@@ -8,14 +8,10 @@
  <!-- <Left v-if="leftShow" />
      <Right v-if="rightShow" /> -->
  <Tools
    :style="
      rightRiverShow || showDangerAssess
        ? { right: '400px' }
        : { right: '12px' }
    "
    class="tools"
  />
  <Tools :style="rightRiverShow || showDangerAssess
    ? { right: '400px' }
    : { right: '12px' }
    " class="tools" />
  <!-- <Message v-if="messageShow" class="messageTool" /> -->
  <Announcement v-show="$route.fullPath != '/'" class="announcementTool" />
  <!-- <Location v-if="locationShow" class="locationTool" /> -->
@@ -31,7 +27,7 @@
</template>
<script setup>
import { computed } from "vue";
import { computed, onMounted, ref, getCurrentInstance } from "vue";
import { useRoute } from "vue-router";
import { useSimStore } from "@/store/simulation";
import { storeToRefs } from "pinia";
@@ -60,10 +56,18 @@
import ResultAssess from "@/components/monifangzhen/ResultAssess.vue";
// import DangerAssess from "@/components/monifangzhen/DangerAssess.vue";
import { showDeviceDetail } from "@/store";
import { setupTokenRefresh } from "@/api/hpApi.js"
import { getData } from "@/api/trApi.js"
import { convertToWKT } from '@/utils/wktUtils';
const route = useRoute();
const simStore = useSimStore();
const backHome = ref(false);
// 接收来自 ComponentA 的事件,并更新 isFlying
function handleBackToHome() {
  backHome.value = false;
}
// 从 store 中解构需要的状态
const {
  flowShow,
@@ -76,10 +80,37 @@
  showDangerAssess,
} = storeToRefs(simStore);
const { init, startYHGL, startZHJC, startMNFZ, startMNPG } = simStore;
// 模拟的经纬度数组
const multiPolygonCoordinates = [
    [
        [120.123456, 30.654321],
        [120.234567, 30.765432],
        [120.345678, 30.876543],
        [120.123456, 30.654321] // 闭合点
    ],
    [
        [121.111111, 31.222222],
        [121.333333, 31.444444],
        [121.555555, 31.666666],
        [121.111111, 31.222222] // 闭合点
    ]
];
// 计算属性
const showDetail = computed(() => showDeviceDetail.value);
onMounted(() => {
  setupTokenRefresh()// 获取宏图token
  getData() //测试tr后端
  try {
    const wktResult = convertToWKT(multiPolygonCoordinates);
    console.log(wktResult);
    // 输出: MULTIPOLYGON(((120.123456 30.654321,120.234567 30.765432,120.345678 30.876543,120.123456 30.654321)))
  } catch (error) {
    console.error(error.message);
  }
});
// 初始化
init();
</script>