Skip to content

Tim

Tim 是一款 macOS 时间追踪应用。Protocol Launcher 允许您生成 Tim 深度链接。

使用方式

有两种使用此库的方式:

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

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

选择安装方式

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

注意事项

Tim 官方帮助页明确列出的 URL 形式只有:tim://tim://[id]tim://[id]?action=start&notes=My%20Notestim://?action=stoptim://create?type=[task|group]&title=My%20Title&notes=My%20Notestim://x-callback-url/getCurrentUrl?x-success=https://www.apple.com

createTask()createGroup() 只暴露官方明确列出的 task/group 类型以及 titlenotes。官方页面没有列出其他 query 字段名,因此这里不额外添加。

打开 Tim

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

const url = open()

打开任务或分组

On-Demand
ts
import { openTaskOrGroup } from 'protocol-launcher/tim'

const url = openTaskOrGroup({
  id: 'D43FA035-6406-495D-9ADD-46721986040F',
})

开始任务计时

On-Demand
ts
import { startTask } from 'protocol-launcher/tim'

const url = startTask({
  id: 'D43FA035-6406-495D-9ADD-46721986040F',
  notes: 'My Notes',
})

停止计时

On-Demand
ts
import { stopTimer } from 'protocol-launcher/tim'

const url = stopTimer()

创建任务

On-Demand
ts
import { createTask } from 'protocol-launcher/tim'

const url = createTask({
  title: 'My Title',
  notes: 'My Notes',
})

创建分组

On-Demand
ts
import { createGroup } from 'protocol-launcher/tim'

const url = createGroup({
  title: 'My Title',
  notes: 'My Notes',
})

获取当前 URL

On-Demand
ts
import { getCurrentUrl } from 'protocol-launcher/tim'

const url = getCurrentUrl({
  xSuccess: 'https://www.apple.com',
})

生成的 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&notes=My%20Notes'

stopTimer()
// => 'tim://?action=stop'

createTask({
  title: 'My Title',
  notes: 'My Notes',
})
// => 'tim://create?type=task&title=My%20Title&notes=My%20Notes'

createGroup({
  title: 'My Title',
  notes: 'My Notes',
})
// => 'tim://create?type=group&title=My%20Title&notes=My%20Notes'

getCurrentUrl({
  xSuccess: 'https://www.apple.com',
})
// => 'tim://x-callback-url/getCurrentUrl?x-success=https://www.apple.com'

官方文档