边框调节
This commit is contained in:
@@ -118,6 +118,9 @@ const hasAreasInMainContent = ref(false)
|
||||
* @returns {boolean} 是否应该操作区域
|
||||
*/
|
||||
const shouldOperateAreaInsteadOfPanel = (areaId) => {
|
||||
console.log(`[DockLayout] 检查单Panel模式,areaId: ${areaId}`);
|
||||
console.log(`[DockLayout] 当前floatingAreas:`, floatingAreas.value);
|
||||
|
||||
const area = floatingAreas.value.find(a => a.id === areaId);
|
||||
if (!area) {
|
||||
console.log(`[DockLayout] 未找到Area: ${areaId}`);
|
||||
@@ -129,14 +132,20 @@ const shouldOperateAreaInsteadOfPanel = (areaId) => {
|
||||
// 遍历所有子元素,统计Panel数量
|
||||
let panelCount = 0;
|
||||
|
||||
console.log(`[DockLayout] Area ${areaId} 的children:`, area.children);
|
||||
|
||||
const childrenArray = Array.isArray(area.children) ? area.children : [area.children];
|
||||
|
||||
for (const child of childrenArray) {
|
||||
console.log(`[DockLayout] 检查子元素:`, child);
|
||||
if (child.type === 'TabPage' && child.children) {
|
||||
console.log(`[DockLayout] 找到TabPage,children:`, child.children);
|
||||
const tabChildrenArray = Array.isArray(child.children) ? child.children : [child.children];
|
||||
for (const tabChild of tabChildrenArray) {
|
||||
console.log(`[DockLayout] 检查TabPage子元素:`, tabChild);
|
||||
if (tabChild.type === 'Panel') {
|
||||
panelCount++;
|
||||
console.log(`[DockLayout] 找到Panel,当前计数: ${panelCount}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -144,6 +153,7 @@ const shouldOperateAreaInsteadOfPanel = (areaId) => {
|
||||
|
||||
// 如果区域中只有一个面板,返回true
|
||||
const result = panelCount === 1;
|
||||
console.log(`[DockLayout] Area ${areaId} 单Panel检查结果:`, result, `(面板数量: ${panelCount})`);
|
||||
if (result) {
|
||||
console.log(`[DockLayout] Area ${areaId} 是单Panel模式,应该操作Area而不是Panel`);
|
||||
}
|
||||
@@ -494,6 +504,12 @@ const setupEventListeners = () => {
|
||||
unsubscribeFunctions.push(eventBus.on(EVENT_TYPES.PANEL_DRAG_START, onPanelDragStart, { componentId: 'dock-layout' }));
|
||||
unsubscribeFunctions.push(eventBus.on(EVENT_TYPES.PANEL_DRAG_MOVE, onPanelDragMove, { componentId: 'dock-layout' }));
|
||||
unsubscribeFunctions.push(eventBus.on(EVENT_TYPES.PANEL_DRAG_END, onPanelDragEnd, { componentId: 'dock-layout' }));
|
||||
// 单面板检测事件
|
||||
unsubscribeFunctions.push(eventBus.on(EVENT_TYPES.PANEL_CHECK_SINGLE_PANEL, onCheckSinglePanel, { componentId: 'dock-layout' }));
|
||||
// Area resize事件
|
||||
unsubscribeFunctions.push(eventBus.on(EVENT_TYPES.AREA_RESIZE_START, onAreaResizeStart, { componentId: 'dock-layout' }));
|
||||
unsubscribeFunctions.push(eventBus.on(EVENT_TYPES.AREA_RESIZE_MOVE, onAreaResizeMove, { componentId: 'dock-layout' }));
|
||||
unsubscribeFunctions.push(eventBus.on(EVENT_TYPES.AREA_RESIZE_END, onAreaResizeEnd, { componentId: 'dock-layout' }));
|
||||
|
||||
// Resize相关事件
|
||||
unsubscribeFunctions.push(eventBus.on(EVENT_TYPES.RESIZE_START, () => emit('dragStart'), { componentId: 'dock-layout' }));
|
||||
@@ -502,7 +518,20 @@ const setupEventListeners = () => {
|
||||
|
||||
// Window相关事件
|
||||
unsubscribeFunctions.push(eventBus.on(EVENT_TYPES.WINDOW_STATE_CHANGE, (event) => {
|
||||
// 处理窗口状态变化
|
||||
const areaId = event.areaId;
|
||||
const state = event.state;
|
||||
const position = event.position;
|
||||
|
||||
const area = floatingAreas.value.find(a => a.id === areaId);
|
||||
if (area) {
|
||||
area.windowState = state;
|
||||
if (position) {
|
||||
area.left = position.left;
|
||||
area.top = position.top;
|
||||
area.width = position.width;
|
||||
area.height = position.height;
|
||||
}
|
||||
}
|
||||
}, { componentId: 'dock-layout' }));
|
||||
|
||||
// 自定义事件
|
||||
@@ -658,6 +687,57 @@ const findOrCreateMainAreaTabPage = () => {
|
||||
};
|
||||
}
|
||||
|
||||
// 单面板检测处理函数
|
||||
const onCheckSinglePanel = (event) => {
|
||||
const areaId = event.areaId;
|
||||
const panelId = event.panelId;
|
||||
|
||||
// 使用现有的shouldOperateAreaInsteadOfPanel函数检查是否为单面板
|
||||
const isSinglePanel = shouldOperateAreaInsteadOfPanel(areaId);
|
||||
|
||||
// 发送检测结果
|
||||
eventBus.emit(EVENT_TYPES.PANEL_SINGLE_PANEL_RESULT, {
|
||||
areaId,
|
||||
panelId,
|
||||
isSinglePanel
|
||||
}, { componentId: 'dock-layout' });
|
||||
};
|
||||
|
||||
// Area resize事件处理函数
|
||||
const onAreaResizeStart = (event) => {
|
||||
const { areaId, direction, position } = event;
|
||||
|
||||
// AreaHandler已经监听了AREA_RESIZE_START事件,会自动处理
|
||||
// 只需要更新本地floatingAreas中的状态
|
||||
};
|
||||
|
||||
const onAreaResizeMove = (event) => {
|
||||
const { areaId, direction, size, position } = event;
|
||||
|
||||
const area = floatingAreas.value.find(a => a.id === areaId);
|
||||
if (area) {
|
||||
if (direction.includes('right') || direction.includes('left')) {
|
||||
area.width = size.width;
|
||||
if (direction.includes('left')) {
|
||||
area.left = position.left;
|
||||
}
|
||||
}
|
||||
if (direction.includes('bottom') || direction.includes('top')) {
|
||||
area.height = size.height;
|
||||
if (direction.includes('top')) {
|
||||
area.top = position.top;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const onAreaResizeEnd = (event) => {
|
||||
const { areaId, direction, finalPosition } = event;
|
||||
|
||||
// AreaHandler已经监听了AREA_RESIZE_END事件,会自动处理
|
||||
// 只需要更新本地floatingAreas中的状态
|
||||
};
|
||||
|
||||
// 轻量级生命周期处理
|
||||
onMounted(() => {
|
||||
// 初始化轻量级状态
|
||||
|
||||
Reference in New Issue
Block a user