移除控制台日志语句

This commit is contained in:
2025-10-20 10:59:56 +08:00
parent 8c6eadd7f3
commit 0aecb2dec4
6 changed files with 70 additions and 17 deletions

View File

@@ -1,5 +1,5 @@
<template>
<div class="dock-panel-container w-full h-full relative overflow-hidden bg-gray-100">
<div ref="container" class="dock-panel-container w-full h-full relative overflow-hidden bg-gray-100">
<!-- 主内容区域 -->
<div class="flex flex-col h-full">
<!-- 顶部面板区域 -->
@@ -322,8 +322,16 @@ const container = ref(null);
// 初始化Pinia store
const store = useDockPanelStore();
// 初始化布局管理器
const layoutManager = useLayoutManager(store);
// 定义布局应用完成后的回调函数,用于刷新面板大小
function handleLayoutApplied() {
// 确保容器存在后调用refreshPanelSizes并传递容器元素
if (container.value) {
store.refreshPanelSizes(container.value);
}
}
// 初始化布局管理器,传递布局应用完成后的回调函数
const layoutManager = useLayoutManager(store, handleLayoutApplied);
// 拖拽状态
const dragState = computed({

View File

@@ -14,11 +14,12 @@ export class LayoutManager {
* 构造函数
* @param {Object} store - Pinia store实例
*/
constructor(store) {
constructor(store, onLayoutApplied = null) {
this.store = store;
this.container = ref(null);
this.layoutPersistence = null;
this.resizeHandlers = null;
this.onLayoutApplied = onLayoutApplied;
}
/**
@@ -29,9 +30,11 @@ export class LayoutManager {
// 直接传入store对象让LayoutPersistence能够访问最新的面板数据
// 创建布局持久化实例
// 优化LayoutPersistence构造函数已简化只需要store对象和storageKey
// 传递onLayoutApplied回调以便在布局应用完成后通知调用方
this.layoutPersistence = new LayoutPersistence(
this.store,
'dockPanelLayout'
'dockPanelLayout',
this.onLayoutApplied
);
// 创建调整大小处理器
@@ -226,10 +229,11 @@ export class LayoutManager {
/**
* 创建LayoutManager的Vue组合式函数
* @param {Object} store - Pinia store实例
* @param {Function} onLayoutApplied - 布局应用完成后的回调函数
* @returns {Object} LayoutManager实例及相关方法
*/
export function useLayoutManager(store) {
const layoutManager = new LayoutManager(store);
export function useLayoutManager(store, onLayoutApplied = null) {
const layoutManager = new LayoutManager(store, onLayoutApplied);
onMounted(() => {
layoutManager.initialize();

View File

@@ -7,11 +7,12 @@ export class LayoutPersistence {
* @param {Object} store - Pinia store实例包含面板集合和布局状态信息
* @param {string} storageKey - localStorage存储键名
*/
constructor(store, storageKey = 'dockPanelLayout') {
constructor(store, storageKey = 'dockPanelLayout', onLayoutApplied = null) {
// 完全简化参数只需要store对象和可选的storageKey
this.panelCollections = store;
this.layoutState = store; // 统一使用store对象
this.storageKey = storageKey;
this.onLayoutApplied = onLayoutApplied;
}
/**
@@ -130,9 +131,7 @@ export class LayoutPersistence {
const bottomPanelValue = this.panelCollections.bottomPanelArea || {};
const centerPanelValue = this.panelCollections.centerPanelArea || {};
// 打印当前读取的面板宽度值
console.log('LayoutPersistence - 读取左侧面板宽度:', leftPanelValue.width || 0);
console.log('LayoutPersistence - 读取右侧面板宽度:', rightPanelValue.width || 0);
// 获取当前面板宽度值
const layoutData = {
// 面板区数据
@@ -282,7 +281,14 @@ export class LayoutPersistence {
this.panelCollections.activeCenterTab = layout.activeCenterTab;
}
// 面板比例已通过面板区域对象直接应用,无需额外处理
// 面板比例已通过面板区域对象直接应用
// 布局应用完成,触发布局应用完成事件
// 注意实际的刷新操作应该由调用方如DockPanelContainer.vue来执行
// 因为它可以直接访问容器DOM元素并传递给refreshPanelSizes方法
if (this.onLayoutApplied) {
this.onLayoutApplied();
}
}
/**

View File

@@ -295,9 +295,9 @@ export class ResizeHandlers {
this.store.resizeStartPos = { x: 0, y: 0 };
// 打印保存前的面板宽度值
console.log('ResizeHandlers - 保存前左侧面板宽度:', this.store.leftPanelArea.width);
this.layoutPersistence.saveLayout();
console.log('ResizeHandlers - 保存后左侧面板宽度:', this.store.leftPanelArea.width);
} else if (this.store.dragState.active && checkDockZoneCallback) {
// 计算拖拽距离
const dragDistance = Math.sqrt(

View File

@@ -345,13 +345,13 @@ export const useDockPanelStore = defineStore('dockPanel', () => {
// 处理所有位置面板的通用逻辑
if (panels.length > 0) {
resetPanelsSizeRatios(position)
// 使用传入的容器参数更新面板尺寸
// 无论是否提供container参数都应该更新面板区内的子面板尺寸
if (container) {
updatePanelsSize(position, panelArea, container, { panelWidth: 150, panelHeight: 100 });
}
}
// 如果面板区域变为空,触发尺寸影响处理以更新其他区域
if (panels.length === 0 && container) {
if (panels.length === 0) {
handlePanelSizeInfluence(position, container);
}
@@ -651,6 +651,27 @@ export const useDockPanelStore = defineStore('dockPanel', () => {
minimizedWindows.value = []
}
// 刷新所有面板区域的大小信息
function refreshPanelSizes(container = null) {
// 对于每个面板区域调用updatePanelsSize来刷新大小信息
// 只有当容器存在时才调用updatePanelsSize
if (container) {
updatePanelsSize('left', leftPanelArea.value, container);
updatePanelsSize('right', rightPanelArea.value, container);
updatePanelsSize('top', topPanelArea.value, container);
updatePanelsSize('bottom', bottomPanelArea.value, container);
updatePanelsSize('center', centerPanelArea.value, container);
}
// 触发响应式更新
// 重新赋值整个对象来确保Vue能够检测到变化
leftPanelArea.value = { ...leftPanelArea.value };
rightPanelArea.value = { ...rightPanelArea.value };
topPanelArea.value = { ...topPanelArea.value };
bottomPanelArea.value = { ...bottomPanelArea.value };
centerPanelArea.value = { ...centerPanelArea.value };
}
// 初始化面板大小影响关系和受影响关系
function initializePanelSizeInfluence() {
// 初始化影响关系数据
@@ -948,7 +969,7 @@ export const useDockPanelStore = defineStore('dockPanel', () => {
case 'top':
newSize = layoutCoordinator.adjustRegionSize('top', panelAreas.top.height, delta, panelAreas, containerHeight)
panelAreas.top.height = newSize
console.log('dockPanelStore - 顶部面板高度更新为:', panelAreas.top.height)
break
case 'bottom':
newSize = layoutCoordinator.adjustRegionSize('bottom', panelAreas.bottom.height, -delta, panelAreas, containerHeight)
@@ -1007,6 +1028,7 @@ export const useDockPanelStore = defineStore('dockPanel', () => {
resetLayout,
resetPanelsSizeRatios,
initializePanelSizeInfluence,
refreshPanelSizes,
updatePanelsSize,
handlePanelSizeInfluence,
adjustAdjacentPanels,