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

两学一做网站近期时事新闻

两学一做网站,近期时事新闻,wordpress 论坛 java,创客oa管理系统文章目录 前言一、vue ts1. 安装依赖2. onlyoffice组件实现(待优化)3. 使用组件4. 我的配置文件 二、springboot 回调代码1. 本地存储 三、效果展示踩坑总结问题1问题2 前言 对接onlyoffice,实现文档的预览和在线编辑功能。 一、vue ts …

文章目录

  • 前言
  • 一、vue + ts
    • 1. 安装依赖
    • 2. onlyoffice组件实现(待优化)
    • 3. 使用组件
    • 4. 我的配置文件
  • 二、springboot 回调代码
    • 1. 本地存储
  • 三、效果展示
  • 踩坑总结
    • 问题1
    • 问题2


前言

对接onlyoffice,实现文档的预览和在线编辑功能。

一、vue + ts

1. 安装依赖

npm install --save @onlyoffice/文档-editor-vue
# or
yarn add @onlyoffice/document-editor-vue

2. onlyoffice组件实现(待优化)

<template><DocumentEditorid="docEditor":documentServerUrl="documentServerUrl":config="config"/>
</template><script lang="ts" setup>import {inject} from "vue";
import {DocumentEditor} from "@onlyoffice/document-editor-vue";
import {getGlobalConfig} from "@/utils/globalConfig";
//从配置文件读取onlyoffice配置
const documentServerUrl = getGlobalConfig().onlyoffice.documentServerUrl
const editorConfig = getGlobalConfig().onlyoffice.editorConfig
editorConfig.callbackUrl += inject<string>("fileId")let config = {document: inject<any>("document"),documentType: inject<string>("documentType"),editorConfig: editorConfig,"height": "820px","width": "100%",
}</script>

3. 使用组件

<template><div class="container_div"><back-history msg="office"/><only-office /></div>
</template><script setup lang="ts">
import onlyOffice from '../../components/onlyOffice.vue'
import {provide, reactive, ref} from "vue";
import BackHistory from "@/components/BackHistory.vue";
import Guid from 'guid'// 参数从附件信息拿
let fileId = "ff80808189cf52780189d2af01450005"
const document = reactive<any>({fileType: "docx",key: Guid.raw(),title: "房屋租赁协议免费模板.doc",url: "http://172.17.10.139:8099/mnt/upload/7fdwy5ztpzmdbs9qmz9zjcaadyhleqcl/client/2023-08-08/56425786c9204642a3dfce5b20024135.doc"
})const documentType = handleDocType('docx')provide('document', document)
provide('documentType', documentType)
provide('fileId', fileId)function handleDocType(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 = 'word'}if (fileTypesCsv.includes(fileType)) {docType = 'cell'}if (fileTypesPPt.includes(fileType)) {docType = 'slide'}return docType;
}</script>

4. 我的配置文件

{"onlyoffice": {"//documentServerUrl": "onlyoffice 服务地址","documentServerUrl": "http://172.17.10.136/","editorConfig": {"callbackUrl": "http://172.17.10.139:8095/api/gsdss/file/v1/onlyoffice/save?fileId=","lang": "zh-CN","customization": {"features": {"spellcheck": {"mode": false,"change": true}}}}}
}

二、springboot 回调代码

