实现快传,完善快传和网盘的功能,实现文件的互传等一系列功能

This commit is contained in:
yoyuzh
2026-03-20 14:16:18 +08:00
parent 944ab6dbf8
commit 43358e29d7
109 changed files with 5237 additions and 2465 deletions

View File

@@ -0,0 +1,88 @@
# File Share And Transfer Save Implementation Plan
> **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:** Let users create URL-based netdisk share links that another logged-in user can import into their own netdisk, and let transfer receivers save received files directly into their netdisk.
**Architecture:** Add a small share-link domain under `backend/src/main/java/com/yoyuzh/files` so the backend can issue secret share tokens, expose share metadata, and import the shared file into the recipients storage without routing the payload through the browser. On the frontend, add share actions to the Files page, a public `/share/:token` import page, and a reusable netdisk-upload helper that Transfer receive actions can call to persist downloaded blobs into the current users storage.
**Tech Stack:** Spring Boot 3.3.8 + Java 17 + JPA, React 19 + Vite + TypeScript, existing file storage abstraction, existing frontend Node test runner and Maven tests.
---
### Task 1: Define Backend Share-Link API Contract
**Files:**
- Modify: `backend/src/test/java/com/yoyuzh/files/FileServiceTest.java`
- Create: `backend/src/test/java/com/yoyuzh/files/FileShareControllerIntegrationTest.java`
- [ ] **Step 1: Write failing tests for creating a share link, reading share metadata, and importing a shared file into another users netdisk**
- [ ] **Step 2: Run `cd backend && /Users/mac/.local/tools/apache-maven-3.9.11/bin/mvn test` to verify the new tests fail**
- [ ] **Step 3: Implement the minimal backend API surface to satisfy the tests**
- [ ] **Step 4: Re-run `cd backend && /Users/mac/.local/tools/apache-maven-3.9.11/bin/mvn test`**
### Task 2: Add Backend Share-Link Persistence And Import Logic
**Files:**
- Create: `backend/src/main/java/com/yoyuzh/files/FileShareLink.java`
- Create: `backend/src/main/java/com/yoyuzh/files/FileShareLinkRepository.java`
- Create: `backend/src/main/java/com/yoyuzh/files/CreateFileShareLinkResponse.java`
- Create: `backend/src/main/java/com/yoyuzh/files/FileShareDetailsResponse.java`
- Create: `backend/src/main/java/com/yoyuzh/files/ImportSharedFileRequest.java`
- Modify: `backend/src/main/java/com/yoyuzh/files/FileController.java`
- Modify: `backend/src/main/java/com/yoyuzh/files/FileService.java`
- [ ] **Step 1: Add the share-link entity/repository and DTOs**
- [ ] **Step 2: Extend `FileService` with share creation, share lookup, and recipient import logic**
- [ ] **Step 3: Expose authenticated create/import endpoints and a public share-details endpoint in `FileController`**
- [ ] **Step 4: Keep directory handling explicit; only add behavior required by the tests**
### Task 3: Add Frontend Share-Link Helpers And Tests
**Files:**
- Create: `front/src/lib/file-share.ts`
- Create: `front/src/lib/file-share.test.ts`
- Modify: `front/src/lib/types.ts`
- [ ] **Step 1: Write failing frontend helper tests for share-link building/parsing and import payload helpers**
- [ ] **Step 2: Run `cd front && npm run test` to verify failure**
- [ ] **Step 3: Implement minimal share helper wrappers against the backend API**
- [ ] **Step 4: Re-run `cd front && npm run test`**
### Task 4: Add Public Share Import Page
**Files:**
- Create: `front/src/pages/FileShare.tsx`
- Modify: `front/src/App.tsx`
- Modify: `front/src/pages/Login.tsx`
- [ ] **Step 1: Add failing tests for any pure helper logic used by the share page and login redirect flow**
- [ ] **Step 2: Run `cd front && npm run test` to verify failure**
- [ ] **Step 3: Implement `/share/:token`, showing share metadata publicly and allowing authenticated users to import into their netdisk**
- [ ] **Step 4: Add login redirect-back handling only as needed for this route**
### Task 5: Add Share Actions To Netdisk And Save-To-Netdisk For Transfer
**Files:**
- Modify: `front/src/pages/Files.tsx`
- Create: `front/src/lib/netdisk-upload.ts`
- Create: `front/src/lib/netdisk-upload.test.ts`
- Modify: `front/src/pages/TransferReceive.tsx`
- [ ] **Step 1: Write failing helper tests for saving a browser `File` into netdisk**
- [ ] **Step 2: Run `cd front && npm run test` to verify failure**
- [ ] **Step 3: Add a share action in the Files page that creates/copies a share URL**
- [ ] **Step 4: Add “存入网盘” actions in transfer receive for completed files**
- [ ] **Step 5: Re-run `cd front && npm run test`**
### Task 6: Full Verification
**Files:**
- Modify only if validation reveals defects
- [ ] **Step 1: Run `cd front && npm run test`**
- [ ] **Step 2: Run `cd front && npm run lint`**
- [ ] **Step 3: Run `cd front && npm run build`**
- [ ] **Step 4: Run `cd backend && /Users/mac/.local/tools/apache-maven-3.9.11/bin/mvn test`**
- [ ] **Step 5: Run `cd backend && /Users/mac/.local/tools/apache-maven-3.9.11/bin/mvn package`**
- [ ] **Step 6: Deploy frontend with `node scripts/deploy-front-oss.mjs` only after all checks pass**

