dootask/public/js/build/OnlyOffice.32c03e14.js
2025-03-16 23:43:51 +08:00

2 lines
5.3 KiB
JavaScript
Vendored

import{m as c}from"./vuex.cc7cb26e.js";import{n as f,l}from"./app.bc3ad3e2.js";import"./@micro-zoe.c2e1472d.js";import"./jquery.e403903e.js";import"./@babel.f9bcab46.js";import"./dayjs.b89f6725.js";import"./localforage.71b7b823.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.cb28ef06.js";import"./markdown-it-link-attributes.e1d5d151.js";import"./@traptitech.79d08561.js";import"./vue.fd9b772e.js";import"./openpgp_hi.15f91b1d.js";import"./axios.6ec123f8.js";import"./mitt.1ea0a2a3.js";import"./vue-router.2d566cd7.js";import"./vue-clipboard2.50be9c5e.js";import"./clipboard.058ef547.js";import"./view-design-hi.92ef2000.js";import"./vuedraggable.9fd6afed.js";import"./sortablejs.d74243d9.js";import"./vue-resize-observer.c3c9ca4e.js";import"./element-sea.7f208f9b.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";import"./lodash.18c5398d.js";var h=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("div",{staticClass:"component-only-office"},[e.loadError?i("Alert",{staticClass:"load-error",attrs:{type:"error","show-icon":""}},[e._v(e._s(e.$L("\u7EC4\u4EF6\u52A0\u8F7D\u5931\u8D25\uFF01")))]):e._e(),i("div",{staticClass:"placeholder",attrs:{id:e.id}}),e.loadIng>0?i("div",{staticClass:"office-loading"},[i("Loading")],1):e._e()],1)},m=[];const u={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 e=this.code||this.value.id,t;return $A.leftExists(e,"msgFile_")?t=`dialog/msg/download/?msg_id=${$A.leftDelete(e,"msgFile_")}&token=${this.userToken}`:$A.leftExists(e,"taskFile_")?t=`project/task/filedown/?file_id=${$A.leftDelete(e,"taskFile_")}&token=${this.userToken}`:(t=`file/content/?id=${e}&token=${this.userToken}`,this.historyId>0&&(t+=`&history_id=${this.historyId}`)),t}},watch:{"value.id":{handler(e){!e||(this.loadIng++,this.loadError=!1,$A.loadScript($A.mainUrl("office/web-apps/apps/api/documents/api.js")).then(t=>{if(!this.documentKey){this.handleClose();return}const i=this.documentKey();i&&i.then?i.then(this.loadFile).catch(({msg:n})=>{$A.modalError({content:n})}):this.loadFile()}).catch(t=>{this.loadError=!0}).finally(t=>{setTimeout(i=>{this.loadIng--},300)}))},immediate:!0}},methods:{getType(e){switch(e){case"word":return"docx";case"excel":return"xlsx";case"ppt":return"pptx"}return e},async getUserData(){if(!this.userInfo.userid&&this.userId&&this.userToken){this.$store.dispatch("showSpinner",300).then(e=>{});try{await this.$store.dispatch("getUserInfo")}catch(e){console.warn(e)}finally{this.$store.dispatch("hiddenSpinner").then(e=>{})}}return{id:String(this.userInfo.userid),name:this.userInfo.nickname}},loadFile(e=""){this.docEditor!==null&&(this.docEditor.destroyEditor(),this.docEditor=null);let t=l;switch(l){case"zh-CHT":t="zh-TW";break}let i=this.code||this.value.id,n=$A.strExists(this.fileName,".")?this.fileName:this.fileName+"."+(this.value.ext||this.fileType),a=`${this.fileType}-${e||i}`;this.historyId>0&&(a+=`-${this.historyId}`),(async y=>{const r={document:{fileType:this.fileType,title:n,key:a,url:`http://nginx/api/${this.fileUrl}`},editorConfig:{mode:"edit",lang:t,user:await this.getUserData(),customization:{uiTheme:this.themeName==="dark"?"theme-dark":"theme-classic-light",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 s=$("iframe[name='frameEditor']")[0];s==null||s.addEventListener("load",function(){s.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 p=f(u,h,m,!1,_,"7946f4cf",null,null);function _(e){for(let t in d)this[t]=d[t]}var ie=function(){return p.exports}();export{ie as default};