Skip to content

Launch Center Pro

Launch Center Pro 是一款用于运行动作和快捷操作的 iOS 启动器。Protocol Launcher 允许您为 Contrast 官方文档中记录的 Launch Center Pro 动作生成深度链接。

使用方式

有两种使用此库的方式:

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

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

选择安装方式

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

URL 方法

这些 helper 按照 Contrast 官方的 x-callback-url SupportDropbox ActionsScheduling Action Notifications 和发布说明示例实现。未在官方文档中给出语法或已经停止支持的 Launch Center Pro 动作不会包装。

打开应用

On-Demand
ts
import { open } from 'protocol-launcher/launch-center-pro'

const url = open()

亮度

On-Demand
ts
import { brightness } from 'protocol-launcher/launch-center-pro'

const url = brightness()

const callbackUrl = brightness({
  xSuccess: 'tweetbot://',
})

剪贴板

On-Demand
ts
import { clipboard } from 'protocol-launcher/launch-center-pro'

const textUrl = clipboard({
  text: 'mytext',
})

const photoUrl = clipboard({
  attach: 'photo:last',
})

定义

On-Demand
ts
import { define } from 'protocol-launcher/launch-center-pro'

const url = define()

朗读

On-Demand
ts
import { speak } from 'protocol-launcher/launch-center-pro'

const url = speak({
  text: 'Hello master!',
})

const callbackUrl = speak({
  text: 'Hello master!',
  xSuccess: '[action:15]',
})

邮件

On-Demand
ts
import { email } from 'protocol-launcher/launch-center-pro'

const url = email({
  to: 'sample@contrast.co',
  subject: 'Last Photo',
  body: '',
  cc: '',
  bcc: '',
  attach: 'photo:last',
})

短信

On-Demand
ts
import { messaging } from 'protocol-launcher/launch-center-pro'

const photoUrl = messaging({
  to: '555-555-5555',
  attach: 'photo:last',
})

const dropboxPhotoUrl = messaging({
  to: '555-555-5555',
  body: '[prompt:Body]',
  attach: 'photo:dropbox',
  path: 'reactions',
})

const gifUrl = messaging({
  attach: 'photo:gif',
  'gif-search': 'excited',
})

Dropbox

On-Demand
ts
import { dropbox } from 'protocol-launcher/launch-center-pro'

const url = dropbox()

Dropbox 添加照片

On-Demand
ts
import { dropboxAddPhoto } from 'protocol-launcher/launch-center-pro'

const url = dropboxAddPhoto({
  attach: 'photo:frontcamera',
  path: '/selfies/',
})

const callbackUrl = dropboxAddPhoto({
  attach: 'photo:last',
  path: '/snaps/',
  getlink: 'yes',
  xSuccess: 'launch://tweet?text=[clipboard]',
})

Dropbox 复制直接链接

On-Demand
ts
import { dropboxCopyDirectLink } from 'protocol-launcher/launch-center-pro'

const url = dropboxCopyDirectLink()

计划动作通知

On-Demand
ts
import { schedule } from 'protocol-launcher/launch-center-pro'

const actionUrl = schedule({
  action: 179,
  in: '1h',
  repeat: 'specificdays',
  days: 'm,tu,w,th,f',
})

const urlNotification = schedule({
  url: '[url:https://apple.com]',
  in: '10min',
})

分享表单

On-Demand
ts
import { shareSheet } from 'protocol-launcher/launch-center-pro'

const url = shareSheet({
  attach: 'photo:last',
  text: '[prompt-fleksy:Notes]',
  url: '[clipboard]',
})

QR 动作

On-Demand
ts
import { qr } from 'protocol-launcher/launch-center-pro'

const url = qr()

Dropbox 新建文本文件

On-Demand
ts
import { dropboxNew } from 'protocol-launcher/launch-center-pro'

const url = dropboxNew({
  text: '[prompt-return:My Note]',
  path: '/Notes/',
  name: 'MyFile.markdown',
  overwrite: 'NO',
})

Dropbox 追加文本

On-Demand
ts
import { dropboxAppend } from 'protocol-launcher/launch-center-pro'

const url = dropboxAppend({
  text: 'Next line',
  name: 'MyFile.markdown',
  linebreak: 'NO',
})

Dropbox 前置文本

On-Demand
ts
import { dropboxPrepend } from 'protocol-launcher/launch-center-pro'

const url = dropboxPrepend({
  text: 'First line\nBody',
  name: 'note_[firstline].text',
  leavefirstline: 'NO',
})

Dropbox 剪贴板

On-Demand
ts
import { dropboxClipboard } from 'protocol-launcher/launch-center-pro'

const browserUrl = dropboxClipboard()

const linkUrl = dropboxClipboard({
  path: '/photos/',
  linkonly: 'yes',
})