From 0bb7bd52196f0300fad7c67a34a2eff46a0eca2b Mon Sep 17 00:00:00 2001 From: WanWanYun Date: Sun, 16 Nov 2025 00:15:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=A4=B9=E8=AF=A6=E6=83=85=E5=8A=9F=E8=83=BD=20+=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=96=87=E4=BB=B6=E5=A4=B9=E5=88=86=E4=BA=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复内容: 1. 【文件夹详情无反应】 - 问题: folder-info API中变量名冲突 - 原因: API参数名'path'与Node.js的'path'模块冲突 - 具体: 第1193行 `const itemPath = path.join(dirPath, item.name)` 这里的path被当作API参数(字符串)而不是模块 - 修复: * API参数改为 `const { path: dirPath, folderName }` * 使用dirPath替代path * countFiles函数参数改为countDirPath避免混淆 - 效果: 查看详情功能现在正常工作 新功能: 2. 【文件夹分享】 - 移除分享功能的文件限制 - 右键菜单"分享"选项对文件和文件夹都显示 - 文件夹分享后可访问该文件夹下所有文件 - 与现有分享API完全兼容(share_type支持file和all) 技术细节: - backend/server.js: * 第1138行: path参数改为dirPath * 第1186行: countFiles函数参数改为countDirPath * 第1193行: 使用path.join正确引用模块 - frontend/app.html: * 移除 `v-if="!contextMenuFile.isDirectory"` 限制 * 文件夹也显示"分享"菜单项 使用方式: 1. 右键文件夹 → "查看详情" → 显示大小、文件数、子文件夹数 2. 右键文件夹 → "分享" → 分享整个文件夹 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- backend/server.js | 10 +++++----- frontend/app.html | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/backend/server.js b/backend/server.js index 4c5c701..73b2a8d 100644 --- a/backend/server.js +++ b/backend/server.js @@ -1135,7 +1135,7 @@ app.post('/api/files/mkdir', authMiddleware, async (req, res) => { // 获取文件夹详情(大小统计) app.post('/api/files/folder-info', authMiddleware, async (req, res) => { - const { path, folderName } = req.body; + const { path: dirPath, folderName } = req.body; let storage; if (!folderName) { @@ -1159,7 +1159,7 @@ app.post('/api/files/folder-info', authMiddleware, async (req, res) => { storage = await storageInterface.connect(); // 构造文件夹路径 - const basePath = path || '/'; + const basePath = dirPath || '/'; const folderPath = basePath === '/' ? `/${folderName}` : `${basePath}/${folderName}`; const fullPath = storage.getFullPath(folderPath); @@ -1183,14 +1183,14 @@ app.post('/api/files/folder-info', authMiddleware, async (req, res) => { const folderSize = storage.calculateFolderSize(fullPath); // 计算文件数量 - function countFiles(dirPath) { + function countFiles(countDirPath) { let fileCount = 0; let folderCount = 0; - const items = fs.readdirSync(dirPath, { withFileTypes: true }); + const items = fs.readdirSync(countDirPath, { withFileTypes: true }); for (const item of items) { - const itemPath = path.join(dirPath, item.name); + const itemPath = path.join(countDirPath, item.name); if (item.isDirectory()) { folderCount++; diff --git a/frontend/app.html b/frontend/app.html index adf7992..0478136 100644 --- a/frontend/app.html +++ b/frontend/app.html @@ -1773,7 +1773,7 @@
查看详情
-
+
分享