修复: 使用临时状态变量兼容SFTP配置显示逻辑

问题描述:
- 用户希望本地存储模式时隐藏SFTP配置区域
- 但点击"切换到SFTP"时需要能看到SFTP配置表单进行填写

解决方案:
1. 添加forceSftpConfigVisible状态变量用于临时强制显示
2. 修改HTML v-if条件,增加forceSftpConfigVisible的判断
3. 在switchStorage中设置forceSftpConfigVisible为true
4. 在updateFtpConfig成功后重置为false
5. 在switchView切换视图时自动重置

效果:
- 本地存储模式:SFTP配置默认隐藏
- 点击切换到SFTP:临时显示SFTP配置区域并滚动到该区域
- 配置成功:自动切换到SFTP模式,标志自动重置
- 切换视图:标志自动重置

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
WanWanYun
2025-11-12 23:31:26 +08:00
parent 1c58e498c5
commit cfcbc22ae7
2 changed files with 16 additions and 3 deletions

View File

@@ -1005,7 +1005,7 @@
</div> </div>
<!-- SFTP配置 - 仅普通用户且权限允许SFTP --> <!-- SFTP配置 - 仅普通用户且权限允许SFTP -->
<div v-if="user && !user.is_admin && (storagePermission === 'sftp_only' || storagePermission === 'user_choice')" id="sftp-config-section"> <div v-if="user && !user.is_admin && (storagePermission === 'sftp_only' || (storagePermission === 'user_choice' && (storageType === 'sftp' || forceSftpConfigVisible)))" id="sftp-config-section">
<h3 style="margin-bottom: 20px;">SFTP配置</h3> <h3 style="margin-bottom: 20px;">SFTP配置</h3>
<div v-if="user && !user.has_ftp_config" class="alert alert-info"> <div v-if="user && !user.has_ftp_config" class="alert alert-info">
请配置SFTP服务器 请配置SFTP服务器

View File

@@ -176,7 +176,10 @@ createApp({
// 上传工具管理 // 上传工具管理
uploadToolStatus: null, // 上传工具状态 { exists, fileInfo: { size, sizeMB, modifiedAt } } uploadToolStatus: null, // 上传工具状态 { exists, fileInfo: { size, sizeMB, modifiedAt } }
checkingUploadTool: false, // 是否正在检测上传工具 checkingUploadTool: false, // 是否正在检测上传工具
uploadingTool: false // 是否正在上传工具 uploadingTool: false, // 是否正在上传工具
// 强制显示SFTP配置用于本地存储模式下临时显示SFTP配置
forceSftpConfigVisible: false
}; };
}, },
@@ -406,7 +409,10 @@ handleDragLeave(e) {
console.error('[SFTP配置] 自动切换存储模式失败:', err); console.error('[SFTP配置] 自动切换存储模式失败:', err);
} }
} }
// 重置强制显示标志
this.forceSftpConfigVisible = false;
// 刷新到文件页面 // 刷新到文件页面
this.currentView = 'files'; this.currentView = 'files';
this.loadFiles('/'); this.loadFiles('/');
@@ -1583,6 +1589,8 @@ handleDragLeave(e) {
if (goToSettings) { if (goToSettings) {
// 直接设置视图并加载配置避免switchView的重复检查 // 直接设置视图并加载配置避免switchView的重复检查
this.currentView = 'settings'; this.currentView = 'settings';
// 强制显示SFTP配置区域
this.forceSftpConfigVisible = true;
// 如果是普通用户手动加载SFTP配置 // 如果是普通用户手动加载SFTP配置
if (this.user && !this.user.is_admin) { if (this.user && !this.user.is_admin) {
this.loadFtpConfig(); this.loadFtpConfig();
@@ -1633,6 +1641,11 @@ handleDragLeave(e) {
this.currentView = view; this.currentView = view;
// 离开settings页面时重置强制显示SFTP配置的标志
if (this.currentView !== 'settings') {
this.forceSftpConfigVisible = false;
}
// 根据视图类型自动加载对应数据 // 根据视图类型自动加载对应数据
switch (view) { switch (view) {
case 'files': case 'files':