feat: 添加SFTP空间使用统计功能
- 新增 /api/user/sftp-usage API,递归统计SFTP服务器空间使用情况 - 返回总使用空间、文件数、文件夹数 - 在设置页面显示SFTP空间统计信息 - 支持手动刷新统计数据 - 适配"仅SFTP"和"用户可选"两种权限模式的UI 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -220,7 +220,12 @@ createApp({
|
||||
|
||||
// SFTP配置引导弹窗
|
||||
showSftpGuideModal: false,
|
||||
showSftpConfigModal: false
|
||||
showSftpConfigModal: false,
|
||||
|
||||
// SFTP空间使用统计
|
||||
sftpUsage: null, // { totalSize, totalSizeFormatted, fileCount, dirCount }
|
||||
sftpUsageLoading: false,
|
||||
sftpUsageError: null
|
||||
};
|
||||
},
|
||||
|
||||
@@ -1840,6 +1845,35 @@ handleDragLeave(e) {
|
||||
console.error('加载用户资料失败:', error);
|
||||
}
|
||||
},
|
||||
|
||||
// 加载SFTP空间使用统计
|
||||
async loadSftpUsage() {
|
||||
// 仅在用户已配置SFTP时才加载
|
||||
if (!this.user?.has_ftp_config) {
|
||||
this.sftpUsage = null;
|
||||
return;
|
||||
}
|
||||
|
||||
this.sftpUsageLoading = true;
|
||||
this.sftpUsageError = null;
|
||||
|
||||
try {
|
||||
const response = await axios.get(
|
||||
`${this.apiBase}/api/user/sftp-usage`,
|
||||
{ headers: { Authorization: `Bearer ${this.token}` } }
|
||||
);
|
||||
|
||||
if (response.data.success) {
|
||||
this.sftpUsage = response.data.usage;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取SFTP空间使用情况失败:', error);
|
||||
this.sftpUsageError = error.response?.data?.message || '获取失败';
|
||||
} finally {
|
||||
this.sftpUsageLoading = false;
|
||||
}
|
||||
},
|
||||
|
||||
// 启动定期检查用户配置
|
||||
startProfileSync() {
|
||||
// 清除已有的定时器
|
||||
|
||||
Reference in New Issue
Block a user