mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-13 12:02:51 +00:00
2 lines
12 KiB
JavaScript
Vendored
2 lines
12 KiB
JavaScript
Vendored
import{V as y}from"./vue.fd9b772e.js";import{m as w}from"./vuex.cc7cb26e.js";import{i as $}from"./view-design-hi.18b9f7fe.js";import{m as a}from"./@micro-zoe.d3f492b7.js";import{D as A}from"./DialogWrapper.2b3d62cd.js";import{n as c,d as _,U as d,e as p,b as u,c as b,l as g}from"./app.20cb76f1.js";import{R as M}from"./index.907ceb5f.js";var S=function(){var e=this,s=e.$createElement,t=e._self._c||s;return t("div",{directives:[{name:"transfer-dom",rawName:"v-transfer-dom"}],attrs:{"data-transfer":!0}},[t("div",{class:e.className},[t("transition",{attrs:{name:e.transitions[0]}},[e.value?t("div",{staticClass:"micro-modal-mask",style:e.maskStyle,on:{click:e.onClose}}):e._e()]),t("transition",{attrs:{name:e.transitions[1]}},[e.value?t("div",{staticClass:"micro-modal-content",style:e.contentStyle},[t("div",{staticClass:"micro-modal-close",on:{click:e.onClose}},[t("svg",{attrs:{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 26 26"}},[t("path",{attrs:{d:"M8.28596 6.51819C7.7978 6.03003 7.00634 6.03003 6.51819 6.51819C6.03003 7.00634 6.03003 7.7978 6.51819 8.28596L11.2322 13L6.51819 17.714C6.03003 18.2022 6.03003 18.9937 6.51819 19.4818C7.00634 19.97 7.7978 19.97 8.28596 19.4818L13 14.7678L17.714 19.4818C18.2022 19.97 18.9937 19.97 19.4818 19.4818C19.97 18.9937 19.97 18.2022 19.4818 17.714L14.7678 13L19.4818 8.28596C19.97 7.7978 19.97 7.00634 19.4818 6.51819C18.9937 6.03003 18.2022 6.03003 17.714 6.51819L13 11.2322L8.28596 6.51819Z",fill:"currentColor"}})])]),t("ResizeLine",{staticClass:"micro-modal-resize",attrs:{placement:"right",min:e.minSize,max:0,reverse:!0,beforeResize:e.beforeResize},on:{"on-change":e.onChangeResize},model:{value:e.dynamicSize,callback:function(i){e.dynamicSize=i},expression:"dynamicSize"}}),t("div",{ref:"body",staticClass:"micro-modal-body",style:e.bodyStyle},[e._t("default")],2)],1):e._e()])],1)])},C=[];const k={name:"MicroModal",components:{ResizeLine:M},directives:{TransferDom:_},props:{value:{type:Boolean,default:!1},size:{type:Number,default:300},minSize:{type:Number,default:300},background:{default:null},transparent:{type:Boolean,default:!1},autoDarkTheme:{type:Boolean,default:!0},beforeClose:Function},data(){return{dynamicSize:0,zIndex:1e3}},computed:{className({value:e,transparent:s,autoDarkTheme:t}){return{"micro-modal":!0,"micro-modal-hidden":!e,"no-dark-content":!t,"transparent-mode":s}},transitions({transparent:e}){return e?["",""]:["micro-modal-fade","micro-modal-slide"]},bodyStyle(){const e={};return $A.isJson(this.background)?e.background=this.background:this.background&&(e.backgroundColor=this.background),e},maskStyle({zIndex:e}){return{zIndex:e}},contentStyle({dynamicSize:e,zIndex:s}){return{width:e<=100?`${e}%`:`${e}px`,zIndex:s}}},watch:{value:{handler(e){e&&(this.zIndex=typeof window.modalTransferIndex=="number"?window.modalTransferIndex++:1e3)},immediate:!0},size:{handler(e){this.dynamicSize=parseInt(e)},immediate:!0}},methods:{beforeResize(){return new Promise(e=>{this.dynamicSize<=100&&this.updateSize(),e()})},onChangeResize({event:e}){e==="up"&&this.updateSize()},updateSize(){this.$refs.body&&(this.dynamicSize=this.$refs.body.clientWidth)},onClose(){if(!this.beforeClose)return this.handleClose();const e=this.beforeClose();e&&e.then?e.then(()=>{this.handleClose()}):this.handleClose()},handleClose(){this.$emit("input",!1)}}},m={};var x=c(k,S,C,!1,E,null,null,null);function E(e){for(let s in m)this[s]=m[s]}var I=function(){return x.exports}(),O=function(){var e=this,s=e.$createElement,t=e._self._c||s;return t("iframe",{ref:"iframe",staticClass:"micro-app-iframe",attrs:{src:e.src,sandbox:"allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox"}})},L=[];const T={name:"MicroIFrame",props:{name:{type:String,default:""},url:{type:String,default:""},data:{type:Object,default:null}},data(){return{src:this.url}},mounted(){this.injectMicroApp(),window.addEventListener("message",this.handleMessage.bind(this)),this.$refs.iframe.addEventListener("load",this.handleLoad.bind(this)),this.$refs.iframe.addEventListener("error",this.handleError.bind(this))},beforeDestroy(){this.cleanupMicroApp(),window.removeEventListener("message",this.handleMessage.bind(this)),this.$refs.iframe.removeEventListener("load",this.handleLoad.bind(this)),this.$refs.iframe.removeEventListener("error",this.handleError.bind(this))},methods:{handleLoad(e){this.injectMicroApp(),this.$emit("mounted",{...e,detail:{name:this.name}})},handleError(e){this.$emit("error",{...e,detail:{name:this.name,error:e}})},handleMessage(e){if(!this.isFromCurrentIframe(e))return;const{type:s,message:t}=e.data;switch(s){case"MICRO_APP_METHOD":if(!this.data||!this.data.methods)return;const{id:i,method:r,args:n}=t;if(this.data.methods[r]){const l=v=>{this.$refs.iframe.contentWindow.postMessage({type:"MICRO_APP_METHOD_RESULT",message:{id:i,result:$A.cloneJSON(v)}},"*")},o=this.data.methods[r](...n);o&&o.then?o.then(l).catch(l):l(o)}break}},isFromCurrentIframe(e){try{const{source:s}=e;return this.$refs.iframe&&s===this.$refs.iframe.contentWindow}catch{return!1}},injectMicroApp(){try{const e=this.$refs.iframe.contentWindow;if(e&&this.data)try{e.microApp={getData:()=>this.data}}catch{e.postMessage({type:"MICRO_APP_INJECT",message:{type:this.data.type,props:this.data.props}},"*")}}catch{}},cleanupMicroApp(){try{const e=this.$refs.iframe.contentWindow;e&&e.microApp&&delete e.microApp}catch{}}}},h={};var z=c(T,O,L,!1,D,"e4e073ea",null,null);function D(e){for(let s in h)this[s]=h[s]}var W=function(){return z.exports}(),P=function(){var e=this,s=e.$createElement,t=e._self._c||s;return t("div",[e._l(e.apps,function(i,r){return t("MicroModal",{key:r,ref:`ref-${i.name}`,refInFor:!0,attrs:{size:1200,background:i.background,transparent:i.transparent,autoDarkTheme:i.auto_dark_theme,beforeClose:async function(){await e.onBeforeClose(i.name)}},model:{value:i.isOpen,callback:function(n){e.$set(i,"isOpen",n)},expression:"app.isOpen"}},[i.url_type==="iframe"&&i.isOpen&&i.url?t("MicroIFrame",{attrs:{name:i.name,url:i.url,data:e.appData(i.name)},on:{mounted:e.mounted,error:e.error}}):i.isOpen&&i.url?t("micro-app",{attrs:{name:i.name,url:i.url,"keep-alive":i.keep_alive,"disable-scopecss":i.disable_scope_css,data:e.appData(i.name)},on:{mounted:e.mounted,error:e.error}}):e._e(),i.isLoading?t("div",{staticClass:"micro-app-loader"},[t("Loading")],1):e._e()],1)}),t("UserSelect",e._b({ref:"userSelect",attrs:{module:""},model:{value:e.userSelectOptions.value,callback:function(i){e.$set(e.userSelectOptions,"value",i)},expression:"userSelectOptions.value"}},"UserSelect",e.userSelectOptions.config,!1)),t("Modal",{attrs:{closable:!0,mask:!1,"mask-closable":!1,"footer-hide":!0,"transition-names":["",""],beforeClose:e.onAssistClose,"class-name":"micro-app-assist"},model:{value:e.assistShow,callback:function(i){e.assistShow=i},expression:"assistShow"}})],2)},N=[];const R={name:"MicroApps",directives:{TransferDom:_},components:{MicroModal:I,UserSelect:d,MicroIFrame:W},props:{windowType:{type:String,default:"embed"}},data(){return{apps:[],assistShow:!1,userSelectOptions:{value:[],config:{}}}},created(){a.start({iframe:!0,"router-mode":"state",iframeSrc:window.location.origin+"/assets/empty.html"})},mounted(){p.on("observeMicroApp:open",this.observeMicroApp)},beforeDestroy(){p.off("observeMicroApp:open",this.observeMicroApp)},watch:{userToken(e){e||this.closeAllMicroApp()},themeName(){this.closeAllMicroApp()},apps:{handler(e){this.assistShow=!!e.find(s=>s.isOpen)},deep:!0}},computed:{...w(["userInfo","themeName"])},methods:{mounted(e){this.finish(e.detail.name)},error(e){this.finish(e.detail.name),$A.modalError({language:!1,title:this.$L("\u5E94\u7528\u52A0\u8F7D\u5931\u8D25"),content:e.detail.error,onOk:()=>{this.closeMicroApp(e.detail.name,!0)}})},finish(e){const s=this.apps.find(t=>t.name==e);s&&(s.isLoading=!1)},appData(e){const s=this.apps.find(t=>t.name==e);return s?{type:"init",instance:{Vue:y,store:u,components:{DialogWrapper:A,UserSelect:d,DatePicker:$.exports.DatePicker}},props:{...s.props,name:s.name,url:s.url,urlType:s.url_type,userId:this.userId,userToken:this.userToken,userInfo:this.userInfo,baseUrl:$A.mainUrl(),systemInfo:window.systemInfo,windowType:this.windowType,isEEUIApp:$A.isEEUIApp,isElectron:$A.isElectron,isMainElectron:$A.isMainElectron,isSubElectron:$A.isSubElectron,languageList:b,languageName:g,themeName:this.themeName},methods:{close:(t=!1)=>{this.closeMicroApp(e,t)},back:()=>{this.closeByName(e)},popoutWindow:async(t=null)=>{const i=this.apps.find(r=>r.name==e);if(!i){$A.modalError("\u5E94\u7528\u4E0D\u5B58\u5728");return}await this.inlineBlank(i,t)},openWindow:t=>{$A.isJson(t)||(t={path:t}),t.url&&(t.path=t.url,delete t.url),this.$store.dispatch("openChildWindow",t)},openTabWindow:t=>{this.$store.dispatch("openWebTabWindow",t)},openAppPage:t=>{$A.isJson(t)||(t={url:t}),this.$store.dispatch("openAppChildPage",{pageType:"app",pageTitle:t.title||" ",url:"web.js",params:{url:t.url,titleFixed:typeof t.titleFixed=="boolean"?t.titleFixed:!1}})},requestAPI:async t=>await u.dispatch("call",t),selectUsers:async t=>($A.isJson(t)||(t={value:t}),$A.isArray(t.value)&&(t.value=t.value?[t.value]:[]),this.userSelectOptions.value=t.value,delete t.value,this.userSelectOptions.config=t,await new Promise(i=>{this.$refs.userSelect.onSelection(r=>i(r))})),nextZIndex:()=>typeof window.modalTransferIndex=="number"?window.modalTransferIndex++:1e3,extraCallA:(...t)=>{if(t.length>0&&typeof t[0]=="string"){const i=t[0],r=t.slice(1);if(typeof $A[i]=="function")return $A[i](...r)}return null}}}:{}},async observeMicroApp(e){if(e.url_type==="inline_blank"){await this.inlineBlank(e);return}if(e.url_type==="external"){await this.externalWindow(e);return}const s=this.apps.find(({name:t})=>t==e.name);s?(s.url!=e.url&&(await a.unmountApp(s.name,{destroy:!0}),s.isLoading=!0),Object.assign(s,e),requestAnimationFrame(t=>s.isOpen=!0)):(e.isLoading=!0,e.isOpen=!1,this.apps.push(e),requestAnimationFrame(t=>e.isOpen=!0))},async inlineBlank(e,s=null){const t={...e,url_type:e.url_type==="iframe"?"iframe":"inline",transparent:!0,keep_alive:!1};s!=null&&s.url&&(t.url=s.url,delete s.url);const i=`/single/apps/${t.name}`,r=(await $A.IDBArray("cacheMicroApps")).filter(n=>n.name!=t.name);r.length>50&&r.splice(0,10),r.push(t),await $A.IDBSet("cacheMicroApps",r),this.$Electron?await this.$store.dispatch("openChildWindow",{name:`single-apps-${$A.randomString(6)}`,path:i,force:!1,config:Object.assign({title:" ",parent:null,width:Math.min(window.screen.availWidth,1440),height:Math.min(window.screen.availHeight,900)},$A.isJson(s)?s:{})}):this.$isEEUIApp?await this.$store.dispatch("openAppChildPage",{pageType:"app",pageTitle:" ",url:"web.js",params:{url:$A.urlReplaceHash(i)}}):window.open($A.mainUrl(i.substring(1)))},async externalWindow(e){this.$Electron?await this.$store.dispatch("openChildWindow",{name:`external-apps-${$A.randomString(6)}`,path:e.url,force:!1,config:{title:" ",parent:null,width:Math.min(window.screen.availWidth,1440),height:Math.min(window.screen.availHeight,900)}}):this.$isEEUIApp?await this.$store.dispatch("openAppChildPage",{pageType:"app",pageTitle:" ",url:"web.js",params:{url:e.url}}):window.open(e.url)},closeByName(e){try{this.$refs[`ref-${e}`][0].onClose()}catch{this.closeMicroApp(e)}},closeMicroApp(e,s){const t=this.apps.find(i=>i.name==e);!t||(t.isOpen=!1,s&&a.unmountApp(t.name,{destroy:!0}))},closeAllMicroApp(e=!0){this.apps.forEach(s=>{s.isOpen=!1,e&&a.unmountApp(s.name,{destroy:!0})})},onBeforeClose(e){return new Promise(s=>{a.forceSetData(e,{type:"beforeClose"},t=>{t!=null&&t.find(i=>i===!0)||($A.leftExists(e,"appstore")&&this.$store.dispatch("updateMicroAppsStatus"),$A.isSubElectron?$A.Electron.sendMessage("windowDestroy"):s())})})},onAssistClose(){return new Promise(e=>{const s=this.apps.findLast(t=>t.isOpen);s?this.closeByName(s.name):e()})}}},f={};var F=c(R,P,N,!1,B,null,null,null);function B(e){for(let s in f)this[s]=f[s]}var G=function(){return F.exports}();export{G as M};
|