Skip to content

Choosy

Choosy 是一款 macOS 浏览器选择工具。Protocol Launcher 允许你生成 URL,通过 Choosy 打开网页链接。

使用方式

有两种使用此库的方式:

  • 按需导入(On-Demand):从子路径导入支持 tree-shaking,保持较小的打包体积。
  • 完整导入(Full Import):从根包导入更方便,但会包含所有应用模块。

生产构建建议选择按需导入;快速脚本或演示可以使用完整导入。

选择安装方式

按需加载
推荐使用。生产环境优化。
全量导入
使用便捷。适合快速脚本。

说明

此模块遵循 Choosy 官方 API 文档,其 URL 形状为 x-choosy://api-method/web-url

内置 helper 只覆盖 Choosy 官方文档列出的 API method:openprompt.allprompt.runningbest.allbest.running。Choosy 也记录了用户自定义 API method,因此 customApiMethod 接收你在 Choosy 规则里配置的 method 名称。

打开

On-Demand
ts
import { open } from 'protocol-launcher/choosy'

const url = open({
  url: 'https://example.com',
})

提示所有浏览器

On-Demand
ts
import { promptAll } from 'protocol-launcher/choosy'

const url = promptAll({
  url: 'https://www.georgebrock.com',
})

提示正在运行的浏览器

On-Demand
ts
import { promptRunning } from 'protocol-launcher/choosy'

const url = promptRunning({
  url: 'https://example.com',
})

最喜欢的浏览器

On-Demand
ts
import { bestAll } from 'protocol-launcher/choosy'

const url = bestAll({
  url: 'https://example.com',
})

最喜欢且正在运行的浏览器

On-Demand
ts
import { bestRunning } from 'protocol-launcher/choosy'

const url = bestRunning({
  url: 'https://example.com',
})

自定义 API Method

On-Demand
ts
import { customApiMethod } from 'protocol-launcher/choosy'

const url = customApiMethod({
  method: 'edit',
  url: 'https://www.example.com',
})

官方文档