fix: migrate UploadPage to V2 API and fix logout navigation

Changes:
- Add uploadFile() method to apiClientV2 for single file uploads
- Update UploadPage to use apiClientV2 instead of apiClient
- Change upload logic to iterate files and collect task IDs
- Add navigation to /login after logout in Layout component

Fixes:
- 403 Forbidden error on file upload (token mismatch between V1/V2 APIs)
- Logout button not redirecting to login page after clearing auth

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
egg
2025-11-16 19:22:36 +08:00
parent ad5c8be0a3
commit 439458c7fe
3 changed files with 38 additions and 7 deletions

View File

@@ -284,6 +284,24 @@ class ApiClientV2 {
return response.data.sessions
}
// ==================== File Upload ====================
/**
* Upload a file
*/
async uploadFile(file: File): Promise<{ task_id: string; filename: string; file_size: number; file_type: string; status: string }> {
const formData = new FormData()
formData.append('file', file)
const response = await this.client.post('/upload', formData, {
headers: {
'Content-Type': 'multipart/form-data',
},
})
return response.data
}
// ==================== Task Management ====================
/**