本地提交:实现向DockLayout发送添加浮动区命令功能

This commit is contained in:
AutoRobot Dev
2025-11-02 17:12:40 +07:00
parent e2a31a6a9d
commit 4927bf5491
2 changed files with 15 additions and 20 deletions

View File

@@ -6,7 +6,7 @@
</template> </template>
<script setup> <script setup>
import { ref } from 'vue' import { ref, defineExpose } from 'vue'
import Area from './Area.vue'; import Area from './Area.vue';
import Panel from './Panel.vue'; import Panel from './Panel.vue';
@@ -68,6 +68,11 @@ const onToggleToolbar = (id) => {
area.toolbarExpanded = !area.toolbarExpanded area.toolbarExpanded = !area.toolbarExpanded
} }
} }
// 暴露方法给父组件
defineExpose({
addFloatingArea
})
</script> </script>
<style scoped> <style scoped>

View File

@@ -44,7 +44,7 @@
<!-- 预留主区域暂不放面板 --> <!-- 预留主区域暂不放面板 -->
<div ref="panelHost" class="flex-1 w-full h-[calc(100%-4rem)] relative bg-gray-100"> <div ref="panelHost" class="flex-1 w-full h-[calc(100%-4rem)] relative bg-gray-100">
<DockLayout /> <DockLayout ref="dockLayoutRef" />
</div> </div>
</div> </div>
</template> </template>
@@ -56,6 +56,7 @@ import DockLayout from '../DockLayout/DockLayout.vue';
// 顶部控制栏按钮的引用 // 顶部控制栏按钮的引用
const layoutFileInput = ref(null); const layoutFileInput = ref(null);
const panelHost = ref(null); const panelHost = ref(null);
const dockLayoutRef = ref(null);
// 浮动面板列表 // 浮动面板列表
const floatingPanels = ref([]); const floatingPanels = ref([]);
@@ -68,24 +69,13 @@ function addPanel(position) {
function addFloatingPanel() { function addFloatingPanel() {
console.log('[DockLayoutTest] addFloatingPanel called'); console.log('[DockLayoutTest] addFloatingPanel called');
// 复原截图样式的默认面板参数 // 向DockLayout组件发送添加浮动区命令
const defaultSize = { width: 300, height: 180 }; if (dockLayoutRef.value && dockLayoutRef.value.addFloatingArea) {
const offset = 16; console.log('[DockLayoutTest] 调用DockLayout的addFloatingArea方法');
const idx = nextPanelIdx.value++; dockLayoutRef.value.addFloatingArea();
const panel = { } else {
id: 'float-' + idx, console.warn('[DockLayoutTest] DockLayout引用未初始化或addFloatingArea方法不可用');
title: '输出', }
x: offset * idx,
y: offset * idx,
width: defaultSize.width,
height: defaultSize.height,
collapsed: false,
toolbarExpanded: false,
maximized: false,
};
console.log('[DockLayoutTest] Adding panel:', panel);
floatingPanels.value.push(panel);
console.log('[DockLayoutTest] Panels after add:', floatingPanels.value.length);
} }
function closePanel(id) { function closePanel(id) {