Appearance
ONLYOFFICE 实施
前置条件
- OARS 后端可被 ONLYOFFICE Document Server 访问。
- 浏览器可访问
document-server-url/web-apps/apps/api/documents/api.js。 onlyoffice.jwt-secret至少 32 字节,并与 Document Server JWT 配置一致。- 文档记录有
latestFileId,对应sys_file文件可读取。
配置项
onlyoffice.enabled=trueonlyoffice.document-server-url:浏览器加载编辑器脚本使用。onlyoffice.public-base-url:Document Server 回调 OARS 使用,通常包含/oars。onlyoffice.jwt-secret:生成编辑配置、文件访问和回调 token。
开发配置当前示例:Document Server http://127.0.0.1:8082,回调地址 http://host.containers.internal:8080/oars。
联调链路
- 前端调用
GET /app/document/{id}/editor-config。 - 后端生成
document.url指向GET /app/document/content/{id}?token=...。 - ONLYOFFICE 保存时回调
POST /app/document/callback/{id}?token=...。 - 回调状态
2或6会下载新文件,写入sys_file和doc_document_version。
排查检查项
- 编辑器未加载:先查脚本 URL 是否能被浏览器访问。
- 回调失败:从 ONLYOFFICE 容器内访问
/oars/actuator/health。 - 保存不落版本:查
doc_document_log、doc_document_version、后端日志。 - 报 JWT 错:核对 OARS 和 Document Server 的 JWT 密钥及长度。
生产环境的 Document Server 域名、HTTPS、内外网回调地址和 JWT 配置需按实际部署方式调整。
