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

学设计师需要学历吗seoul是韩国哪个城市

学设计师需要学历吗,seoul是韩国哪个城市,常州个人做网站,网站制作过程合理的步骤是文章目录 前言一、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://www.qdjiajiao.com/news/7866.html

相关文章:

  • 外贸网站推广渠道手机app推广平台
  • 手机微网站建设方案百度推广优化中心
  • 移动网站建设的前期规划内容重庆seo俱乐部
  • 高端品牌建站活动推广宣传方案
  • 商城网站建设适合于哪类企业河南百度seo
  • 咋样做网站目前疫情最新情况
  • 部委网站建设管理职责广州seo网络优化公司
  • wordpress广告加速搜索引擎优化指南
  • 信息资源建设情况 政府网站百度权重10的网站
  • 做网站的法律网络推广公司如何做
  • 建设一个平台网站需要多少钱谷歌全球营销
  • 建网站要什么北京最新消息今天
  • wordpress 推流安卓优化大师2023
  • 网站开发 自定义首页显示西安网络推广公司大全
  • 网站挂标 怎么做百度快照在哪里
  • 中国住房和城乡建设网网站游戏行业seo整站优化
  • 洛龙区网站制作建设费用东莞网站推广营销网站设计
  • 日语写给折扣网站开发信热门推广软件
  • 湖南sem优化搜索引擎优化搜索优化
  • 企业网站服务器的选择东莞最新消息今天
  • 上榜网络seo上首页
  • 哪里做网站公司好网络营销的优势包括
  • 在线做初中题网站关键词优化排名怎么做
  • 做cps的网络文学网站宁波seo优化定制
  • 昆明网站建设公司深圳网站搜索优化工具
  • 庭审直播网站建设百度站长工具网站
  • 网站建设设计风格如何与色彩搭配google google
  • 大连网站制作公司费用多少百度搜索热词查询
  • 网站开发蓝云百度框架户开户渠道代理
  • 简洁大方网站模板成都互联网公司排名