当前位置: 首页 > news >正文

docker 安装 onlyoffice

1.文档地址

Installing ONLYOFFICE Docs for Docker on a local server - ONLYOFFICE

2.安装onlyoffice

docker run -i -t -d -p 9000:8000 --restart=always -e JWT_ENABLED=false onlyoffice/documentserver

如果发现镜像无法下载,可以尝试更换镜像源

{"registry-mirrors": ["https://do.nark.eu.org","https://dc.j8.work","https://docker.m.daocloud.io","https://dockerproxy.com","https://docker.mirrors.ustc.edu.cn","https://docker.nju.edu.cn"]
}

 参考从Docker Hub 拉取镜像一直失败超时?这些解决方案帮你解决烦恼_docker拉取镜像超时-CSDN博客

3.启动成功后,访问服务,查看服务是否启动成功

 访问时,localhost和127.0.0.1都可以试试,可能有些不能访问

访问 http://localhost:9000/welcome/

访问 http://localhost:9000/web-apps/apps/api/documents/api.js

说明启动成功

4.集成到vue 

<script type='text/javascript' src='http://localhost:9000/web-apps/apps/api/documents/api.js'></script>

//onlyoffice测试{path: "/onlyoffice",name: "onlyoffice",component: () => import("@/views/onlyoffice/test.vue"),},

test.vue 文件内容

