From e8951248316dacac4107dde4904954454e829276 Mon Sep 17 00:00:00 2001 From: liumangmang Date: Mon, 30 Mar 2026 16:18:00 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20SFTP=E6=A0=87=E7=AD=BE=E9=A1=B5=E7=A6=BB?= =?UTF-8?q?=E5=BC=80=E5=90=8E=E8=BF=94=E5=9B=9E=E5=88=B7=E6=96=B0=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E4=B8=A2=E5=A4=B1=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2026-03-30-sftp-tab-cache-fix-plan.md | 63 +++++++++++++++++++ frontend/src/layouts/MainLayout.vue | 6 +- frontend/src/views/SftpView.vue | 3 +- 3 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 .opencode/plans/2026-03-30-sftp-tab-cache-fix-plan.md diff --git a/.opencode/plans/2026-03-30-sftp-tab-cache-fix-plan.md b/.opencode/plans/2026-03-30-sftp-tab-cache-fix-plan.md new file mode 100644 index 0000000..0b6fb70 --- /dev/null +++ b/.opencode/plans/2026-03-30-sftp-tab-cache-fix-plan.md @@ -0,0 +1,63 @@ +# SFTP标签页状态保持修复实施计划 + +> **For agentic workers:** REQUIRED: Use superpowers:subagent-driven-development (if subagents available) or superpowers:executing-plans to implement this plan. Steps use checkbox (`- [ ]`) syntax for tracking. + +**Goal:** 修复SFTP标签页离开后再返回会刷新页面、丢失浏览状态的问题 + +**Architecture:** 为SftpView组件添加keep-alive缓存,仅缓存SFTP相关页面,最大缓存10个实例避免内存占用过高,每个路由实例通过fullPath作为唯一key区分 + +**Tech Stack:** Vue 3、Vue Router 4、Pinia + +--- + +### Task 1: 为SftpView组件添加名称标识 +**Files:** +- Modify: `frontend/src/views/SftpView.vue` + +- [ ] **Step 1: 添加组件名称** +在script setup开头添加: +```typescript +defineOptions({ name: 'SftpView' }) +``` + +--- + +### Task 2: 修改MainLayout添加keep-alive缓存 +**Files:** +- Modify: `frontend/src/layouts/MainLayout.vue:193-195` + +- [ ] **Step 1: 替换原RouterView代码** +原代码: +```vue + + + +``` +替换为: +```vue + + + + + +``` + +--- + +### Task 3: 验证修复效果 +**Files:** +- Test: 手动验证 + 构建验证 + +- [ ] **Step 1: 运行类型检查** +Run: `cd frontend && npm run build` +Expected: 构建成功,无类型错误 + +- [ ] **Step 2: 手动测试功能** +1. 启动开发服务,登录系统 +2. 打开任意连接的SFTP标签 +3. 浏览到任意子目录 +4. 切换到其他页面(如连接列表、终端) +5. 切回SFTP标签,确认仍停留在之前浏览的子目录,状态未丢失 +6. 打开多个不同连接的SFTP标签,切换时确认各自状态独立保存 + +--- diff --git a/frontend/src/layouts/MainLayout.vue b/frontend/src/layouts/MainLayout.vue index fe0823d..09a718d 100644 --- a/frontend/src/layouts/MainLayout.vue +++ b/frontend/src/layouts/MainLayout.vue @@ -190,8 +190,10 @@ function handleSftpTabClose(tabId: string, connectionId: number, event: Event) {
- - + + + + diff --git a/frontend/src/views/SftpView.vue b/frontend/src/views/SftpView.vue index 0285726..fc7f473 100644 --- a/frontend/src/views/SftpView.vue +++ b/frontend/src/views/SftpView.vue @@ -1,4 +1,5 @@ -