Box
Box 是一款云端文件共享和内容管理应用。Protocol Launcher 允许你生成移动端链接,用来打开 Box folder、file 和 shared link。
使用
有两种方式可以使用此库:
- 按需从子路径导入,支持 Tree Shaking 并保持包体积较小。
- 从根包完整导入更适合快速脚本或示例,但会包含全部应用模块。
生产构建建议使用按需导入;快速演示可以使用完整导入。
选择安装方式
按需加载
推荐使用。生产环境优化。
全量导入
使用便捷。适合快速脚本。
URL 方法
Box 官方移动端 deep linking 文档列出了 Box 和 Box for EMM 中打开 folder、file、shared link 对象的链接。本模块只暴露这些官方记录的形式。
打开 Folder
生成官方记录的 URL,在 Box 移动端 app 中打开一个 folder 对象。
ts
import { openFolder } from 'protocol-launcher/box'
const url = openFolder({
id: '123456789',
})打开 File
生成官方记录的 URL,在 Box 移动端 app 中打开一个 file 对象。
ts
import { openFile } from 'protocol-launcher/box'
const url = openFile({
id: '987654321',
})打开 Shared Link
生成官方记录的 URL,在 Box 移动端 app 中打开一个 shared link。
ts
import { openSharedLink } from 'protocol-launcher/box'
const url = openSharedLink({
url: 'https://app.box.com/s/shared-link-id',
})打开 EMM Folder
生成官方记录的 URL,在 Box for EMM 中打开一个 folder 对象。
ts
import { openEmmFolder } from 'protocol-launcher/box'
const url = openEmmFolder({
id: '123456789',
})打开 EMM File
生成官方记录的 URL,在 Box for EMM 中打开一个 file 对象。
ts
import { openEmmFile } from 'protocol-launcher/box'
const url = openEmmFile({
id: '987654321',
})打开 EMM Shared Link
生成官方记录的 URL,在 Box for EMM 中打开一个 shared link。
ts
import { openEmmSharedLink } from 'protocol-launcher/box'
const url = openEmmSharedLink({
url: 'https://app.box.com/s/shared-link-id',
})生成的 URL
ts
openFolder({ id: '123456789' })
// => 'boxapp://folder?id=123456789'
openFile({ id: '987654321' })
// => 'boxapp://file?id=987654321'
openSharedLink({ url: 'https://app.box.com/s/shared-link-id' })
// => 'boxapp://sharedlink?url=https%3A%2F%2Fapp.box.com%2Fs%2Fshared-link-id'
openEmmFolder({ id: '123456789' })
// => 'boxemm://folder?id=123456789'
openEmmFile({ id: '987654321' })
// => 'boxemm://file?id=987654321'
openEmmSharedLink({ url: 'https://app.box.com/s/shared-link-id' })
// => 'boxemm://sharedlink?url=https%3A%2F%2Fapp.box.com%2Fs%2Fshared-link-id'