<template><div id="app"><div class="qualityManual-container"><div><button style="width: 120px" type="primary" @click="getFile">测试预览office文档</button><button style="width: 120px" type="primary" @click="close">关闭</button></div><div v-if="show" class="qualityManual-container-office"><vab-only-office :option="option" /></div></div></div>
</template><script>
import vabOnlyOffice from "./VabOnlyOffice.vue";export default {name: "App",components: {vabOnlyOffice,},data() {return {//参考vabOnlyOffice组件参数配置option: {url:"http://192.168.0.104:8003/system/api/file/attachment/2024-07-13/1812066832136409088.docx",isEdit: "",fileType: "",title: "",lang: "",isPrint: "",user: { id: null, name: "" },},show: false,};},methods: {getFile() {this.show = true;// getAction('/file/selectById', { id: this.id }).then(res => {this.option.isEdit = false;this.option.lang = "zh-CN";this.option.url ="http://192.168.0.104:8003/system/api/file/attachment/2024-07-13/1812066832136409088.docx";this.option.title = "123";this.option.fileType = "docx";this.option.isPrint = false;this.option.user = { id: 12, name: "张三" };// })},close() {this.show = false;},},
};
</script><style>
html,
body {height: 100%;
}
#app {font-family: Avenir, Helvetica, Arial, sans-serif;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;text-align: center;color: #2c3e50;height: 100%;
}
.qualityManual-container {padding: 0 !important;height: 100%;
}
.qualityManual-container-office {/* mobile width: 0px;*//* desktop */width: 100%;height: calc(100% - 55px);
}
</style>

VabOnlyOffice.vue 文件内容

<!--onlyoffice 编辑器-->
<template><div id="vabOnlyOffice"></div>
</template><script>
export default {name: "VabOnlyOffice",props: {option: {type: Object,default: () => {return {};},},},data() {return {doctype: "",docEditor: null,};},beforeDestroy() {if (this.docEditor !== null) {this.docEditor.destroyEditor();this.docEditor = null;}},watch: {option: {handler: function (n) {this.setEditor(n);this.doctype = this.getFileType(n.fileType);},deep: true,},},mounted() {if (this.option.url) {this.setEditor(this.option);}},methods: {async setEditor(option) {if (this.docEditor !== null) {this.docEditor.destroyEditor();this.docEditor = null;}this.doctype = this.getFileType(option.fileType);let config = {document: {//后缀fileType: option.fileType,key: option.key || "",title: option.title,permissions: {edit: option.isEdit, //是否可以编辑: 只能查看,传falseprint: option.isPrint,download: false,// "fillForms": true,//是否可以填写表格,如果将mode参数设置为edit,则填写表单仅对文档编辑器可用。 默认值与edit或review参数的值一致。// "review": true //跟踪变化},url: option.url,},documentType: this.doctype,editorConfig: {callbackUrl: option.editUrl, //"编辑word后保存时回调的地址,这个api需要自己写了,将编辑后的文件通过这个api保存到自己想要的位置lang: option.lang, //语言设置//定制customization: {autosave: false, //是否自动保存chat: false,comments: false,help: false,// "hideRightMenu": false,//定义在第一次加载时是显示还是隐藏右侧菜单。 默认值为false//是否显示插件plugins: false,},user: {id: option.user.id,name: option.user.name,},mode: option.model ? option.model : "edit",},width: "100%",height: "100%",token: option.token || "",type: "desktop", //desktop  或 'mobile' 根据设备类型};// eslint-disable-next-line no-undef,no-unused-varsthis.docEditor = new DocsAPI.DocEditor("vabOnlyOffice", config);},getFileType(fileType) {let docType = "";let fileTypesDoc = ["doc","docm","docx","dot","dotm","dotx","epub","fodt","htm","html","mht","odt","ott","pdf","rtf","txt","djvu","xps",];let fileTypesCsv = ["csv","fods","ods","ots","xls","xlsm","xlsx","xlt","xltm","xltx",];let fileTypesPPt = ["fodp","odp","otp","pot","potm","potx","pps","ppsm","ppsx","ppt","pptm","pptx",];if (fileTypesDoc.includes(fileType)) {docType = "text";}if (fileTypesCsv.includes(fileType)) {docType = "spreadsheet";}if (fileTypesPPt.includes(fileType)) {docType = "presentation";}return docType;},},
};
</script>

打开页面

预览文档 时 如果出现 下载失败 按下面解决方法

编辑docker中/etc/onlyoffice/documentserver/default.json​下的内容

搜索并修改以下字段为true

可以使用docker容器内的nano default.json 命令编辑文件,然后重启容器

"request-filtering-agent" : {"allowPrivateIPAddress": true,"allowMetaIPAddress": true
},

参考文档 OnlyOffice 打开文档时提示下载失败_onlyoffice 下载失败-CSDN博客

desktop 效果

mobile效果

如果需要在线编辑和保存,可参考以下文章

SpringBoot中整合ONLYOFFICE在线编辑_springboot 集成 onlyoffice-CSDN博客

相关文章:

  • 北京网站建设多少钱?
  • 辽宁网页制作哪家好_网站建设
  • 高端品牌网站建设_汉中网站制作
  • CentOS 7 中出现 cannot open Packages database in /var/lib/rpm 错误
  • 最新PHP自助商城源码,彩虹商城源码
  • kettle从入门到精通 第七五课 ETL之kettle血缘,数据血缘
  • 【笔记】先求修改没保存的文本文件-在虚拟机中输入 yum makecache报错
  • 【Diffusion学习】【生成式AI】Diffusion Model 原理剖析 (2/4) (optional)【公式推导】
  • 微信小程序开发基础知识6----使用npm包
  • 探索Mojo编程语言:AI开发者的新宠儿
  • STM32学习和实践笔记(40):DS18B20温度传感器实验
  • 有关电力电子技术的一些相关仿真和分析:⑤交-直-交全桥逆变+全波整流结构电路(MATLAB/Siumlink仿真)
  • 1.3- Zygote
  • Prometheus 云原生 - 微服务监控报警系统 (Promethus、Grafana、Node_Exporter)部署、简单使用
  • goaccess分析json格式日志
  • CORDIC Translate
  • 【C/C++】内存相关
  • 最接近的三数之和
  • php的引用
  • [case10]使用RSQL实现端到端的动态查询
  • 2017届校招提前批面试回顾
  • Angular 2 DI - IoC DI - 1
  • CEF与代理
  • JS专题之继承
  • Linux编程学习笔记 | Linux多线程学习[2] - 线程的同步
  • Mithril.js 入门介绍
  • Phpstorm怎样批量删除空行?
  • Selenium实战教程系列(二)---元素定位
  • Web标准制定过程
  • 如何使用Mybatis第三方插件--PageHelper实现分页操作
  • 收藏好这篇,别再只说“数据劫持”了
  • 手机端车牌号码键盘的vue组件
  • 一些基于React、Vue、Node.js、MongoDB技术栈的实践项目
  • 源码安装memcached和php memcache扩展
  • [地铁译]使用SSD缓存应用数据——Moneta项目: 低成本优化的下一代EVCache ...
  • # windows 安装 mysql 显示 no packages found 解决方法
  • ## 临床数据 两两比较 加显著性boxplot加显著性
  • #stm32整理(一)flash读写
  • #数据结构 笔记三
  • (20050108)又读《平凡的世界》
  • (Bean工厂的后处理器入门)学习Spring的第七天
  • (web自动化测试+python)1
  • (超详细)语音信号处理之特征提取
  • (二)WCF的Binding模型
  • (二)斐波那契Fabonacci函数
  • (翻译)Quartz官方教程——第一课:Quartz入门
  • (附源码)spring boot火车票售卖系统 毕业设计 211004
  • (附源码)springboot 个人网页的网站 毕业设计031623
  • (附源码)springboot工单管理系统 毕业设计 964158
  • (附源码)ssm捐赠救助系统 毕业设计 060945
  • (三) diretfbrc详解
  • (未解决)jmeter报错之“请在微信客户端打开链接”
  • (转)Android学习系列(31)--App自动化之使用Ant编译项目多渠道打包
  • (转)负载均衡,回话保持,cookie
  • **python多态
  • .bat批处理(七):PC端从手机内复制文件到本地
  • .NET CF命令行调试器MDbg入门(三) 进程控制
  • .NET Core 中的路径问题