Cardhop
Cardhop 是 Flexibits 出品的联系人应用。Protocol Launcher 可以生成 Cardhop 链接,用于打开应用、解析联系人操作、显示联系人或视图,以及打开官方支持的偏好设置路径。
使用
提供两种使用方式:
- 按需加载(通过子路径导入),支持 Tree Shaking,体积更小。
- 全量导入(从根包导入),使用简单,但会包含所有应用模块。
生产环境建议使用按需加载以减小体积;快速脚本或演示可选择全量导入。
选择安装方式
按需加载
推荐使用。生产环境优化。
全量导入
使用便捷。适合快速脚本。
Flexibits 官方文档列出了 x-cardhop://、parse、show 和 preferences URL handler。本模块只覆盖这些已记录的入口和参数。
打开
打开 Cardhop。
ts
import { open } from 'protocol-launcher/cardhop'
const url = open()Parse
使用官方文档中的 s 文本参数打开 Cardhop 解析器。
ts
import { parse } from 'protocol-launcher/cardhop'
const url = parse({
s: 'call Mike',
})使用 list 过滤结果;当解析出的新联系人需要立即添加时,可使用 Cardhop 官方记录的 add 值(Y、y、T、t 或 1-9)。
ts
import { parse } from 'protocol-launcher/cardhop'
const url = parse({
s: 'Sarah Jones',
list: 'Friends',
add: '1',
})Show
按姓名或标识符显示联系人。
ts
import { show } from 'protocol-launcher/cardhop'
const url = show({
contact: 'Mike Ross',
})显示联系人时可带上官方记录的操作和列表过滤。
ts
import { show } from 'protocol-launcher/cardhop'
const url = show({
id: 'REPLACE_WITH_CONTACT_ID',
action: 'mail',
list: 'Team',
})显示 Cardhop 官方记录的视图。
ts
import { show } from 'protocol-launcher/cardhop'
const url = show({
view: 'contacts',
list: 'Friends',
})Preferences
打开 Cardhop 支持的偏好设置路径。
ts
import { preferences } from 'protocol-launcher/cardhop'
const url = preferences({
path: 'notifications',
})