Skip to content

feat #支持 url json导入 #69

Closed
Closed

Description

@gaoconggit

扩展现有的json导入功能,在支持上传本地json文件的基础上,扩展支持在线 json,如 github rawcontent

Activity

  1. gaoconggit commented on Oct 27, 2025

    @gaoconggit
    OwnerAuthor

    @claude 实现这个功能

  2. claude commented on Oct 27, 2025

    @claude

    Claude finished @gaoconggit's task —— View job • claude/issue-69-20251027-1531 • Create PR ➔


    Implementing URL JSON Import Feature ✅

    I've successfully implemented URL JSON import support for the folder import feature!

    Task List

    • Read project guidelines (CLAUDE.md)
    • Explore current JSON import implementation
    • Design the enhancement (UI + backend)
    • Implement frontend UI changes (add URL input option)
    • Add error handling and validation
    • Test the implementation (build successful)
    • Commit and push changes
    • Provide PR creation link

    Implementation Summary

    Modified File: SharpPad/wwwroot/fileSystem/fileManager.js

    New Features:

    1. Two-way Import Selection - When users click "导入" (Import) in the folder context menu, they now see a modal dialog with two options:

      • 📁 从本地文件导入 (Import from local file)
      • 🌐 从 URL 导入 (Import from URL)
    2. URL Import Support - The new URL import feature includes:

      • URL input prompt with validation
      • Support for any publicly accessible JSON URL (including GitHub raw content)
      • Automatic content fetching using the Fetch API
      • Content-type validation with warnings for non-JSON files
      • Comprehensive error handling for network failures and CORS issues
      • User-friendly error messages in Chinese
    3. Code Organization - Refactored the original file import logic into separate methods:

      • selectImportMethod() - Shows the selection dialog
      • importFromUrl() - Handles URL-based imports
      • importFromFile() - Handles local file uploads (original functionality)

    Key Benefits:

    • ✅ Supports GitHub raw content URLs (e.g., https://raw.githubusercontent.com/...)
    • ✅ Works with any publicly accessible JSON URL
    • ✅ No backend changes required (pure frontend implementation)
    • ✅ Maintains 100% backward compatibility with existing file upload
    • ✅ Simple and intuitive user interface
    • ✅ Robust error handling and validation

    Testing:

    • ✅ Build successful with no new errors or warnings
    • ✅ Code follows project guidelines (simplicity, readability, minimal changes)

    Example Usage

    Users can now import folders from URLs like:

    • GitHub raw content: https://raw.githubusercontent.com/user/repo/main/folder.json
    • Any public JSON file: https://example.com/data/folder.json

    --- • Branch: claude/issue-69-20251027-1531

  3. added a commit that references this issue on Oct 27, 2025
    d63f72e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions