首页 前端知识 解决onlyoffice警告的一些思路

解决onlyoffice警告的一些思路

2024-09-08 02:09:31 前端知识 前端哥 102 366 我要收藏

解决思路:

1、监听出现警告的事件:已经实现

<script setup>
import {message} from "ant-design-vue";

const onError = (event) => {
  console.log("ONLYOFFICE Document Editor reports an error: code " + event.data.errorCode + ", description " + event.data.errorDescription);
};
const onWarning = (event) => {
  console.log("ONLYOFFICE Document Editor reports a warning: code " + event.data.warningCode + ", description " + event.data.warningDescription);
  console.log("event=", event)
  return true
}
const onLoadDocumentClick = () => {
  message.success("load document")
  // isDocument.value = true
  new DocsAPI.DocEditor("doc", {
    "events": {
      "onError": onError,
      "onWarning": onWarning,
    },
    "document": {
      "fileType": "docx",
      "key": `Khirz6zTPdfd7`,
      "title": "Example Document Title.docx",
      "url": "http://192.168.234.138:18888/dist/test.docx"
    },
    "editorConfig": {
      "callbackUrl": "http://192.168.234.138:18888/callback",
      "lang": "zh-CN",
      "user": {
        "id": "1",
        "name": "zdp"
      },
      "customization": {
        "forcesave": true,
      },
      "coEditing": {
        "mode": "fast",
        "change": true
      },
    },
    "documentType": "word",
    height: '500px',
    width: '100%',
    token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkb2N1bWVudCI6eyJmaWxlVHlwZSI6ImRvY3giLCJrZXkiOiJLaGlyejZ6VFBkZmQ3IiwidGl0bGUiOiJFeGFtcGxlIERvY3VtZW50IFRpdGxlLmRvY3giLCJ1cmwiOiJodHRwOi8vMTkyLjE2OC4yMzQuMTM4OjE4ODg4L2Rpc3QvdGVzdC5kb2N4In0sImVkaXRvckNvbmZpZyI6eyJjYWxsYmFja1VybCI6Imh0dHA6Ly8xOTIuMTY4LjIzNC4xMzg6MTg4ODgvY2FsbGJhY2siLCJsYW5nIjoiemgtQ04iLCJ1c2VyIjp7ImlkIjoiMSIsIm5hbWUiOiJ6ZHAifSwiY3VzdG9taXphdGlvbiI6eyJmb3JjZXNhdmUiOnRydWV9LCJjb0VkaXRpbmciOnsibW9kZSI6ImZhc3QiLCJjaGFuZ2UiOnRydWV9fSwiZG9jdW1lbnRUeXBlIjoid29yZCIsImhlaWdodCI6IjUwMHB4Iiwid2lkdGgiOiIxMDAlIn0.vnSYKU22-IsBmuoSn5Po-Ukz1RrnM-G3ch3-JuJd1xg",
  });
}
</script>
<template>
  <div class="bg-indigo-50 p-8 min-h-screen">
    <div class="bg-amber-200 p-8">
      <a-button type="primary" @click="onLoadDocumentClick">Load Document</a-button>
    </div>
    <div class="bg-amber-400 p-8 min-h-96">
      <div id="doc">doc</div>
    </div>
  </div>
</template>

2、检查如何在警告的回调函数中,返回某个值,或者阻止事件的继续传播,以解决出现警告弹窗的问题。目前主要解决方案是查阅官方源码:
https://github.com/ONLYOFFICE/sdkjs/blob/master/common/errorCodes.js

转载请注明出处或者链接地址:https://www.qianduange.cn//article/17856.html
标签
评论
发布的文章

数据持久化(Json)

2024-09-28 23:09:01

JSON Gate 开源项目教程

2024-09-28 23:09:00

【C 】Ubuntu安装jsoncpp

2024-09-28 23:09:58

http请求json

2024-09-28 23:09:58

JSON 格式详解

2024-09-28 23:09:53

大家推荐的文章
会员中心 联系我 留言建议 回顶部
复制成功!