2022-02-13 14:10:06 +08:00

1 line
14 KiB
JavaScript
Vendored

"use strict";(self.webpackChunkDooTask=self.webpackChunkDooTask||[]).push([[157,911,942],{85916:(e,t,i)=>{i.d(t,{Z:()=>r});var n=i(1519),o=i.n(n)()((function(e){return e[1]}));o.push([e.id,".component-only-office[data-v-1ec144f0]{align-items:center;bottom:0;display:flex;justify-content:center;left:0;position:absolute;right:0;top:0}.component-only-office .placeholder[data-v-1ec144f0]{flex:1;height:100%;width:100%}.component-only-office .office-loading[data-v-1ec144f0]{align-items:center;bottom:0;display:flex;justify-content:center;left:0;position:absolute;right:0;top:0;z-index:2}",""]);const r=o},42586:(e,t,i)=>{i.d(t,{Z:()=>r});var n=i(1519),o=i.n(n)()((function(e){return e[1]}));o.push([e.id,".single-file-task[data-v-3847fd5e]{align-items:center;display:flex}.single-file-task .ace_editor[data-v-3847fd5e],.single-file-task .no-support[data-v-3847fd5e],.single-file-task .preview-iframe[data-v-3847fd5e]{border:0;height:100%;left:0;margin:0;outline:0;padding:0;position:absolute;top:0;width:100%}.single-file-task .preview-iframe[data-v-3847fd5e]{background:0 0;float:none;max-width:none}.single-file-task .no-support[data-v-3847fd5e],.single-file-task .view-editor[data-v-3847fd5e]{align-items:center;display:flex;justify-content:center}",""]);const r=o},3911:(e,t,i)=>{i.r(t),i.d(t,{default:()=>f});var n=i(20629);function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function r(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function s(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?r(Object(i),!0).forEach((function(t){a(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):r(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function a(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function l(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==i)return;var n,o,r=[],s=!0,a=!1;try{for(i=i.call(e);!(s=(n=i.next()).done)&&(r.push(n.value),!t||r.length!==t);s=!0);}catch(e){a=!0,o=e}finally{try{s||null==i.return||i.return()}finally{if(a)throw o}}return r}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return c(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return c(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}const d={name:"AceEditor",props:{value:{default:""},options:{type:Object,default:function(){return{}}},theme:{type:String,default:"auto"},ext:{type:String,default:"txt"},height:{type:Number||null,default:null},width:{type:Number||null,default:null},wrap:{type:Boolean,default:!1},readOnly:{type:Boolean,default:!1}},render:function(e){return e("div",{class:"no-dark-mode"})},data:function(){return{code:"",editor:null,cursorPosition:{row:0,column:0},supportedModes:{Apache_Conf:["^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"],BatchFile:["bat|cmd"],C_Cpp:["cpp|c|cc|cxx|h|hh|hpp|ino"],CSharp:["cs"],CSS:["css"],Dockerfile:["^Dockerfile"],golang:["go"],HTML:["html|htm|xhtml|vue|we|wpy"],Java:["java"],JavaScript:["js|jsm|jsx"],JSON:["json"],JSP:["jsp"],LESS:["less"],Lua:["lua"],Makefile:["^Makefile|^GNUmakefile|^makefile|^OCamlMakefile|make"],Markdown:["md|markdown"],MySQL:["mysql"],Nginx:["nginx|conf"],INI:["ini|conf|cfg|prefs"],ObjectiveC:["m|mm"],Perl:["pl|pm"],Perl6:["p6|pl6|pm6"],pgSQL:["pgsql"],PHP_Laravel_blade:["blade.php"],PHP:["php|inc|phtml|shtml|php3|php4|php5|phps|phpt|aw|ctp|module"],Powershell:["ps1"],Python:["py"],R:["r"],Ruby:["rb|ru|gemspec|rake|^Guardfile|^Rakefile|^Gemfile"],Rust:["rs"],SASS:["sass"],SCSS:["scss"],SH:["sh|bash|^.bashrc"],SQL:["sql"],SQLServer:["sqlserver"],Swift:["swift"],Text:["txt"],Typescript:["ts|typescript|str"],VBScript:["vbs|vb"],Verilog:["v|vh|sv|svh"],XML:["xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl|xaml"],YAML:["yaml|yml"],Compress:["tar|zip|7z|rar|gz|arj|z"],images:["icon|jpg|jpeg|png|bmp|gif|tif|emf"]}}},mounted:function(){var e=this;$A.loadScriptS(["js/ace/ace.js","js/ace/mode-json.js"],(function(){e.setSize(e.$el,{height:e.height,width:e.width}),e.editor=window.ace.edit(e.$el,{wrap:e.wrap,showPrintMargin:!1,readOnly:e.readOnly,keyboardHandler:"vscode"}),e.editor.session.setMode("ace/mode/".concat(e.getFileMode())),e.$emit("mounted",e.editor),e.editor.session.$worker&&e.editor.session.$worker.addEventListener("annotate",e.workerMessage,!1),e.editor.setValue(e.value),e.editor.clearSelection(),e.editor.setOptions(e.options),e.editTheme&&e.editor.setTheme("ace/theme/".concat(e.editTheme)),e.editor.commands.addCommand({name:"保存文件",bindKey:{win:"Ctrl-S",mac:"Command-S"},exec:function(){e.$emit("saveData")},readOnly:!1}),e.editor.getSession().on("change",(function(){e.code=e.editor.getValue(),e.$emit("input",e.code)}))}))},methods:{workerMessage:function(e){var t=e.data;this.cursorPosition=this.editor.selection.getCursor();var i=l(t,1)[0];i&&"error"===i.type?this.$emit("validationFailed",i):this.$emit("change",this.editor.getValue())},setSize:function(e,t){var i=this,n=t.width,o=void 0===n?this.width:n,r=t.height,s=void 0===r?this.height:r;e.style.width=o&&"number"==typeof o?"".concat(o,"px"):"100%",e.style.height=s&&"number"==typeof s?"".concat(s,"px"):"100%",this.$nextTick((function(){return i.editor&&i.editor.resize()}))},getFileMode:function(){var e=this.ext||"text";for(var t in this.supportedModes)for(var i=this.supportedModes[t][0].split("|"),n=t.toLowerCase(),o=0;o<i.length;o++)if(e==i[o])return n;return"text"}},computed:s(s({},(0,n.rn)(["themeIsDark"])),{},{editTheme:function(){return"auto"==this.theme?this.themeIsDark?"dracula-dark":"chrome":this.theme}}),watch:{options:function(e){e&&"object"===o(e)&&this.editor&&this.editor.setOptions(e)},editTheme:function(e){e&&"string"==typeof e&&this.editor&&this.editor.setTheme("ace/theme/".concat(e))},ext:function(e){e&&"string"==typeof e&&this.editor&&this.editor.session.setMode("ace/mode/".concat(this.getFileMode()))},width:function(e){this.setSize(this.el,{width:e})},height:function(e){this.setSize(this.el,{height:e})},readOnly:function(e){"boolean"==typeof e&&this.editor&&this.editor.setReadOnly(e)},value:function(e){if(this.editor&&e!=this.code){this.editor.setValue(e),this.editor.clearSelection();var t=this.cursorPosition,i=t.row,n=t.column;this.editor.selection.moveCursorTo(i,n)}}},beforeDestroy:function(){this.editor&&(this.editor.session.$worker&&this.editor.session.$worker.removeEventListener("message",this.workerMessage,!1),this.editor.destroy(),this.editor.container.remove())}};const f=(0,i(51900).Z)(d,undefined,undefined,!1,null,null,null).exports},17942:(e,t,i)=>{i.r(t),i.d(t,{default:()=>u});var n=i(20629);function o(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function r(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?o(Object(i),!0).forEach((function(t){s(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):o(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function s(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}const a={name:"OnlyOffice",props:{id:{type:String,default:function(){return"office_"+Math.round(1e4*Math.random())}},code:{type:String,default:""},value:{type:[Object,Array],default:function(){return{}}},readOnly:{type:Boolean,default:!1},documentKey:Function},data:function(){return{loadIng:0,docEditor:null}},mounted:function(){},beforeDestroy:function(){null!==this.docEditor&&(this.docEditor.destroyEditor(),this.docEditor=null)},computed:r(r({},(0,n.rn)(["userToken","userInfo","themeIsDark"])),{},{fileType:function(){return this.getType(this.value.type)},fileName:function(){return this.value.name}}),watch:{"value.id":{handler:function(e){var t=this;e&&(this.loadIng++,$A.loadScript($A.apiUrl("../office/web-apps/apps/api/documents/api.js"),(function(e){if(t.loadIng--,null===e)if(t.documentKey){var i=t.documentKey();i&&i.then?i.then(t.loadFile):t.loadFile()}else t.handleClose();else $A.modalAlert("组件加载失败!")})))},immediate:!0}},methods:{getType:function(e){switch(e){case"word":return"docx";case"excel":return"xlsx";case"ppt":return"pptx"}return e},loadFile:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";null!==this.docEditor&&(this.docEditor.destroyEditor(),this.docEditor=null);var i="zh";switch(this.getLanguage()){case"CN":case"TC":i="zh";break;default:i="en"}var n=this.code||this.value.id,o=$A.strExists(this.fileName,".")?this.fileName:this.fileName+"."+this.fileType,r={document:{fileType:this.fileType,key:"".concat(this.fileType,"-").concat(n,"-").concat(t),title:o,url:"http://nginx/api/file/content/?id=".concat(n,"&token=").concat(this.userToken)},editorConfig:{mode:"edit",lang:i,user:{id:this.userInfo.userid,name:this.userInfo.nickname},customization:{uiTheme:this.themeIsDark?"theme-dark":"theme-classic-light"},callbackUrl:"http://nginx/api/file/content/office?id=".concat(n,"&token=").concat(this.userToken)}};if(/\/hideenOfficeTitle\//.test(window.navigator.userAgent)&&(r.document.title=" "),$A.leftExists(n,"msgFile_")?r.document.url="http://nginx/api/dialog/msg/download/?msg_id=".concat($A.leftDelete(n,"msgFile_"),"&token=").concat(this.userToken):$A.leftExists(n,"taskFile_")&&(r.document.url="http://nginx/api/project/task/filedown/?file_id=".concat($A.leftDelete(n,"taskFile_"),"&token=").concat(this.userToken)),this.readOnly&&(r.editorConfig.mode="view",r.editorConfig.callbackUrl=null,!r.editorConfig.user.id)){var s=$A.getStorageInt("viewer");s||(s=$A.randNum(1e3,99999),$A.setStorage("viewer",s)),r.editorConfig.user.id="viewer_"+s,r.editorConfig.user.name="Viewer_"+s}this.$nextTick((function(){e.docEditor=new DocsAPI.DocEditor(e.id,r)}))}}};var l=i(93379),c=i.n(l),d=i(85916),f={insert:"head",singleton:!1};c()(d.Z,f);d.Z.locals;const u=(0,i(51900).Z)(a,(function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("div",{staticClass:"component-only-office"},[i("div",{staticClass:"placeholder",attrs:{id:this.id}}),e._v(" "),e.loadIng>0?i("div",{staticClass:"office-loading"},[i("Loading")],1):e._e()])}),[],!1,null,"1ec144f0",null).exports},98157:(e,t,i)=>{i.r(t),i.d(t,{default:()=>c});var n=i(3911);const o={components:{OnlyOffice:i(17942).default,AceEditor:n.default},data:function(){return{loadIng:0,fileDetail:{}}},mounted:function(){},watch:{$route:{handler:function(){this.getInfo()},immediate:!0}},computed:{fileId:function(){return $A.runNum(this.$route.params.id)},title:function(){var e=this.fileDetail.name;return e||"Loading..."},isCode:function(){return 1==this.fileDetail.file_mode},codeContent:function(){return this.isCode?this.fileDetail.content:""},codeExt:function(){return this.isCode?this.fileDetail.ext:"txt"},isOffice:function(){return 2==this.fileDetail.file_mode},officeContent:function(){return{id:this.isOffice?this.fileDetail.id:0,type:this.fileDetail.ext,name:this.title}},officeCode:function(){return this.isOffice?"taskFile_"+this.fileDetail.id:""},isPreview:function(){return 3==this.fileDetail.file_mode},previewUrl:function(){return this.isPreview?$A.apiUrl("../fileview/onlinePreview?url="+encodeURIComponent(this.fileDetail.url)):""}},methods:{getInfo:function(){var e=this;this.fileId<=0||(this.loadIng++,this.$store.dispatch("call",{url:"project/task/filedetail",data:{file_id:this.fileId}}).then((function(t){var i=t.data;e.loadIng--,e.fileDetail=i})).catch((function(t){var i=t.msg;e.loadIng--,$A.modalError({content:i,onOk:function(){e.$Electron&&window.close()}})})))},documentKey:function(){var e=this;return new Promise((function(t){e.$store.dispatch("call",{url:"project/task/filedetail",data:{file_id:e.fileId,only_update_at:"yes"}}).then((function(e){var i=e.data;t($A.Date(i.update_at,!0))})).catch((function(){t(0)}))}))}}};var r=i(93379),s=i.n(r),a=i(42586),l={insert:"head",singleton:!1};s()(a.Z,l);a.Z.locals;const c=(0,i(51900).Z)(o,(function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("div",{staticClass:"single-file-task"},[i("PageTitle",{attrs:{title:e.title}}),e._v(" "),e.loadIng>0?i("Loading"):[e.isCode?i("AceEditor",{staticClass:"view-editor",attrs:{ext:e.codeExt,readOnly:""},model:{value:e.codeContent,callback:function(t){e.codeContent=t},expression:"codeContent"}}):e.isOffice?i("OnlyOffice",{attrs:{code:e.officeCode,documentKey:e.documentKey,readOnly:""},model:{value:e.officeContent,callback:function(t){e.officeContent=t},expression:"officeContent"}}):e.isPreview?i("iframe",{staticClass:"preview-iframe",attrs:{src:e.previewUrl}}):i("div",{staticClass:"no-support"},[e._v(e._s(e.$L("不支持单独查看此消息")))])]],2)}),[],!1,null,"3847fd5e",null).exports}}]);