mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-12 11:19:56 +00:00
2 lines
10 KiB
JavaScript
Vendored
2 lines
10 KiB
JavaScript
Vendored
import{V as h}from"./vue.fd9b772e.js";import{m as f}from"./vuex.cc7cb26e.js";import{i as v}from"./view-design-hi.18b9f7fe.js";import{m as n}from"./@micro-zoe.f728a9f4.js";import{D as _}from"./DialogWrapper.57a6baf8.js";import{n as o,d as m,U as l,e as c,b as $,c as w,l as y}from"./app.9d301cd7.js";import{R as A}from"./index.41480376.js";var b=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",{staticClass:"icon fill-current",attrs:{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 26 26",fill:"none",role:"img"}},[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"},[e._t("default")],2)],1):e._e()])],1)])},S=[];const x={name:"MicroModal",components:{ResizeLine:A},directives:{TransferDom:m},props:{value:{type:Boolean,default:!1},size:{type:Number,default:300},minSize:{type:Number,default:300},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"]},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)}}},p={};var M=o(x,b,S,!1,C,null,null,null);function C(e){for(let s in p)this[s]=p[s]}var g=function(){return M.exports}(),E=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"}})},k=[];const I={name:"MicroIFrame",props:{name:{type:String,default:""},url:{type:String,default:""}},data(){return{src:this.url}},mounted(){this.$refs.iframe.addEventListener("load",this.handleLoad.bind(this)),this.$refs.iframe.addEventListener("error",this.handleError.bind(this))},beforeDestroy(){this.$refs.iframe.removeEventListener("load",this.handleLoad.bind(this)),this.$refs.iframe.removeEventListener("error",this.handleError.bind(this))},methods:{handleLoad(e){this.$emit("mounted",{...e,detail:{name:this.name}})},handleError(e){this.$emit("error",{...e,detail:{name:this.name,error:e}})}}},u={};var L=o(I,E,k,!1,z,"1969b0c1",null,null);function z(e){for(let s in u)this[s]=u[s]}var O=function(){return L.exports}(),T=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,transparent:i.transparent,autoDarkTheme:i.auto_dark_theme,beforeClose:async function(){await e.onBeforeClose(i.name)}},model:{value:i.isOpen,callback:function(a){e.$set(i,"isOpen",a)},expression:"app.isOpen"}},[i.url_type==="iframe"&&i.isOpen&&i.url?t("MicroIFrame",{attrs:{name:i.name,url:i.url},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)},D=[];const B={name:"MicroApps",directives:{TransferDom:m},components:{MicroModal:g,UserSelect:l,MicroIFrame:O},props:{windowType:{type:String,default:"embed"}},data(){return{apps:[],assistShow:!1,userSelectOptions:{value:[],config:{}}}},created(){n.start({iframe:!0,"router-mode":"state",iframeSrc:window.location.origin+"/assets/empty.html"})},mounted(){c.on("observeMicroApp:open",this.observeMicroApp)},beforeDestroy(){c.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:{...f(["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:h,store:$,components:{DialogWrapper:_,UserSelect:l,DatePicker:v.exports.DatePicker}},props:{...s.props,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:w,languageName:y,themeName:this.themeName},methods:{close:(t=!1)=>{this.closeMicroApp(e,t)},back:()=>{this.closeByName(e)},nextZIndex:()=>typeof window.modalTransferIndex=="number"?window.modalTransferIndex++:1e3,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))})),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}})},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 n.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:"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(a=>a.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&&n.unmountApp(t.name,{destroy:!0}))},closeAllMicroApp(e=!0){this.apps.forEach(s=>{s.isOpen=!1,e&&n.unmountApp(s.name,{destroy:!0})})},onBeforeClose(e){return new Promise(s=>{n.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()})}}},d={};var N=o(B,T,D,!1,W,null,null,null);function W(e){for(let s in d)this[s]=d[s]}var q=function(){return N.exports}();export{q as M};
|