fix: 修复管理员OSS配置缺失和数据库迁移问题
- 🐛 修复管理员无法配置OSS的问题(添加管理员OSS配置界面) - 🐛 修复 database.js 迁移代码引用不存在的 has_ftp_config 字段 - ✨ 管理员设置页面新增OSS配置、空间统计、存储切换功能 - 📝 完善管理员OSS配置体验 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -659,10 +659,6 @@ function migrateToV2() {
|
||||
ALTER TABLE users ADD COLUMN local_storage_used INTEGER DEFAULT 0;
|
||||
`);
|
||||
|
||||
// 更新现有用户为SFTP模式(保持兼容)
|
||||
const updateStmt = db.prepare("UPDATE users SET current_storage_type = 'sftp' WHERE has_ftp_config = 1");
|
||||
updateStmt.run();
|
||||
|
||||
console.log('[数据库迁移] ✓ 用户表已升级');
|
||||
|
||||
// 为分享表添加存储类型字段
|
||||
|
||||
@@ -2409,6 +2409,101 @@
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 管理员 OSS 配置 -->
|
||||
<div class="card" style="margin-bottom: 30px;">
|
||||
<h3 style="margin-bottom: 20px;">
|
||||
<i class="fas fa-cloud"></i> 管理员 OSS 配置
|
||||
</h3>
|
||||
<div style="margin-bottom: 15px;">
|
||||
<span style="color: var(--text-secondary); font-size: 13px;">配置管理员账号的 OSS 云存储,用于文件存储和管理。</span>
|
||||
</div>
|
||||
|
||||
<!-- OSS 配置状态 -->
|
||||
<div v-if="user && user.has_oss_config" style="margin-bottom: 20px; padding: 15px; background: rgba(34, 197, 94, 0.1); border-left: 4px solid #22c55e; border-radius: 8px;">
|
||||
<div style="display: flex; justify-content: space-between; align-items: center;">
|
||||
<div>
|
||||
<div style="font-weight: 600; color: var(--text-primary); margin-bottom: 4px;">
|
||||
<i class="fas fa-check-circle" style="color: #22c55e;"></i> OSS 已配置
|
||||
</div>
|
||||
<div style="font-size: 13px; color: var(--text-secondary);">
|
||||
{{ user.oss_provider }} / {{ user.oss_bucket }}
|
||||
</div>
|
||||
</div>
|
||||
<button class="btn btn-primary" @click="openOssConfigModal" style="padding: 8px 16px;">
|
||||
<i class="fas fa-edit"></i> 修改配置
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- OSS 空间统计 -->
|
||||
<div v-if="user && user.has_oss_config" style="margin-bottom: 20px;">
|
||||
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px;">
|
||||
<span style="font-weight: 600; color: var(--text-primary);">
|
||||
<i class="fas fa-chart-pie"></i> 空间使用统计
|
||||
</span>
|
||||
<button class="btn btn-secondary" @click="loadOssUsage" :disabled="ossUsageLoading" style="padding: 6px 12px; font-size: 12px;">
|
||||
<i :class="ossUsageLoading ? 'fas fa-spinner fa-spin' : 'fas fa-sync-alt'"></i> 刷新
|
||||
</button>
|
||||
</div>
|
||||
<div v-if="ossUsage" style="padding: 12px; background: var(--bg-card); border-radius: 8px; border: 1px solid var(--glass-border);">
|
||||
<div style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; font-size: 13px;">
|
||||
<div>
|
||||
<span style="color: var(--text-muted);">总大小</span>
|
||||
<div style="font-weight: 600; color: var(--text-primary);">{{ ossUsage.totalSizeFormatted || '-' }}</div>
|
||||
</div>
|
||||
<div>
|
||||
<span style="color: var(--text-muted);">文件数</span>
|
||||
<div style="font-weight: 600; color: var(--text-primary);">{{ ossUsage.fileCount || '-' }}</div>
|
||||
</div>
|
||||
<div>
|
||||
<span style="color: var(--text-muted);">文件夹数</span>
|
||||
<div style="font-weight: 600; color: var(--text-primary);">{{ ossUsage.dirCount || '-' }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else-if="ossUsageLoading" style="padding: 12px; text-align: center; color: var(--text-muted);">
|
||||
<i class="fas fa-spinner fa-spin"></i> 正在加载...
|
||||
</div>
|
||||
<div v-else style="padding: 12px; text-align: center; color: var(--text-muted);">
|
||||
暂无数据,点击刷新查看
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 未配置 OSS 时显示配置按钮 -->
|
||||
<div v-if="user && !user.has_oss_config" style="padding: 30px; text-align: center; background: var(--bg-card); border-radius: 12px; border: 1px solid var(--glass-border);">
|
||||
<i class="fas fa-cloud-upload-alt" style="font-size: 48px; color: var(--text-muted); margin-bottom: 15px;"></i>
|
||||
<div style="margin-bottom: 15px; color: var(--text-secondary);">尚未配置 OSS 存储</div>
|
||||
<button class="btn btn-primary" @click="openOssConfigModal" style="padding: 12px 30px;">
|
||||
<i class="fas fa-plus"></i> 配置 OSS 存储
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- 存储模式切换 -->
|
||||
<div v-if="user" style="margin-top: 20px; padding: 15px; background: var(--bg-card); border-radius: 12px; border: 1px solid var(--glass-border);">
|
||||
<div style="display: flex; justify-content: space-between; align-items: center;">
|
||||
<div>
|
||||
<div style="font-weight: 600; color: var(--text-primary); margin-bottom: 5px;">
|
||||
<i class="fas fa-database"></i> 当前存储模式
|
||||
</div>
|
||||
<div style="font-size: 13px; color: var(--text-secondary);">
|
||||
<span v-if="user.current_storage_type === 'local'" style="color: #667eea;">
|
||||
<i class="fas fa-hard-drive"></i> 本地存储
|
||||
</span>
|
||||
<span v-else style="color: #6c757d;">
|
||||
<i class="fas fa-cloud"></i> OSS 存储
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<button v-if="user.has_oss_config" class="btn" :class="user.current_storage_type === 'oss' ? 'btn-secondary' : 'btn-primary'"
|
||||
@click="switchStorage(user.current_storage_type === 'local' ? 'oss' : 'local')"
|
||||
:disabled="storageSwitching" style="padding: 8px 16px;">
|
||||
<i :class="storageSwitching ? 'fas fa-spinner fa-spin' : 'fas fa-random'"></i>
|
||||
{{ storageSwitching ? '切换中...' : (user.current_storage_type === 'local' ? '切换到 OSS' : '切换到本地') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- 设置标签页结束 -->
|
||||
|
||||
<!-- ========== 监控标签页 ========== -->
|
||||
|
||||
Reference in New Issue
Block a user