diff --git a/src/components/DiagramCanvas.vue b/src/components/DiagramCanvas.vue index cc2e4a6..28e32d3 100644 --- a/src/components/DiagramCanvas.vue +++ b/src/components/DiagramCanvas.vue @@ -1,7 +1,8 @@ @@ -80,7 +54,7 @@ const showDocPanel = ref(false); const documentContent = ref(""); // 获取路由参数 -import { useRoute } from 'vue-router'; +import { useRoute } from "vue-router"; const route = useRoute(); // 切换文档面板和属性面板 @@ -97,29 +71,32 @@ async function toggleDocPanel() { async function loadDocumentContent() { try { // 从路由参数中获取教程ID - const tutorialId = route.query.tutorial as string || '02'; // 默认加载02例程 - + const tutorialId = (route.query.tutorial as string) || "02"; // 默认加载02例程 + // 构建文档路径 let docPath = `/doc/${tutorialId}/doc.md`; - + // 检查当前路径是否包含下划线(例如 02_key 格式) // 如果不包含,那么使用更新的命名格式 - if (!tutorialId.includes('_')) { + if (!tutorialId.includes("_")) { docPath = `/doc/${tutorialId}/doc.md`; } - + // 获取文档内容 const response = await fetch(docPath); if (!response.ok) { throw new Error(`Failed to load document: ${response.status}`); } - + // 更新文档内容,并替换图片路径 - documentContent.value = (await response.text()) - .replace(/.\/images/gi, `/doc/${tutorialId}/images`); + documentContent.value = (await response.text()).replace( + /.\/images/gi, + `/doc/${tutorialId}/images`, + ); } catch (error) { - console.error('加载文档失败:', error); - documentContent.value = '# 文档加载失败\n\n无法加载请求的文档。'; } + console.error("加载文档失败:", error); + documentContent.value = "# 文档加载失败\n\n无法加载请求的文档。"; + } } // 检查是否有例程参数,如果有则自动打开文档面板 @@ -843,8 +820,10 @@ body { padding: 1.5rem; max-width: 100%; margin: 0; - background-color: transparent; /* 使用透明背景 */ - border: none; /* 确保没有边框 */ + background-color: transparent; + /* 使用透明背景 */ + border: none; + /* 确保没有边框 */ } /* 文档切换按钮样式 */