Timepage
Timepage 是一款用于管理日程、事件和天气的日历应用。Protocol Launcher 可以生成官方 Timepage URL scheme 链接。
使用方式
有两种使用此库的方式:
- 按需导入(On-Demand):从子路径导入支持 tree-shaking,保持较小的打包体积。
- 完整导入(Full Import):从根包导入更方便,但会包含所有应用模块。
生产构建建议选择按需导入;快速脚本或演示可以使用完整导入。
选择安装方式
按需加载
推荐使用。生产环境优化。
全量导入
使用便捷。适合快速脚本。
打开 Timepage
ts
import { open } from 'protocol-launcher/timepage'
const url = open()添加事件
ts
import { addEvent } from 'protocol-launcher/timepage'
const url = addEvent({
title: 'Team Sync',
day: 'today',
})只有在需要 Timepage 官方 x-callback-url 形式时,才传入 x-success 或 x-cancel:
ts
import { addEvent } from 'protocol-launcher/timepage'
const url = addEvent({
title: 'Team Sync',
day: 'tomorrow',
xSuccess: 'shortcuts://callback',
xCancel: 'shortcuts://cancel',
})打开事件
ts
import { openEvent } from 'protocol-launcher/timepage'
const url = openEvent({
event: 'next',
})打开事件地图
ts
import { openEventMap } from 'protocol-launcher/timepage'
const url = openEventMap({
event: 'next',
})打开日期
ts
import { openDay } from 'protocol-launcher/timepage'
const url = openDay({
day: '2026-03-30',
})打开周
ts
import { openWeek } from 'protocol-launcher/timepage'
const url = openWeek({
week: 'this',
})官方 index 参数也支持数字偏移量:
ts
import { openWeek } from 'protocol-launcher/timepage'
const url = openWeek({
week: -1,
})打开月份
ts
import { openMonth } from 'protocol-launcher/timepage'
const url = openMonth({
month: 'next',
})打开天气
ts
import { openWeather } from 'protocol-launcher/timepage'
const url = openWeather({
day: 'today',
})ts
import { openWeather } from 'protocol-launcher/timepage'
const url = openWeather({
week: 'next',
})搜索
ts
import { search } from 'protocol-launcher/timepage'
const url = search({
query: 'project review',
})获取事件
ts
import { getEvent } from 'protocol-launcher/timepage'
const url = getEvent({
event: 'next',
xSuccess: 'shortcuts://callback',
})Timepage 会调用 x-success 回调,并带上 start、end、title 和 location 参数。