简体中文
Tim
Tim 是一款 macOS 时间追踪应用。Protocol Launcher 允许您生成 Tim 深度链接。
使用方式
有两种使用此库的方式:
- 按需导入(On-Demand):从子路径导入支持 tree-shaking,保持较小的打包体积。
- 完整导入(Full Import):从根包导入更方便,但会包含所有应用模块。
生产构建建议选择按需导入;快速脚本或演示可以使用完整导入。
选择安装方式
按需加载
推荐使用。生产环境优化。
全量导入
使用便捷。适合快速脚本。
注意事项
当前官方帮助涵盖应用/窗口导航、任务/分组/记录 ID、计时器控制、已弃用的 create 链接及 getCurrentUrl 回调。createRecord() 需要任务 ID 和 ISO 8601 起止时间。上游已弃用所有 create 函数对应的链接。嵌套回调 URL 会进行百分号编码。
打开 Tim
ts
import { open } from 'protocol-launcher/tim'
const url = open()打开任务或分组
ts
import { openTaskOrGroup } from 'protocol-launcher/tim'
const url = openTaskOrGroup({
id: 'D43FA035-6406-495D-9ADD-46721986040F',
})开始任务计时
ts
import { startTask } from 'protocol-launcher/tim'
const url = startTask({
id: 'D43FA035-6406-495D-9ADD-46721986040F',
notes: 'My Notes',
})停止计时
ts
import { stopTimer } from 'protocol-launcher/tim'
const url = stopTimer()创建任务
ts
import { createTask } from 'protocol-launcher/tim'
const url = createTask({
title: 'My Title',
notes: 'My Notes',
})创建分组
ts
import { createGroup } from 'protocol-launcher/tim'
const url = createGroup({
title: 'My Title',
notes: 'My Notes',
})获取当前 URL
ts
import { getCurrentUrl } from 'protocol-launcher/tim'
const url = getCurrentUrl({
xSuccess: 'https://www.apple.com',
})打开设置
打开设置窗口。
ts
import { openSettings } from 'protocol-launcher/tim'
const url = openSettings()打开导出
打开导出窗口。
ts
import { openExport } from 'protocol-launcher/tim'
const url = openExport()打开升级
打开升级窗口。
ts
import { openUpgrade } from 'protocol-launcher/tim'
const url = openUpgrade()创建记录(已弃用)
使用 ISO 8601 起止时间为任务创建计时记录。Tim 将 create 链接标记为已弃用。
ts
import { createRecord } from 'protocol-launcher/tim'
const url = createRecord({
'task': 'REPLACE_WITH_TASK_ID',
'start': '2026-10-02T01:00:00Z',
'end': '2026-10-02T02:00:00Z',
'notes': 'Code review'
})生成的 URL
ts
open()
// => 'tim://'
openTaskOrGroup({
id: 'D43FA035-6406-495D-9ADD-46721986040F',
})
// => 'tim://D43FA035-6406-495D-9ADD-46721986040F'
startTask({
id: 'D43FA035-6406-495D-9ADD-46721986040F',
notes: 'My Notes',
})
// => 'tim://D43FA035-6406-495D-9ADD-46721986040F?action=start¬es=My%20Notes'
stopTimer()
// => 'tim://?action=stop'
createTask({
title: 'My Title',
notes: 'My Notes',
})
// => 'tim://create?type=task&title=My%20Title¬es=My%20Notes'
createGroup({
title: 'My Title',
notes: 'My Notes',
})
// => 'tim://create?type=group&title=My%20Title¬es=My%20Notes'
getCurrentUrl({
xSuccess: 'https://www.apple.com',
})
// => 'tim://x-callback-url/getCurrentUrl?x-success=https%3A%2F%2Fwww.apple.com'