fix: jam when doc panel open

This commit is contained in:
SikongJueluo 2025-05-20 18:34:44 +08:00
parent 970a537391
commit 46621fdb40
No known key found for this signature in database
2 changed files with 58 additions and 71 deletions

View File

@ -1,7 +1,8 @@
<template>
<div class="flex-1 h-full w-full bg-base-200 relative overflow-hidden diagram-container" ref="canvasContainer"
@mousedown="handleCanvasMouseDown" @mousedown.middle.prevent="startMiddleDrag" @wheel.prevent="onZoom"
@contextmenu.prevent="handleContextMenu"> <!-- 工具栏 -->
@contextmenu.prevent="handleContextMenu">
<!-- 工具栏 -->
<div class="absolute top-2 right-2 flex gap-2 z-30">
<button class="btn btn-sm btn-primary" @click="openDiagramFileSelector">
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 mr-1" fill="none" viewBox="0 0 24 24"
@ -32,7 +33,7 @@
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
</svg>
{{ props.showDocPanel ? '属性面板' : '文档' }}
{{ props.showDocPanel ? "属性面板" : "文档" }}
</button>
</div>
@ -64,16 +65,23 @@
'component-disabled': !component.isOn,
'component-hidepins': component.hidepins,
}" :style="{
top: component.y + 'px',
left: component.x + 'px',
zIndex: component.index ?? 0,
transform: component.rotate
? `rotate(${component.rotate}deg)`
: 'none',
opacity: component.isOn ? 1 : 0.6,
display: 'block',
}" @mousedown.left.stop="startComponentDrag($event, component)" @mouseover="hoveredComponent = component.id"
@mouseleave="hoveredComponent = null">
top: component.y + 'px',
left: component.x + 'px',
zIndex: component.index ?? 0,
transform: component.rotate
? `rotate(${component.rotate}deg)`
: 'none',
opacity: component.isOn ? 1 : 0.6,
display: 'block',
}" @mousedown.left.stop="startComponentDrag($event, component)" @mouseover="
(event) => {
hoveredComponent = component.id;
}
" @mouseleave="
(event) => {
hoveredComponent = null;
}
">
<!-- 动态渲染组件 -->
<component :is="getComponentDefinition(component.type)" v-if="props.componentModules[component.type]"
v-bind="prepareComponentProps(component.attrs || {}, component.id)" @update:bindKey="
@ -98,10 +106,10 @@
<!-- 通知组件 -->
<div v-if="showNotification" class="toast toast-top toast-center z-50 w-fit-content">
<div :class="`alert ${notificationType === 'success'
? 'alert-success'
: notificationType === 'error'
? 'alert-error'
: 'alert-info'
? 'alert-success'
: notificationType === 'error'
? 'alert-error'
: 'alert-info'
}`">
<span>{{ notificationMessage }}</span>
</div>
@ -173,7 +181,7 @@ const emit = defineEmits([
//
const props = defineProps<{
componentModules: Record<string, any>;
showDocPanel?: boolean; //
showDocPanel?: boolean; //
}>();
// --- ---

View File

@ -2,60 +2,34 @@
<div class="h-screen flex flex-col overflow-hidden">
<div class="flex flex-1 overflow-hidden relative">
<!-- 左侧图形化区域 -->
<div
class="relative bg-base-200 overflow-hidden h-full"
:style="{ width: leftPanelWidth + '%' }"
>
<DiagramCanvas
ref="diagramCanvas"
:componentModules="componentModules"
:showDocPanel="showDocPanel"
@component-selected="handleComponentSelected"
@component-moved="handleComponentMoved"
@component-delete="handleComponentDelete"
@wire-created="handleWireCreated"
@wire-deleted="handleWireDeleted"
@diagram-updated="handleDiagramUpdated"
@open-components="openComponentsMenu"
@load-component-module="handleLoadComponentModule"
@toggle-doc-panel="toggleDocPanel"
/>
<div class="relative bg-base-200 overflow-hidden h-full" :style="{ width: leftPanelWidth + '%' }">
<DiagramCanvas ref="diagramCanvas" :componentModules="componentModules" :showDocPanel="showDocPanel"
@component-selected="handleComponentSelected" @component-moved="handleComponentMoved"
@component-delete="handleComponentDelete" @wire-created="handleWireCreated" @wire-deleted="handleWireDeleted"
@diagram-updated="handleDiagramUpdated" @open-components="openComponentsMenu"
@load-component-module="handleLoadComponentModule" @toggle-doc-panel="toggleDocPanel" />
</div>
<!-- 拖拽分割线 -->
<div
class="resizer bg-base-100 hover:bg-primary hover:opacity-70 active:bg-primary active:opacity-90 transition-colors"
@mousedown="startResize"
></div> <!-- 右侧编辑区域 -->
<div
class="bg-base-200 h-full overflow-hidden flex flex-col"
:style="{ width: 100 - leftPanelWidth + '%' }"
>
@mousedown="startResize"></div>
<!-- 右侧编辑区域 -->
<div class="bg-base-200 h-full overflow-hidden flex flex-col" :style="{ width: 100 - leftPanelWidth + '%' }">
<div class="overflow-y-auto flex-1">
<!-- 使用条件渲染显示不同的面板 -->
<PropertyPanel
v-if="!showDocPanel"
:componentData="selectedComponentData"
:componentConfig="selectedComponentConfig"
@updateProp="updateComponentProp"
@updateDirectProp="updateComponentDirectProp"
/> <div
v-else
class="doc-panel overflow-y-auto h-full"
>
<PropertyPanel v-show="!showDocPanel" :componentData="selectedComponentData"
:componentConfig="selectedComponentConfig" @updateProp="updateComponentProp"
@updateDirectProp="updateComponentDirectProp" />
<div v-show="showDocPanel" class="doc-panel overflow-y-auto h-full">
<MarkdownRenderer :content="documentContent" />
</div>
</div>
</div>
</div>
<!-- 元器件选择组件 -->
<ComponentSelector
:open="showComponentsMenu"
@update:open="showComponentsMenu = $event"
@add-component="handleAddComponent"
@add-template="handleAddTemplate"
@close="showComponentsMenu = false"
/>
<ComponentSelector :open="showComponentsMenu" @update:open="showComponentsMenu = $event"
@add-component="handleAddComponent" @add-template="handleAddTemplate" @close="showComponentsMenu = false" />
</div>
</template>
@ -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;
/* 确保没有边框 */
}
/* 文档切换按钮样式 */