fix: 修复文件夹详情功能 + 添加文件夹分享
修复内容:
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 <noreply@anthropic.com>
This commit is contained in:
@@ -1135,7 +1135,7 @@ app.post('/api/files/mkdir', authMiddleware, async (req, res) => {
|
|||||||
|
|
||||||
// 获取文件夹详情(大小统计)
|
// 获取文件夹详情(大小统计)
|
||||||
app.post('/api/files/folder-info', 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;
|
let storage;
|
||||||
|
|
||||||
if (!folderName) {
|
if (!folderName) {
|
||||||
@@ -1159,7 +1159,7 @@ app.post('/api/files/folder-info', authMiddleware, async (req, res) => {
|
|||||||
storage = await storageInterface.connect();
|
storage = await storageInterface.connect();
|
||||||
|
|
||||||
// 构造文件夹路径
|
// 构造文件夹路径
|
||||||
const basePath = path || '/';
|
const basePath = dirPath || '/';
|
||||||
const folderPath = basePath === '/' ? `/${folderName}` : `${basePath}/${folderName}`;
|
const folderPath = basePath === '/' ? `/${folderName}` : `${basePath}/${folderName}`;
|
||||||
const fullPath = storage.getFullPath(folderPath);
|
const fullPath = storage.getFullPath(folderPath);
|
||||||
|
|
||||||
@@ -1183,14 +1183,14 @@ app.post('/api/files/folder-info', authMiddleware, async (req, res) => {
|
|||||||
const folderSize = storage.calculateFolderSize(fullPath);
|
const folderSize = storage.calculateFolderSize(fullPath);
|
||||||
|
|
||||||
// 计算文件数量
|
// 计算文件数量
|
||||||
function countFiles(dirPath) {
|
function countFiles(countDirPath) {
|
||||||
let fileCount = 0;
|
let fileCount = 0;
|
||||||
let folderCount = 0;
|
let folderCount = 0;
|
||||||
|
|
||||||
const items = fs.readdirSync(dirPath, { withFileTypes: true });
|
const items = fs.readdirSync(countDirPath, { withFileTypes: true });
|
||||||
|
|
||||||
for (const item of items) {
|
for (const item of items) {
|
||||||
const itemPath = path.join(dirPath, item.name);
|
const itemPath = path.join(countDirPath, item.name);
|
||||||
|
|
||||||
if (item.isDirectory()) {
|
if (item.isDirectory()) {
|
||||||
folderCount++;
|
folderCount++;
|
||||||
|
|||||||
@@ -1773,7 +1773,7 @@
|
|||||||
<div v-if="contextMenuFile.isDirectory" class="context-menu-item" @click="contextMenuAction('info')">
|
<div v-if="contextMenuFile.isDirectory" class="context-menu-item" @click="contextMenuAction('info')">
|
||||||
<i class="fas fa-info-circle"></i> 查看详情
|
<i class="fas fa-info-circle"></i> 查看详情
|
||||||
</div>
|
</div>
|
||||||
<div v-if="!contextMenuFile.isDirectory" class="context-menu-item" @click="contextMenuAction('share')">
|
<div class="context-menu-item" @click="contextMenuAction('share')">
|
||||||
<i class="fas fa-share"></i> 分享
|
<i class="fas fa-share"></i> 分享
|
||||||
</div>
|
</div>
|
||||||
<div class="context-menu-divider"></div>
|
<div class="context-menu-divider"></div>
|
||||||
|
|||||||
Reference in New Issue
Block a user