dootask/public/js/build/OnlyOffice.aa9825d9.js
2025-11-30 12:18:18 +08:00

2 lines
5.6 KiB
JavaScript
Vendored

import{m as c}from"./vuex.cc7cb26e.js";import{n as h,l}from"./app.1c2a0fa1.js";import"./jquery.ce39e51d.js";import"./@babel.f9bcab46.js";import"./dayjs.23d8b964.js";import"./localforage.f1b1079d.js";import"./markdown-it.bda97caf.js";import"./mdurl.ce6c1dd8.js";import"./uc.micro.8d343c98.js";import"./entities.48a44fec.js";import"./linkify-it.c5e8196e.js";import"./punycode.js.4b3f125a.js";import"./highlight.js.ab8aeea4.js";import"./markdown-it-link-attributes.e1d5d151.js";import"./@traptitech.897ae552.js";import"./vue.fd9b772e.js";import"./openpgp_hi.15f91b1d.js";import"./axios.79c8b3d5.js";import"./mitt.1ea0a2a3.js";import"./quill-hi.654cb53d.js";import"./parchment.d5c5924e.js";import"./quill-delta.f1b7ce48.js";import"./fast-diff.f17881f3.js";import"./lodash.clonedeep.e8ef3f14.js";import"./lodash.isequal.d6a986d0.js";import"./eventemitter3.78b735ad.js";import"./lodash-es.df04b444.js";import"./quill-mention-hi.41f02fd4.js";import"./view-design-hi.75f80746.js";import"./html-to-md.8a9a8796.js";import"./vue-router.2d566cd7.js";import"./vue-clipboard2.50be9c5e.js";import"./clipboard.058ef547.js";import"./vuedraggable.9fd6afed.js";import"./sortablejs.d74243d9.js";import"./vue-resize-observer.c3c9ca4e.js";import"./element-sea.1d49e96e.js";import"./deepmerge.cecf392e.js";import"./resize-observer-polyfill.0bdc1850.js";import"./throttle-debounce.7c3948b2.js";import"./babel-helper-vue-jsx-merge-props.5ed215c3.js";import"./normalize-wheel.2a034b9f.js";import"./async-validator.49abba38.js";import"./babel-runtime.4773988a.js";import"./core-js.314b4a1d.js";var f=function(){var t=this,e=t.$createElement,i=t._self._c||e;return i("div",{staticClass:"component-only-office"},[t.loadError?i("Alert",{staticClass:"load-error",attrs:{type:"error","show-icon":""}},[t._v(t._s(t.$L("\u7EC4\u4EF6\u52A0\u8F7D\u5931\u8D25\uFF01")))]):t._e(),i("div",{staticClass:"placeholder",attrs:{id:t.id}}),t.loadIng>0?i("div",{staticClass:"office-loading"},[i("Loading")],1):t._e()],1)},m=[];const p={name:"OnlyOffice",props:{id:{type:String,default:()=>"office_"+Math.round(Math.random()*1e4)},code:{type:String,default:""},historyId:{type:Number,default:0},value:{type:[Object,Array],default:function(){return{}}},readOnly:{type:Boolean,default:!1},documentKey:Function},data(){return{loadIng:0,loadError:!1,docEditor:null}},beforeDestroy(){this.docEditor!==null&&(this.docEditor.destroyEditor(),this.docEditor=null)},computed:{...c(["userInfo","themeName"]),fileType(){return this.getType(this.value.type)},fileName(){return this.value.name},fileUrl(){let t=this.code||this.value.id,e;return $A.leftExists(t,"msgFile_")?e=`dialog/msg/download/?msg_id=${$A.leftDelete(t,"msgFile_")}&token=${this.userToken}`:$A.leftExists(t,"taskFile_")?e=`project/task/filedown/?file_id=${$A.leftDelete(t,"taskFile_")}&token=${this.userToken}`:(e=`file/content/?id=${t}&token=${this.userToken}`,this.historyId>0&&(e+=`&history_id=${this.historyId}`)),e}},watch:{"value.id":{handler(t){!t||(this.loadIng++,this.loadError=!1,$A.loadScript($A.mainUrl("office/web-apps/apps/api/documents/api.js")).then(e=>{if(!this.documentKey){this.handleClose();return}const i=this.documentKey();i&&i.then?i.then(this.loadFile).catch(({msg:s})=>{$A.modalError({content:s})}):this.loadFile()}).catch(e=>{this.loadError=!0}).finally(e=>{setTimeout(i=>{this.loadIng--},300)}))},immediate:!0}},methods:{getType(t){switch(t){case"word":return"docx";case"excel":return"xlsx";case"ppt":return"pptx"}return t},async getUserData(){if(!this.userInfo.userid&&this.userId&&this.userToken){this.$store.dispatch("showSpinner",300).then(t=>{});try{await this.$store.dispatch("getUserInfo")}catch(t){console.warn(t)}finally{this.$store.dispatch("hiddenSpinner").then(t=>{})}}return{id:String(this.userInfo.userid),name:this.userInfo.nickname}},loadFile(t=""){this.docEditor!==null&&(this.docEditor.destroyEditor(),this.docEditor=null);let e=l;switch(l){case"zh-CHT":e="zh-TW";break}let i=this.code||this.value.id,s=$A.strExists(this.fileName,".")?this.fileName:this.fileName+"."+(this.value.ext||this.fileType),a=`${this.fileType}-${t||i}`;this.historyId>0&&(a+=`-${this.historyId}`),(async y=>{const r={document:{fileType:this.fileType,title:s,key:a,url:`http://nginx/api/${this.fileUrl}`},editorConfig:{mode:"edit",lang:e,user:await this.getUserData(),customization:{uiTheme:this.themeName==="dark"?"theme-night":"theme-white",forcesave:!0,help:!1},callbackUrl:`http://nginx/api/file/content/office?id=${i}&dootask-token=${this.userToken}`},events:{onDocumentReady:this.onDocumentReady}};if(/\/hideenOfficeTitle\//.test(window.navigator.userAgent)&&(r.document.title=" "),(this.readOnly||this.historyId>0)&&(r.editorConfig.mode="view",r.editorConfig.callbackUrl=null,!r.editorConfig.user.id)){let o=await $A.IDBInt("officeViewer");o||(o=$A.randNum(1e3,99999),await $A.IDBSet("officeViewer",o)),r.editorConfig.user.id="viewer_"+o,r.editorConfig.user.name="Viewer_"+o}this.$nextTick(()=>{this.$store.dispatch("call",{url:"file/office/token",data:{config:r}}).then(({data:o})=>{if(r.token=o.token,this.docEditor=new DocsAPI.DocEditor(this.id,r),this.readOnly){var n=$("iframe[name='frameEditor']")[0];n==null||n.addEventListener("load",function(){n.contentWindow.postMessage("disableDownload","*")})}}).catch(({msg:o})=>{if(o.indexOf("404 not found")!==-1){$A.modalInfo({title:"\u7248\u672C\u8FC7\u4F4E",content:"\u670D\u52A1\u5668\u7248\u672C\u8FC7\u4F4E\uFF0C\u8BF7\u5347\u7EA7\u670D\u52A1\u5668\u3002"});return}$A.modalError({content:o})})})})()},onDocumentReady(){this.$emit("on-document-ready",this.docEditor)}}},d={};var u=h(p,f,m,!1,_,"6f9d12ef",null,null);function _(t){for(let e in d)this[e]=d[e]}var ct=function(){return u.exports}();export{ct as default};