diff --git a/SharpPad/wwwroot/fileSystem/fileManager.js b/SharpPad/wwwroot/fileSystem/fileManager.js index d83cbbf..38bacfd 100644 --- a/SharpPad/wwwroot/fileSystem/fileManager.js +++ b/SharpPad/wwwroot/fileSystem/fileManager.js @@ -2,6 +2,7 @@ import { showNotification, DEFAULT_CODE, PROJECT_TYPE_CHANGE_EVENT } from '../utils/common.js'; import { customPrompt, customConfirm } from '../utils/customPrompt.js'; import desktopBridge from '../utils/desktopBridge.js'; +import { fileListResizer } from './fileListResizer.js'; class FileManager { constructor() { @@ -44,10 +45,63 @@ class FileManager { addFolderBtn.addEventListener('click', () => this.addFolder()); } + // 文件列表折叠/展开按钮监听 + const toggleFileListBtn = document.getElementById('toggleFileList'); + if (toggleFileListBtn) { + toggleFileListBtn.addEventListener('click', () => this.toggleFileList()); + } + + // 恢复文件列表按钮监听 + const restoreFileListBtn = document.querySelector('.restore-filelist'); + if (restoreFileListBtn) { + restoreFileListBtn.addEventListener('click', () => this.toggleFileList()); + } + + // 初始化文件列表状态 + this.initializeFileListState(); + // 初始化右键菜单事件 this.initializeContextMenus(); } + initializeFileListState() { + const fileList = document.getElementById('fileList'); + const minimizedButton = document.querySelector('.minimized-filelist-button'); + const isCollapsed = localStorage.getItem('fileListCollapsed') === 'true'; + + if (isCollapsed && fileList && minimizedButton) { + fileList.classList.add('collapsed'); + minimizedButton.style.display = 'block'; + } else if (minimizedButton) { + minimizedButton.style.display = 'none'; + } + + if (fileListResizer && typeof fileListResizer.updateContainerWidth === 'function') { + fileListResizer.updateContainerWidth(); + } + } + + toggleFileList() { + const fileList = document.getElementById('fileList'); + const minimizedButton = document.querySelector('.minimized-filelist-button'); + + if (!fileList || !minimizedButton) return; + + const isCollapsed = fileList.classList.toggle('collapsed'); + + if (isCollapsed) { + minimizedButton.style.display = 'block'; + localStorage.setItem('fileListCollapsed', 'true'); + } else { + minimizedButton.style.display = 'none'; + localStorage.setItem('fileListCollapsed', 'false'); + } + + if (fileListResizer && typeof fileListResizer.updateContainerWidth === 'function') { + fileListResizer.updateContainerWidth(); + } + } + normalizeProjectType(projectType) { const fallback = 'console'; const candidate = typeof projectType === 'string' diff --git a/SharpPad/wwwroot/index.html b/SharpPad/wwwroot/index.html index af85b0b..c5632f4 100644 --- a/SharpPad/wwwroot/index.html +++ b/SharpPad/wwwroot/index.html @@ -25,6 +25,7 @@