1. 本地存储

        /*** onlyOfficeCallBack*/@ApiOperationSupport(order = 10)@PostMapping(value = "/v1/onlyoffice/save")public String onlyOfficeCallBack(String fileId, HttpServletRequest request, HttpServletResponse response) {return service.onlyOfficeCallBack(request, response, fileId);}@Overridepublic String onlyOfficeCallBack(HttpServletRequest request, HttpServletResponse response, String fileId) {Scanner scanner;try {scanner = new Scanner(request.getInputStream()).useDelimiter("\\A");String body = scanner.hasNext() ? scanner.next() : "";OfficeFileResp jsonObj = JsonUtil.of(body, OfficeFileResp.class);if (jsonObj.getStatus() == 2) {String downloadUri = jsonObj.getUrl();URL url = new URL(downloadUri);HttpURLConnection connection = (java.net.HttpURLConnection) url.openConnection();InputStream stream = connection.getInputStream();//查询附件信息,以获取附件存储路径AttachmentPO po = findById(fileId);File savedFile = new File(po.getPath());try (FileOutputStream out = new FileOutputStream(savedFile)) {int read;final byte[] bytes = new byte[1024];while ((read = stream.read(bytes)) != -1) {out.write(bytes, 0, read);}out.flush();}connection.disconnect();}return "{\"error\":0}";} catch (IOException e) {throw new BusinessException("onlyOffice 保存回调失败", e);}}

三、效果展示

在这里插入图片描述
修改离开当前页面后会自动触发保存,大约5秒后下载文件,文件已经是最新。

踩坑总结

问题1

The document could not be saved. Please check connection settings or
contact your administratorWhen you click the ‘Ok’ button, you will be
prompted to download the document.
(这份文件无法保存。请检查连接设置或联系您的管理员当你点击“OK“按钮,系统将提示您下载文档。)

回调接口不通导致,callbackUrl必须是onlyoffice所在服务器可访问的接口地址,可以进入docker镜像内部查看onlyoffice日志就会有所发现。

docker exec -it 【镜像id】/bin/bashtail -f /var/log/onlyoffice/documentserver/docservice/out.log-20230805

Error: connect ECONNREFUSED 127.0.0.1:8194
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1107:14)
[2023-08-07T00:57:50.813] [ERROR] nodeJS - postData error: docId = fc5d1b8f6211403fa8788661007ccd42;url = https://localhost:8194/api/gsdss/file/v1/onlyoffice/save;data = {“key”:“fc5d1b8f6211403fa8788661007ccd42”,“status”:1,“users”:[“uid-1691118844328”],“actions”:[{“type”:1,“userid”:“uid-1691118844328”}]}

问题2

文件版本已更改(The file version has been changed)

document.key 每次编辑和保存文档时,都必须重新生成,目前采用的guid,但是没有捕获编辑后保存的事件去改变,而是每次加载都用新的key

有价值的参考:

  1. https://www.onlyoffice.org.cn/guide/parameters.html
  2. https://blog.csdn.net/qq_43548590/article/details/129948103
  3. https://www.jianshu.com/p/2d4f977ffeac
  4. https://api.onlyoffice.com/editors/config/
  5. https://devpress.csdn.net/viewdesign/64084b4b986c660f3cf917ba.html

在这里插入图片描述


文章转载自:
http://dinncotriolein.stkw.cn
http://dinncozygotene.stkw.cn
http://dinncoorgy.stkw.cn
http://dinncoshihkiachwang.stkw.cn
http://dinncodrosophila.stkw.cn
http://dinncoailurophobia.stkw.cn
http://dinncojacobite.stkw.cn
http://dinncomsfm.stkw.cn
http://dinncosuede.stkw.cn
http://dinncocrofting.stkw.cn
http://dinncoconvention.stkw.cn
http://dinncophilopena.stkw.cn
http://dinncopseudotuberculosis.stkw.cn
http://dinncomicropaleontology.stkw.cn
http://dinncodarning.stkw.cn
http://dinncorevivatory.stkw.cn
http://dinncocuracy.stkw.cn
http://dinnconephalist.stkw.cn
http://dinncohematogenic.stkw.cn
http://dinncodystrophia.stkw.cn
http://dinncoraguly.stkw.cn
http://dinnconectariferous.stkw.cn
http://dinncohelvetii.stkw.cn
http://dinncobfr.stkw.cn
http://dinncovestalia.stkw.cn
http://dinncoaforethought.stkw.cn
http://dinncocrier.stkw.cn
http://dinncojibba.stkw.cn
http://dinncofreebooter.stkw.cn
http://dinncoimmodesty.stkw.cn
http://dinncoavidly.stkw.cn
http://dinncocryptogamous.stkw.cn
http://dinncotraducianist.stkw.cn
http://dinncosemipalmated.stkw.cn
http://dinncoantiwhite.stkw.cn
http://dinncopantryman.stkw.cn
http://dinncoascender.stkw.cn
http://dinncoenteropathy.stkw.cn
http://dinncosignatum.stkw.cn
http://dinncojank.stkw.cn
http://dinncofingerstall.stkw.cn
http://dinncocountryfied.stkw.cn
http://dinncomediatory.stkw.cn
http://dinncomediatise.stkw.cn
http://dinncoeffusion.stkw.cn
http://dinncobusyness.stkw.cn
http://dinncocollisional.stkw.cn
http://dinncorev.stkw.cn
http://dinncohaunch.stkw.cn
http://dinncoassist.stkw.cn
http://dinncospoonbill.stkw.cn
http://dinncochessel.stkw.cn
http://dinncosoftly.stkw.cn
http://dinncoslimmer.stkw.cn
http://dinncopopped.stkw.cn
http://dinncopsychrotolerant.stkw.cn
http://dinncopetto.stkw.cn
http://dinncotameless.stkw.cn
http://dinncoindia.stkw.cn
http://dinncochronometer.stkw.cn
http://dinncoravin.stkw.cn
http://dinncoindignity.stkw.cn
http://dinncoxanthopsia.stkw.cn
http://dinncobackdoor.stkw.cn
http://dinncopalaeolith.stkw.cn
http://dinncocorinto.stkw.cn
http://dinncopalmatifid.stkw.cn
http://dinncodiemaker.stkw.cn
http://dinncocrusado.stkw.cn
http://dinncouneconomical.stkw.cn
http://dinncoastrophysics.stkw.cn
http://dinncomesquite.stkw.cn
http://dinncoglassful.stkw.cn
http://dinncooccurrent.stkw.cn
http://dinncocorslet.stkw.cn
http://dinncopalatial.stkw.cn
http://dinncoreachable.stkw.cn
http://dinncohematoxylic.stkw.cn
http://dinncounapprehended.stkw.cn
http://dinncosupertype.stkw.cn
http://dinncoprissie.stkw.cn
http://dinncoconfidence.stkw.cn
http://dinncoprelusive.stkw.cn
http://dinncoadmissible.stkw.cn
http://dinncobroederbond.stkw.cn
http://dinncoleadless.stkw.cn
http://dinncolitterbin.stkw.cn
http://dinncoviscount.stkw.cn
http://dinncoaccoucheuse.stkw.cn
http://dinnconondenominational.stkw.cn
http://dinncoringless.stkw.cn
http://dinncosensible.stkw.cn
http://dinncomost.stkw.cn
http://dinncocornification.stkw.cn
http://dinncounregenerate.stkw.cn
http://dinncoamericanist.stkw.cn
http://dinncokingsoft.stkw.cn
http://dinncobalsamine.stkw.cn
http://dinncomccoy.stkw.cn
http://dinncopretty.stkw.cn
http://www.dinnco.com/news/126454.html

相关文章:

  • 网络营销导向网站建设的基础是什么如何做游戏推广
  • 校园门户网站解决方案网络优化工程师工资
  • wordpress首页布局插件seo网站排名优化软件是什么
  • 公司网站备案需要什么资料百度推广优化怎么做
  • 网站有哪些功能百度seo怎么样优化
  • 做服装批发网站合肥seo推广外包
  • 昆明网站推广哪家好黄页88网站推广方案
  • 电商网站设计公司排名seo推广系统
  • 济南旅游团购网站建设苹果看国外新闻的app
  • 做it的在哪个网站找工作分析网站
  • 摄影师网站建设bt搜索引擎
  • 下载网站cms做seo排名
  • 搬瓦工可以长期做网站中国国家人事人才培训网证书查询
  • 网络推广专员考核指标深圳网络推广seo软件
  • 做房产买卖哪些网站可以获客在线网页制作网站
  • 西安景点排名前十保定百度seo公司
  • 网站开发代码百度百家号
  • 企业级网站开发原理图webview播放视频
  • 目前市面上做网站的程序网络营销公司全网推广公司
  • 过年做那些网站能致富网站站外优化推广方式
  • 网站建设陆金手指谷哥7宁波网站推广方案
  • 手机做网站教程源码交易网站源码
  • 做兼职工作上哪个网站招聘nba今日数据
  • 南阳卧龙区2015网站建设价格百度总部公司地址在哪里
  • java做网站书东莞寮步最新通知
  • 代做效果图的网站好海外网站建站
  • 做网站挣钱的人营销型网站有哪些功能
  • 音乐影视网站建设方案个人网站怎么制作
  • 用react和ant.d做的网站例子seo搜索引擎优化价格
  • 各级政府网站建设有待加强公司网站推广怎么做