Skip to content

Add local YAML file import feature for subscription manager - #33913

Open
kitenium wants to merge 1 commit into
hq450:3.0from
kitenium:feature/local-yaml-import
Open

Add local YAML file import feature for subscription manager#33913
kitenium wants to merge 1 commit into
hq450:3.0from
kitenium:feature/local-yaml-import

Conversation

@kitenium

@kitenium kitenium commented Aug 26, 2026

Copy link
Copy Markdown

订阅管理器支持本地 YAML 文件导入

概述

在订阅管理器对话框中新增「本地文件导入」标签页,支持上传本地 Clash/Mihomo YAML 配置文件,自动解析并导入代理节点。此前用户只能通过订阅链接或分享链接导入节点,本次更新新增了基于本地文件的第三种导入方式。

新增功能

  • 新增「本地文件导入」标签页:支持拖拽上传和点击选择文件
  • 自动检测文件格式:Clash/Mihomo YAML(含 proxies 字段)、纯文本 URI 列表、Base64 编码的 URI 列表
  • 导入后自动关联订阅配置:上传的节点会关联到一个自动创建的订阅配置(本地YAML导入),可在订阅配置管理中统一管理
  • 支持格式.yaml.yml.txt

改动详情

后端 (ss_node_subscribe.sh)

  • subprof_create_local_import_profile() — 创建本地导入的订阅配置 dbus 记录,确保导入节点正确关联到订阅配置
  • start_yaml_file_import()(action "5")— 主导入入口:定位上传文件、校验大小、创建订阅配置、通过 sub-tool inspect 检测格式并解析,写入 dbus 时关联 _profile_id
  • 支持三种格式:clash-yamluri-linesbase64-uri-lines

前端 (Module_shadowsocks.asp)

  • 订阅管理器对话框中新增「本地文件导入」标签页
  • 拖拽区域支持 ondragover/ondrop 事件(调用 preventDefault() 阻止浏览器默认下载行为)
  • on_submgr_yaml_file_dropped() — 处理拖拽文件,校验扩展名,暂存文件
  • on_submgr_yaml_file_selected() — 处理点击选择文件
  • submit_subscription_yaml_from_manager() — 通过 FormData 上传文件至 /_upload,完成后触发导入 action "5"
  • 导入完成后自动切换到订阅配置管理标签页,无需手动关闭再重新打开
  • YAML 标签页下按钮文案改为「上传并解析节点」

Add Local YAML File Import for Subscription Manager

Summary

Add a new "本地文件导入" (Local File Import) tab in the subscription manager dialog, allowing users to upload local Clash/Mihomo YAML configuration files and import proxy nodes directly. Previously, users could only import nodes via subscription URLs or share links — this adds a third entry point for local file-based imports.

What's New

  • New "本地文件导入" tab in the subscription manager with drag-and-drop and click-to-browse file upload
  • Auto-detects file format: Clash/Mihomo YAML (with proxies field), plain URI lines, or base64-encoded URI blocks
  • Imports into a subscription profile: uploaded nodes are associated with a created profile record (本地YAML导入), so they appear in the profiles list and can be managed like regular subscriptions
  • Supports formats: .yaml, .yml, .txt

Changes

Backend (ss_node_subscribe.sh)

  • subprof_create_local_import_profile() — creates a subscription profile dbus record for local file imports so imported nodes are properly associated with a profile
  • start_yaml_file_import() (action "5") — the main import entry point: locates the uploaded file, validates size, creates a profile, detects format via sub-tool inspect, parses accordingly, and writes nodes to dbus with _profile_id association
  • Handles three format cases: clash-yaml, uri-lines, and base64-uri-lines

Frontend (Module_shadowsocks.asp)

  • Added "本地文件导入" tab in the subscription manager dialog UI
  • Drop zone with ondragover/ondrop handlers (calls preventDefault() to stop browser from downloading the file)
  • on_submgr_yaml_file_dropped() — handles drag-and-drop file input, validates extension, stores file for upload
  • on_submgr_yaml_file_selected() — handles click-to-browse file selection
  • submit_subscription_yaml_from_manager() — uploads file via FormData to /_upload, then triggers import action "5"
  • Auto-switches to the profiles tab after import completes so the user sees the updated profile list immediately
  • Button relabeled to "上传并解析节点" when on the YAML tab
Screenshot 2026-08-26 at 12 15 40 pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant