@atkonoffice/sdk 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -50
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,52 +1,3 @@
|
|
|
1
1
|
# @atkonoffice/sdk
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
## 安装
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install @atkonoffice/sdk
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## 用法
|
|
12
|
-
|
|
13
|
-
```js
|
|
14
|
-
import { atkonoffice } from '@atkonoffice/sdk'
|
|
15
|
-
|
|
16
|
-
// 指向你的后端(拉起的签名工作在后端完成,密钥不进浏览器)
|
|
17
|
-
atkonoffice.config({ backendBase: 'https://your-backend.example.com' })
|
|
18
|
-
|
|
19
|
-
// 收保存回传:编辑器保存完成后回推到这里
|
|
20
|
-
atkonoffice.on('documentSaved', (e) => {
|
|
21
|
-
// e.doc_id 已保存到你的后端存储
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
// 打开一份已存在的文档
|
|
25
|
-
await atkonoffice.open({ params: { docId: 'report.docx' } })
|
|
26
|
-
|
|
27
|
-
// 新建一份空白文档('word' | 'excel' | 'ppt'):把 hostPagePath 指向你后端对应的新建宿主页路由,
|
|
28
|
-
// 客户端会打开一份 SDK 自带空白模板。新文档的落盘命名由你的后端保存端点决定;若要以你为新文档预分配的 id
|
|
29
|
-
// 落盘,由你的编辑承载页在保存时透传(完整示例见参考集成 atkonoffice-integration)。
|
|
30
|
-
await atkonoffice.open({
|
|
31
|
-
create: 'word',
|
|
32
|
-
params: { docId: 'new-report.docx' },
|
|
33
|
-
hostPagePath: '/atkonoffice/host-page/create/word',
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
// 你的业务编辑页有首屏登录守卫(进页先读 localStorage 判登录态,否则重定向登录页)时:把登录令牌作为
|
|
37
|
-
// storage 交给客户端。客户端内是独立的浏览器环境、localStorage 本是空的,直接打开会被守卫判未登录;传了
|
|
38
|
-
// storage,客户端会在你的编辑页首屏脚本执行**之前**把它逐键写进壳内 localStorage,守卫随即放行、直接进
|
|
39
|
-
// 编辑器(**编辑页无需为客户端做任何改造**)。
|
|
40
|
-
await atkonoffice.open({
|
|
41
|
-
page: 'https://your-app.example.com/host/edit?docId=report.docx',
|
|
42
|
-
params: { docId: 'report.docx' },
|
|
43
|
-
storage: { token: '<你的用户登录令牌>' },
|
|
44
|
-
})
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
`storage` 是一份 `{ 键: 值 }`(值为字符串)快照,有**两个互补的消费面**,缺一不可:
|
|
48
|
-
|
|
49
|
-
- **前端 localStorage**:在编辑页首屏脚本执行前逐键写入壳内 `localStorage`,让你原有的登录守卫放行。
|
|
50
|
-
- **数据面鉴权**:同一份 `storage` 还会序列化进 `X-Atkonoffice-Storage` 头,随编辑器数据面请求发回你的后端做鉴权。
|
|
51
|
-
|
|
52
|
-
两处消费同一份 `storage`、不可互替——只保留其一会破坏另一侧能力。
|
|
3
|
+
atkonoffice 文档编辑器的浏览器侧 SDK:在你的业务页里拉起编辑器,编辑完成后收到保存回传。
|