Skip to content

Microsoft OneNote

Microsoft OneNote 是 Microsoft 的数字笔记应用。Protocol Launcher 可以打开 Microsoft Graph 返回的官方 OneNote client URL。

使用方式

有两种使用此库的方式:

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

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

选择安装方式

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

说明

Microsoft Graph 会在 page 和 notebook 资源上提供 OneNote 链接。links 属性包含 oneNoteClientUrl.hrefoneNoteWebUrl.href。使用 links.oneNoteClientUrl.href 作为原生 OneNote client URL,并把这个已知 URL 传给 openClientUrl。helper 会校验文档记录的 onenote: 前缀和 HTTPS 目标,然后原样返回 URL。

不要根据 ID 自行拼接 OneNote page 或 notebook URL。Microsoft 文档记录的是从 Graph 返回的 oneNoteClientUrl 值打开客户端。

对于 Android,Microsoft 文档记录了一个额外步骤:启动 Intent 前,oneNoteClientUrl 中的 GUID 字符串必须包上 {}openAndroidClientUrl 只用于这个文档记录的 Android client 流程。

Open Client URL

On-Demand
ts
import { openClientUrl } from 'protocol-launcher/microsoft-onenote'

const url = openClientUrl({
  href: 'onenote:https://...',
})

Open Android Client URL

On-Demand
ts
import { openAndroidClientUrl } from 'protocol-launcher/microsoft-onenote'

const oneNoteClientUrl = response.links.oneNoteClientUrl.href
const url = openAndroidClientUrl({ href: oneNoteClientUrl })

生成的 URL

ts
openClientUrl(clientUrlParams)
// => 'onenote:https://...'

参考资料