Motrix
Motrix 是一款全功能的下载管理器,支持 HTTP、FTP、BitTorrent、磁力链等多种下载协议。Protocol Launcher 允许您生成深度链接以创建下载任务和控制 Motrix。
使用方式
有两种使用此库的方式:
- 按需导入(On-Demand):从子路径导入支持 tree-shaking,保持较小的打包体积。
- 完整导入(Full Import):从根包导入更方便,但会包含所有应用模块。
生产构建建议选择按需导入;快速脚本或演示可以使用完整导入。
选择安装方式
按需加载
推荐使用。生产环境优化。
全量导入
使用便捷。适合快速脚本。
打开 Motrix
ts
import { open } from 'protocol-launcher/motrix'
const url = open()新建下载任务
ts
import { newTask } from 'protocol-launcher/motrix'
const url = newTask({
uri: 'https://example.com/file.dmg',
out: 'myfile.dmg',
})新建 BitTorrent 任务
ts
import { newBtTask } from 'protocol-launcher/motrix'
const url = newBtTask()打开任务列表
ts
import { openTaskList } from 'protocol-launcher/motrix'
const url = openTaskList()暂停所有任务
ts
import { pauseAllTask } from 'protocol-launcher/motrix'
const url = pauseAllTask()恢复所有任务
ts
import { resumeAllTask } from 'protocol-launcher/motrix'
const url = resumeAllTask()打开偏好设置
ts
import { preferences } from 'protocol-launcher/motrix'
const url = preferences()打开关于页面
ts
import { about } from 'protocol-launcher/motrix'
const url = about()