View File

@@ -0,0 +1,84 @@
# Netdisk Path Picker And Move Implementation Plan
> **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:** Let users choose a destination path in a centered modal when saving files into the netdisk, and add a real move-file/move-folder capability inside the netdisk.
**Architecture:** Add a backend move endpoint in the existing `files` domain so both local storage and OSS-backed storage can relocate files safely. On the frontend, introduce a reusable netdisk path picker modal that can browse existing folders and reuse it from transfer save flows, share import flows, and the new move action in the Files page.
**Tech Stack:** Spring Boot 3.3.8 + Java 17 + JPA, React 19 + Vite + TypeScript, Tailwind CSS v4, existing file storage abstraction and Node test runner.
---
### Task 1: Add Backend Move API Contract
**Files:**
- Modify: `backend/src/test/java/com/yoyuzh/files/FileServiceTest.java`
- Modify: `backend/src/test/java/com/yoyuzh/files/FileShareControllerIntegrationTest.java`
- [ ] **Step 1: Write failing backend tests for moving a file to another directory and moving a folder while preserving descendants**
- [ ] **Step 2: Run `cd backend && /Users/mac/.local/tools/apache-maven-3.9.11/bin/mvn test` to verify the new tests fail**
- [ ] **Step 3: Implement the minimal backend API surface to satisfy the tests**
- [ ] **Step 4: Re-run `cd backend && /Users/mac/.local/tools/apache-maven-3.9.11/bin/mvn test`**
### Task 2: Implement Backend Move Logic
**Files:**
- Create: `backend/src/main/java/com/yoyuzh/files/MoveFileRequest.java`
- Modify: `backend/src/main/java/com/yoyuzh/files/FileController.java`
- Modify: `backend/src/main/java/com/yoyuzh/files/FileService.java`
- Modify: `backend/src/main/java/com/yoyuzh/files/StoredFileRepository.java`
- Modify: `backend/src/main/java/com/yoyuzh/files/storage/FileContentStorage.java`
- Modify: `backend/src/main/java/com/yoyuzh/files/storage/LocalFileContentStorage.java`
- Modify: `backend/src/main/java/com/yoyuzh/files/storage/OssFileContentStorage.java`
- [ ] **Step 1: Add a move request DTO and controller endpoint for `PATCH /api/files/{fileId}/move`**
- [ ] **Step 2: Extend the repository and service with destination-directory validation, duplicate-name protection, and self/descendant move guards**
- [ ] **Step 3: Add storage-layer support for moving a file across directories while reusing existing directory move behavior**
- [ ] **Step 4: Keep the implementation narrow to existing netdisk semantics: move into an existing directory only**
### Task 3: Add Frontend Path Selection Helpers And Tests
**Files:**
- Create: `front/src/lib/netdisk-paths.ts`
- Create: `front/src/lib/netdisk-paths.test.ts`
- Modify: `front/src/lib/netdisk-upload.ts`
- Modify: `front/src/lib/netdisk-upload.test.ts`
- [ ] **Step 1: Write failing helper tests for netdisk path splitting/joining and default transfer save paths**
- [ ] **Step 2: Run `cd front && npm run test` to verify failure**
- [ ] **Step 3: Implement minimal shared path helpers for the picker modal and save flows**
- [ ] **Step 4: Re-run `cd front && npm run test`**
### Task 4: Add Reusable Netdisk Path Picker Modal
**Files:**
- Create: `front/src/components/ui/NetdiskPathPickerModal.tsx`
- Modify: `front/src/pages/FileShare.tsx`
- Modify: `front/src/pages/TransferReceive.tsx`
- [ ] **Step 1: Replace inline save/import path entry with a centered modal path picker that browses existing folders**
- [ ] **Step 2: Reuse the same modal for transfer “存入网盘” and share import so the interaction stays consistent**
- [ ] **Step 3: Keep browsing lightweight by listing one directory level at a time and filtering to folders only**
### Task 5: Add Netdisk Move UI
**Files:**
- Modify: `front/src/pages/Files.tsx`
- Create only if needed: `front/src/lib/file-move.ts`
- [ ] **Step 1: Add a move action to the file list menu and detail sidebar**
- [ ] **Step 2: Reuse the path picker modal to choose the destination directory**
- [ ] **Step 3: Call the backend move endpoint, refresh the current listing, and clear or sync selection as needed**
- [ ] **Step 4: Surface move errors in the modal instead of failing silently**
### Task 6: Full Verification
**Files:**
- Modify only if validation reveals defects
- [ ] **Step 1: Run `cd front && npm run test`**
- [ ] **Step 2: Run `cd front && npm run lint`**
- [ ] **Step 3: Run `cd front && npm run build`**
- [ ] **Step 4: Run `cd backend && /Users/mac/.local/tools/apache-maven-3.9.11/bin/mvn test`**
- [ ] **Step 5: Run `cd backend && /Users/mac/.local/tools/apache-maven-3.9.11/bin/mvn package`**

View File

@@ -0,0 +1,137 @@
# Transfer Module Refactor Implementation Plan
> **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:** Refactor the fast-transfer module so the website has one coherent transfer flow, with cleaner frontend boundaries, a cleaner backend session model, and route generation that matches the site router mode.
**Architecture:** Keep the current product behavior of “authenticated sender page + public receiver page + backend signaling only”, but split protocol/state concerns away from route UI. On the frontend, centralize transfer URL building, protocol message helpers, and sender/receiver session orchestration so the pages become thinner. On the backend, split the current monolithic in-memory service into small transfer domain objects while preserving the same HTTP API.
**Tech Stack:** Vite 6, React 19, TypeScript, Spring Boot 3.3, Java 17, node:test, JUnit 5, MockMvc.
---
### Task 1: Lock down route-aware transfer URLs
**Files:**
- Modify: `front/src/pages/transfer-state.test.ts`
- Modify: `front/src/pages/transfer-state.ts`
- Modify: `front/src/App.tsx`
- [ ] **Step 1: Write the failing test**
Add tests asserting:
- browser mode share URL => `https://host/t?session=abc`
- hash mode share URL => `https://host/#/t?session=abc`
- [ ] **Step 2: Run test to verify it fails**
Run: `cd front && npm run test`
- [ ] **Step 3: Write minimal implementation**
Introduce a router-mode-aware URL builder and update the app router to respect `VITE_ROUTER_MODE`.
- [ ] **Step 4: Run test to verify it passes**
Run: `cd front && npm run test`
### Task 2: Extract shared frontend transfer protocol and session helpers
**Files:**
- Create: `front/src/lib/transfer-protocol.ts`
- Create: `front/src/lib/transfer-runtime.ts`
- Modify: `front/src/lib/transfer.ts`
- Modify: `front/src/pages/Transfer.tsx`
- Modify: `front/src/pages/TransferReceive.tsx`
- [ ] **Step 1: Write the failing test**
Add tests for pure protocol helpers:
- sender meta message encoding
- receiver payload parsing
- progress/URL helpers that no longer live inside page components
- [ ] **Step 2: Run test to verify it fails**
Run: `cd front && npm run test`
- [ ] **Step 3: Write minimal implementation**
Move WebRTC protocol constants, message parsing/encoding, and repeated session setup logic out of page components. Keep pages focused on route UI and user actions.
- [ ] **Step 4: Run test to verify it passes**
Run: `cd front && npm run test`
### Task 3: Thin down backend transfer service
**Files:**
- Create: `backend/src/main/java/com/yoyuzh/transfer/TransferRole.java`
- Create: `backend/src/main/java/com/yoyuzh/transfer/TransferSession.java`
- Create: `backend/src/main/java/com/yoyuzh/transfer/TransferSessionStore.java`
- Modify: `backend/src/main/java/com/yoyuzh/transfer/TransferService.java`
- Add/Modify Test: `backend/src/test/java/com/yoyuzh/transfer/TransferControllerIntegrationTest.java`
- [ ] **Step 1: Write the failing test**
Add focused tests that lock current session behavior:
- pickup code validation
- receiver join only emits one `peer-joined`
- signals route to the opposite queue
- [ ] **Step 2: Run test to verify it fails**
Run: `cd backend && /Users/mac/.local/tools/apache-maven-3.9.11/bin/mvn test`
- [ ] **Step 3: Write minimal implementation**
Extract session state and store responsibilities from `TransferService`, leaving `TransferService` as orchestration only.
- [ ] **Step 4: Run test to verify it passes**
Run: `cd backend && /Users/mac/.local/tools/apache-maven-3.9.11/bin/mvn test`
### Task 4: Reconnect the module cleanly to the site
**Files:**
- Modify: `front/src/pages/Overview.tsx`
- Modify: `front/src/components/layout/Layout.tsx`
- Modify: `scripts/oss-deploy-lib.mjs`
- Modify: `scripts/oss-deploy-lib.test.mjs`
- [ ] **Step 1: Verify transfer entry points still match the refactored routes**
Confirm overview CTA, sidebar nav, and public receiver route all align on the same URL helpers.
- [ ] **Step 2: Verify the deployment aliases still cover the public transfer route**
Run: `node scripts/oss-deploy-lib.test.mjs`
- [ ] **Step 3: Apply any minimal cleanup**
Remove duplicated hardcoded route strings if they remain.
### Task 5: Full verification
**Files:**
- No code changes required unless failures appear
- [ ] **Step 1: Run frontend tests**
Run: `cd front && npm run test`
- [ ] **Step 2: Run frontend typecheck**
Run: `cd front && npm run lint`
- [ ] **Step 3: Run frontend build**
Run: `cd front && npm run build`
- [ ] **Step 4: Run backend tests**
Run: `cd backend && /Users/mac/.local/tools/apache-maven-3.9.11/bin/mvn test`
- [ ] **Step 5: Run backend package**
Run: `cd backend && /Users/mac/.local/tools/apache-maven-3.9.11/bin/mvn package`

View File

@@ -0,0 +1,87 @@
# Transfer WebRTC Share Implementation Plan
> **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:** Turn the current mock transfer page into a real QR-to-webpage sharing flow where a sender opens `/transfer`, the receiver opens a public share URL, and the browsers exchange files over WebRTC P2P.
**Architecture:** Add a minimal backend signaling layer under `backend/src/main/java/com/yoyuzh/transfer` using in-memory session storage with short TTL. Keep the sender workspace inside the authenticated portal, add a public receiver route in the frontend, and exchange SDP / ICE over authenticated-or-public HTTP endpoints while the actual file bytes move through `RTCDataChannel`.
**Tech Stack:** React 19 + Vite + TypeScript, Spring Boot 3.3.8 + Java 17, WebRTC `RTCPeerConnection`, existing OSS deploy script, Maven tests, Node test runner.
---
### Task 1: Define Share URL And Pure Frontend Protocol Helpers
**Files:**
- Modify: `front/src/pages/transfer-state.ts`
- Modify: `front/src/pages/transfer-state.test.ts`
- Modify: `front/src/App.tsx`
- [ ] **Step 1: Write failing tests for share URL and protocol helpers**
- [ ] **Step 2: Run `cd front && npm run test` to verify the new tests fail**
- [ ] **Step 3: Implement minimal helpers for public share URLs, protocol message typing, and code parsing**
- [ ] **Step 4: Run `cd front && npm run test` to verify the helpers pass**
### Task 2: Add Backend Signaling Session APIs
**Files:**
- Create: `backend/src/main/java/com/yoyuzh/transfer/TransferController.java`
- Create: `backend/src/main/java/com/yoyuzh/transfer/TransferService.java`
- Create: `backend/src/main/java/com/yoyuzh/transfer/TransferSessionStore.java`
- Create: `backend/src/main/java/com/yoyuzh/transfer/*.java` DTOs for create/join/poll/post signal
- Modify: `backend/src/main/java/com/yoyuzh/config/SecurityConfig.java`
- Test: `backend/src/test/java/com/yoyuzh/transfer/TransferControllerIntegrationTest.java`
- Test: `backend/src/test/java/com/yoyuzh/config/SecurityConfigTest.java`
- [ ] **Step 1: Write failing backend integration tests for session creation, public join, offer/answer exchange, ICE polling, and access rules**
- [ ] **Step 2: Run `cd backend && mvn test` to verify the transfer tests fail for the expected missing endpoints**
- [ ] **Step 3: Implement the minimal in-memory signaling service and public `/api/transfer/**` endpoints**
- [ ] **Step 4: Run `cd backend && mvn test` to verify backend green**
### Task 3: Replace Mock Transfer UI With Sender Workspace
**Files:**
- Modify: `front/src/pages/Transfer.tsx`
- Create: `front/src/lib/transfer-client.ts` if needed for request wrappers
- Test: `front/src/pages/transfer-state.test.ts`
- [ ] **Step 1: Add failing tests for sender-side state transitions that now depend on created share sessions instead of mock codes**
- [ ] **Step 2: Run `cd front && npm run test` to verify failure**
- [ ] **Step 3: Implement sender-side session creation, QR/share URL generation, and WebRTC offer / data channel sending**
- [ ] **Step 4: Run `cd front && npm run test` to verify green**
### Task 4: Add Public Receiver Page
**Files:**
- Create: `front/src/pages/TransferReceive.tsx`
- Modify: `front/src/App.tsx`
- Modify: `front/src/pages/Transfer.tsx`
- [ ] **Step 1: Add failing tests for public share route parsing or receiver helper logic**
- [ ] **Step 2: Run `cd front && npm run test` to verify failure**
- [ ] **Step 3: Implement the public receiver page, session join flow, answer/ICE exchange, and browser download assembly**
- [ ] **Step 4: Run `cd front && npm run test` to verify green**
### Task 5: Make OSS Publish Recognize Public Share Routes
**Files:**
- Modify: `scripts/oss-deploy-lib.mjs`
- Modify: `scripts/oss-deploy-lib.test.mjs`
- [ ] **Step 1: Write failing tests for new SPA aliases such as `t` or `transfer/receive`**
- [ ] **Step 2: Run `node scripts/oss-deploy-lib.test.mjs` only if already used elsewhere; otherwise verify through existing frontend build and test coverage**
- [ ] **Step 3: Implement the minimal alias updates**
- [ ] **Step 4: Re-run the relevant checked-in verification command**
### Task 6: Full Verification And Release
**Files:**
- Modify only if verification reveals issues
- [ ] **Step 1: Run `cd front && npm run test`**
- [ ] **Step 2: Run `cd front && npm run lint`**
- [ ] **Step 3: Run `cd front && npm run build`**
- [ ] **Step 4: Run `cd backend && mvn test`**
- [ ] **Step 5: Run `cd backend && mvn package`**
- [ ] **Step 6: Deploy frontend with `node scripts/deploy-front-oss.mjs`**
- [ ] **Step 7: Deploy backend jar to the discovered production host and restart `my-site-api.service` using the real server procedure**