Alfred
Alfred 是一款屡获殊荣的 macOS 效率应用。它通过热键、关键词、文本扩展等功能提升您的工作效率。搜索您的 Mac 和网络,并使用自定义操作来控制您的 Mac。Protocol Launcher 允许您生成深度链接来打开 Alfred、导航偏好设置、浏览画廊中的工作流以及创建自定义搜索。
用法
有两种使用此库的方式:
- 按需导入(On-Demand)从子路径导入,支持 tree-shaking,保持打包体积小。
- 完整导入(Full Import)从根包导入,使用方便但包含所有应用模块。
生产构建请选择按需导入;完整导入适合快速脚本或演示。
选择安装方式
按需加载
推荐使用。生产环境优化。
全量导入
使用便捷。适合快速脚本。
打开 Alfred
ts
import { open } from 'protocol-launcher/alfred'
const url = open()打开偏好设置
ts
import { openPreferences } from 'protocol-launcher/alfred'
const url = openPreferences()导航到偏好设置部分
ts
import { navigateTo } from 'protocol-launcher/alfred'
const url = navigateTo({
path: '{
"path": "workflows"
}',
})导航到解析依赖
ts
import { navigateTo } from 'protocol-launcher/alfred'
const url = navigateTo({
path: '{
"path": "workflows>resolvedependencies"
}',
})导航到指定工作流
ts
import { navigateTo } from 'protocol-launcher/alfred'
const url = navigateTo({
path: '{
"path": "workflows>workflow>user.workflow.81CBDAC6-527B-4B33-BA4E-F12563EBED09"
}',
})导航到代码片段
ts
import { navigateTo } from 'protocol-launcher/alfred'
const url = navigateTo({
path: '{
"path": "features>snippets"
}',
})打开画廊工作流
ts
import { gallery } from 'protocol-launcher/alfred'
const url = gallery({
author: 'alanhe',
workflow: 'about-mac',
})打开 1Password 画廊工作流
ts
import { gallery } from 'protocol-launcher/alfred'
const url = gallery({
author: 'alfredapp',
workflow: '1password',
})创建自定义搜索
ts
import { customSearch } from 'protocol-launcher/alfred'
const url = customSearch({
title: 'Search Github for '{query}'',
keyword: 'gh',
url: 'https://github.com/search?q={query}',
})