You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.5 KiB
Vue

1 month ago
<template>
1 month ago
<WellRecommend ref="recommend" :isView="true" />
1 month ago
<!-- <div>
<p>NodeID:{{ route.params.nodeId }}</p>
<p>ID{{ route.params.id }}</p>
</div> -->
</template>
<script setup>
definePageMeta({
requiresAuth: true
});
import { ref, onMounted, onBeforeMount } from 'vue';
import { useRoute } from "vue-router";
import { fetchLoadFileById } from '~/services/projectService';
import { generateGUID } from "~/utils/common";
// 消息提示(自动隐藏)
const { $toastMessage } = useNuxtApp();
const useTabStore = useCurrentTabStore();
const route = useRoute();
const recommend = ref(null);
const nodeId = route.query.nodeId;
const id = route.query.id;
const loadFile = async () => {
try {
const response = await fetchLoadFileById(nodeId, id);
1 month ago
console.log("加载文件:", response);
1 month ago
if (response == null) {
return;
}
if (checkEmpty(response.MapName)) {
$toastMessage.warning("未找到对应文件!");
return;
}
const token = id || generateGUID();
1 month ago
localStorage.setItem("viewerToken", token);
1 month ago
emitter.emit("evtType", { type: 'viewFile', data: JSON.stringify({ fileUrl: response.MapName, viewerToken: token }) });
} catch (error) {
console.error("加载文件失败:", error);
$toastMessage.error(`加载文件失败:${error}`);
}
};
onBeforeMount(() => {
useTabStore.changeTab('/drawview');
});
onMounted(async () => {
1 month ago
nextTick();
useTabStore.changeShowRight(false);
await loadFile();
1 month ago
})
</script>
<style scoped></style>