mixdashboards 1.0.27 → 1.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mixdashboards.cjs +1 -1
- package/dist/mixdashboards.js +1 -1
- package/package.json +1 -1
package/dist/mixdashboards.cjs
CHANGED
|
@@ -8852,4 +8852,4 @@ function sendPendingMessages() {\r
|
|
|
8852
8852
|
// 清空待处理列表\r
|
|
8853
8853
|
pendingMessages = [];\r
|
|
8854
8854
|
}\r
|
|
8855
|
-
`,kat=["id","data-theme"],zat={key:0,class:"canvas"},Bat={class:"modal-content"},Hat={key:0,class:"modal-sticky-area"},Vat=["title"],Fat={key:0,xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},Uat={key:1,xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},jat=["onClick"],Gat=d.defineComponent({name:"MixBasePreview",__name:"BasePreview",props:{script:{},uid:{},enableWebSocket:{type:Boolean,default:!0}},setup(t){const e=t;let n=d.reactive({margin:[10,10],height:40});const r=d.ref({sheets:[]}),i={pro:"ProContainer",show:"ShowContainer",app:"AppContainer"},a=d.ref(0),o=d.computed(()=>r.value.sheets[a.value]),s=d.computed(()=>{var Ne;return(((Ne=r.value)==null?void 0:Ne.sheets)||[]).map((Ze,Qe)=>({s:Ze,idx:Qe})).filter(({s:Ze})=>!(Ze!=null&&Ze.hideInPreviewTabs)).map(({idx:Ze})=>Ze)}),l=d.computed(()=>s.value.map(Pe=>r.value.sheets[Pe])),c=d.ref("light"),u=d.ref(!0),f=()=>{c.value=_ee.toggleTheme(),h(c.value)},h=Pe=>{const Ne=document.documentElement;Pe==="dark"?(Ne.setAttribute("data-theme","dark"),Ne.classList.add("dark")):(Ne.setAttribute("data-theme","light"),Ne.classList.remove("dark"))},p=Pe=>{const{theme:Ne}=Pe.detail;c.value=Ne,h(Ne)},v=d.ref(!0);let m=null;const y=d.computed(()=>localStorage.getItem("dashboardTabDisplayMode")||"auto"),g=()=>{y.value==="auto"&&(m&&clearTimeout(m),m=setTimeout(()=>{v.value=!1},3e3))},b=()=>{m&&(clearTimeout(m),m=null),v.value=!0},x=Pe=>{var Ze,Qe;const Ne=(Qe=(Ze=r.value)==null?void 0:Ze.sheets)==null?void 0:Qe[Pe];return(Ne==null?void 0:Ne.tabStyle)||{bgColor:"transparent",activeBgColor:"transparent",textColor:"#666666",activeTextColor:"#333333",fontSize:14,height:40,borderRadius:0}},w=d.computed(()=>x(a.value)),C=d.computed(()=>({height:`${w.value.height}px`})),S=Pe=>{const Ne=a.value===Pe,Ze=x(Pe);return{backgroundColor:Ne?Ze.activeBgColor:Ze.bgColor,color:Ne?Ze.activeTextColor:Ze.textColor,fontSize:`${Ze.fontSize}px`,height:`${Ze.height-8}px`,lineHeight:`${Ze.height-8}px`,borderRadius:`${Ze.borderRadius}px`}},A=d.computed(()=>{var Ne;const Pe=[...((Ne=o.value)==null?void 0:Ne.layers)||[]].sort((Ze,Qe)=>Ze.order-Qe.order);return T.value?Pe.filter(Ze=>Ze.id!==T.value):Pe});d.computed(()=>{var Pe;return[...((Pe=o.value)==null?void 0:Pe.layers)||[]].sort((Ne,Ze)=>Ne.order-Ze.order)});const T=d.ref(null),E=d.ref([]),M=d.ref(null),D=d.ref(null),O=d.ref([]),N=d.ref(null),I=d.computed(()=>D.value!==null&&D.value!==void 0?"sheet":E.value.length?"page":(T.value,"layer")),R=d.computed(()=>!!T.value||E.value.length>0||D.value!==null&&D.value!==void 0),B=d.computed(()=>{var Pe;return T.value&&(((Pe=o.value)==null?void 0:Pe.layers)||[]).find(Ne=>Ne.id===T.value)||null}),F=Pe=>{var Ze,Qe;const Ne=Number(Pe);return!Number.isFinite(Ne)||Ne<0?null:((Qe=(Ze=r.value)==null?void 0:Ze.sheets)==null?void 0:Qe[Ne])||null},V=(Pe,Ne)=>{if(!Array.isArray(Pe)||!Array.isArray(Ne)||!Ne.length)return[];const Ze=new Map(Pe.map(Qe=>[Qe.id,Qe]));return Ne.map(Qe=>Ze.get(Qe)).filter(Boolean)},j=d.computed(()=>{var Ze;const Pe=E.value||[];if(!Pe.length)return[];const Ne=new Map((((Ze=o.value)==null?void 0:Ze.layers)||[]).map(Qe=>[Qe.id,Qe]));return Pe.map(Qe=>Ne.get(Qe)).filter(Boolean).sort((Qe,Zt)=>{var we,Ge;return((we=Qe.order)!=null?we:0)-((Ge=Zt.order)!=null?Ge:0)})}),X=d.computed(()=>D.value===null||D.value===void 0?null:F(D.value)),W=d.computed(()=>{var Ne;return(((Ne=X.value)==null?void 0:Ne.layers)||[]).find(Ze=>!!Ze.isSticky)||null}),J=d.computed(()=>{var Qe,Zt;const Pe=((Qe=X.value)==null?void 0:Qe.layers)||[],Ne=(Zt=W.value)==null?void 0:Zt.id;let Ze=Pe.filter(we=>we.id!==Ne);return Array.isArray(O.value)&&O.value.length&&(Ze=V(Ze,O.value)),[...Ze].sort((we,Ge)=>{var Ue,Ve;return((Ue=we.order)!=null?Ue:0)-((Ve=Ge.order)!=null?Ve:0)})}),$=d.computed(()=>{var Pe,Ne,Ze,Qe,Zt,we;if(D.value!==null&&D.value!==void 0){const Ge=N.value||((Ne=(Pe=J.value)==null?void 0:Pe[0])==null?void 0:Ne.id);return Ge&&(((Ze=X.value)==null?void 0:Ze.layers)||[]).find(Ue=>Ue.id===Ge)||null}if(E.value.length){const Ge=M.value||((Zt=(Qe=j.value)==null?void 0:Qe[0])==null?void 0:Zt.id);return Ge&&(((we=o.value)==null?void 0:we.layers)||[]).find(Ue=>Ue.id===Ge)||null}return B.value}),q=()=>{D.value=null,O.value=[],N.value=null},re=()=>{E.value=[],M.value=null},Q=()=>{T.value=null,re(),q()},ce=Pe=>{var Zt,we;Q();const Ne={width:Pe==null?void 0:Pe.width,height:Pe==null?void 0:Pe.height};Ne&&(Ne.width||Ne.height)?se.value={width:(Zt=Ne.width)!=null?Zt:se.value.width,height:(we=Ne.height)!=null?we:se.value.height}:se.value={width:80,height:80};const Ze=Pe==null?void 0:Pe.sheetIndex,Qe=()=>{var Ue;const Ge=(Pe==null?void 0:Pe.targetType)||"layer";if(Ge==="page"){const Ve=Array.isArray(Pe==null?void 0:Pe.pageLayerIds)?Pe.pageLayerIds:[];E.value=Ve,M.value=(Ve==null?void 0:Ve[0])||null;return}if(Ge==="sheet"){D.value=(Ue=Pe==null?void 0:Pe.targetSheetIndex)!=null?Ue:null,O.value=Array.isArray(Pe==null?void 0:Pe.sheetLayerIds)?Pe.sheetLayerIds:[],N.value=null;return}re(),q(),T.value=(Pe==null?void 0:Pe.layerId)||null};if(Ze===-1||Ze===void 0||Ze===null){Qe();return}if(typeof Ze=="number"&&Ze>=0&&Ze!==a.value){a.value=Ze,d.nextTick(()=>{Qe()});return}Qe()},ae=()=>{Q()},ee=Pe=>{if(((Pe==null?void 0:Pe.targetType)||"layer")==="page"){const Qe=Array.isArray(Pe==null?void 0:Pe.pageLayerIds)?Pe.pageLayerIds:[];if(E.value.length===Qe.length&&E.value.every((we,Ge)=>we===Qe[Ge])){ae();return}ce(Pe);return}const Ze=Pe==null?void 0:Pe.layerId;if(Ze){if(T.value===Ze){ae();return}ce(Pe)}},he=(Pe,Ne)=>{const Ze=Pe==null?void 0:Pe.modalBinding;if(Ze&&Ze.enabled){if((Ze.triggerEvent||"click")!==Ne||(Ze.triggerMode||"direct")==="linkhub")return;switch((Ze==null?void 0:Ze.action)||"show"){case"show":ce(Ze);break;case"hide":ae();break;default:ee(Ze);break}return}},se=d.ref({width:80,height:80}),ve=Pe=>{const Ne=Number(se.value.width)||80,Ze=Number(se.value.height)||80;return{width:`${Ne}%`,height:`${Ze}%`,maxWidth:"100%",maxHeight:"100%"}},xe=Pe=>{var Ne;if(!((Ne=o.value)!=null&&Ne.layers))return!1;for(const Ze of o.value.layers)for(const Qe of Ze.components)if(Qe.type==="glbModel"&&Qe.data&&Array.isArray(Qe.data)){for(const Zt of Qe.data)if(Zt.targetComponentId===Pe)return!0}return!1},fe=d.ref({});let Be={},je=null;if(e.enableWebSocket)try{const Pe=new Blob([Rat],{type:"application/javascript"}),Ne=URL.createObjectURL(Pe);je=new SharedWorker(Ne),console.log("✅ [BasePreview] SharedWorker 已创建 (Blob 模式)")}catch(Pe){console.warn("⚠️ [BasePreview] SharedWorker 创建失败:",Pe)}const rt=new Iat;d.ref(!1),je&&(rt.init(je),je.port.onmessage=Pe=>{rt.processWorkerMessage(Pe)});const oe=()=>zt(null,null,function*(){try{const{getAuthToken:Pe,getWsUrl:Ne}=yield Promise.resolve().then(()=>Wat),Ze=yield Pe(),Qe=Ne();je&&(je.port.postMessage({type:"init_connection",url:Qe,token:Ze}),console.log("[Data] 数据连接已初始化, WebSocket URL:",Qe))}catch(Pe){console.error("[Data] 初始化失败:",Pe),At.ElMessage.error("数据连接初始化失败")}}),ye=Pe=>({x:Pe.x,y:Pe.y,w:Pe.w,h:Pe.h,i:Pe.i}),Ce=()=>{let Pe=1920,Ne=o.value.col||20;if(r.value.type==="pro"&&(Pe=document.body.offsetWidth-400-16-(Ne+1)*n.margin[0],n.height=Math.round(Pe/Ne)),r.value.type==="show"){let Ze=o.value.screenHeight;document.querySelector("#ShowContainer")&&(Ze=Ze-(Ne+1)*n.margin[0]),n.height=Ze/Ne}},le=Pe=>Pe?Pe.startsWith("#")||Pe.startsWith("rgb")||Pe.startsWith("rgba")?Pe:`url(${ie(Pe)})`:"",ie=Pe=>{if(Pe=="defaultBg1"&&(Pe=Oat),Pe=="defaultBg2"&&(Pe=Nat),Pe)return Pe},Ae=Pe=>(Pe&&Pe.dashboard&&Array.isArray(Pe.dashboard)&&Pe.dashboard.length>0&&(Pe=Pe.dashboard[0]),!Pe||!Pe.sheets?{sheets:[],type:""}:(Pe.sheets.forEach(Ne=>{if(!Ne.layers&&Ne.components){const Qe={id:WT("layer"),name:"图层 1",visible:!0,opacity:100,order:0,locked:!1,components:Ne.components||[]};Ne.layers=[Qe],Ne.activeLayerId=Qe.id,delete Ne.components}Ne.layers.forEach(Ze=>{Ze.components.forEach(Qe=>{var Ue;const{type:Zt}=Qe;let we=JSON.parse(JSON.stringify(Be[Qe.type].OPTIONS)),Ge=JSON.parse(JSON.stringify(Be[Qe.type].DATA));for(let Ve in we){const Lt=we[Ve]&&typeof we[Ve]=="object"&&"value"in we[Ve],_t=(Ue=Qe.options)==null?void 0:Ue[Ve],sn=_t&&typeof _t=="object"&&"value"in _t?_t.value:_t;Lt?we[Ve].value=sn!=null?sn:we[Ve].value:we[Ve]=sn!=null?sn:we[Ve]}Array.isArray(Qe.data)&&Qe.data.length&&(Qe.data=Qe.data.map((Ve,Lt)=>(Zt==="gridview"?Ve=Ve.map((_t,sn)=>(_t=Object.assign({},Ge[0][0],_t),_t)):Ve=Object.assign({},Ge[0],Ve),Ve))),Qe.options=we,Qe.source=Be[Qe.type].SOURCE||[],Qe.params=Be[Qe.type].PARAMS||[],Qe.common=Object.assign({},Be[Qe.type].COMMON,Qe.common)})})}),Pe)),He=()=>zt(null,null,function*(){var Pe;try{const Ne=yield _n.post("get_object_list",{select:["name","uid","alias"]});if((Ne==null?void 0:Ne.code)!==200||!((Pe=Ne==null?void 0:Ne.result)!=null&&Pe.data))return console.warn("获取对象别名失败:",(Ne==null?void 0:Ne.msg)||Ne),{};let Ze={};return Ne.result.data.forEach(Qe=>{Ze[Qe.alias]=Qe.uid}),Ze}catch(Ne){return console.error("获取对象别名异常:",Ne),{}}}),_e=Pe=>{a.value=Pe,d.nextTick(()=>{y.value==="auto"?(m&&clearTimeout(m),m=setTimeout(()=>{v.value=!1},3e3)):y.value==="show"&&(m&&(clearTimeout(m),m=null),v.value=!0)})},Ee=()=>{const{screenHeight:Pe,screenWidth:Ne}=o.value;let Ze=document.documentElement,Qe=document.getElementById("ShowContainer"),Zt=Ze.clientWidth,we=Ze.clientHeight,Ge=we/Pe,Ue=Zt/Ne,Ve=Ue>Ge?Ge:Ue,Lt=Zt/2-Ne*Ve/2,_t=we/2-Pe*Ve/2;Qe.style.width=Ne+"px",Qe.style.height=Pe+"px",Qe.style.transform=`scale(${Ve}, ${Ve}) translate(${Lt/Ve}px, ${_t/Ve}px)`},ut=Pe=>{Pe.key==="Escape"&&window.close()},lt=Pe=>{const Ne=(Pe==null?void 0:Pe.detail)||{},Ze=Ne.action||"show",Qe=Ne.layerId;if(Ne.sheetIndex,Ne.size,!(!Qe&&Ze!=="hide")){if(Ze==="hide"){ae();return}if(Ze==="toggle"){ee(Ne);return}ce(Ne)}},dt=Ra(),tn=()=>{var Ze;const Pe=[];return(((Ze=r.value)==null?void 0:Ze.sheets)||[]).forEach((Qe,Zt)=>{var we;(we=Qe.layers)==null||we.forEach(Ge=>{var Ue;(Ue=Ge.components)==null||Ue.forEach(Ve=>{var _t,sn,mr,Vr;const Lt=Ve==null?void 0:Ve.modalBinding;if(Lt&&Lt.enabled&&Lt.triggerMode==="linkhub"){const Zn=((sn=(_t=Ve==null?void 0:Ve.options)==null?void 0:_t.linkChannel)==null?void 0:sn.value)||"",Gr=((Vr=(mr=Ve==null?void 0:Ve.options)==null?void 0:mr.customChannel)==null?void 0:Vr.value)||"",Zi=Zn==="custom"&&Gr?Gr:Zn;console.log("[LinkHub Modal] 找到 linkhub 模式组件:",{componentId:Ve==null?void 0:Ve.id,linkChannelValue:Zn,customChannelValue:Gr,linkChannel:Zi,binding:Lt}),Zi&&Pe.push({binding:Lt,linkChannel:Zi,component:Ve,sheetIndex:Zt,layerId:Ge.id})}})})}),console.log("[LinkHub Modal] 所有 linkhub 绑定:",Pe),Pe},at=(Pe,Ne)=>{if(console.log("[LinkHub Modal] 收到事件:",{channel:Pe,event:Ne}),!Ne||!Ne.topic){console.log("[LinkHub Modal] 事件无效,跳过");return}const Ze=tn();console.log("[LinkHub Modal] 所有绑定:",Ze);const Qe=Ze.filter(Ue=>Ue.linkChannel===Pe);if(console.log("[LinkHub Modal] 匹配的绑定:",Qe,"频道:",Pe),Qe.length===0){console.log("[LinkHub Modal] 没有匹配的绑定,跳过");return}const we=Qe[0].binding;console.log("[LinkHub Modal] 使用绑定:",we);const Ge=(we==null?void 0:we.action)||"show";if(Ge==="hide"){console.log("[LinkHub Modal] 执行 hide 操作"),ae();return}if(Ge==="show"){const Ue=(we==null?void 0:we.targetType)||"layer";if(Ue==="sheet"){const Ve=we==null?void 0:we.targetSheetIndex;if(D.value===Ve){console.log("[LinkHub Modal] 弹窗已打开,跳过");return}}else if(Ue==="layer"){const Ve=we==null?void 0:we.layerId;if(T.value===Ve){console.log("[LinkHub Modal] 弹窗已打开,跳过");return}}console.log("[LinkHub Modal] 执行 show 操作,打开弹窗"),ce(we);return}if(Ge==="toggle"){console.log("[LinkHub Modal] 执行 toggle 操作"),ee(we);return}};let yt=null;const Yt=new Set;return d.onMounted(()=>zt(null,null,function*(){window.addEventListener("keydown",ut),window.addEventListener("mix-modal",lt);const Pe=localStorage.getItem("dashboardDefaultTheme")||"light";u.value=localStorage.getItem("dashboardShowThemeToggle")!=="false",Pe==="auto"?c.value=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":c.value=Pe,h(c.value),window.addEventListener("mix-dashboard-theme-change",p),yield oe();const Ne=yield He();sessionStorage.setItem("object_alias_uid_mapping",JSON.stringify(Ne)),fe.value=yield J5.loadComponents(),Be=yield J5.getAllExposedProps(),e.script&&(r.value=Ae(e.script)),window.__mix_preview_params=r.value,yt=d.watch(()=>dt.channels,(Ze,Qe)=>{!r.value||!r.value.sheets||r.value.sheets.length===0||Object.keys(Ze).forEach(Zt=>{const we=Ze[Zt];if(!we||!we.topic)return;const Ge=we.topic.uniqueId;Yt.has(Ge)||(Yt.add(Ge),console.log("[LinkHub Modal] 检测到新事件:",{channel:Zt,newEventId:Ge,event:JSON.parse(JSON.stringify(we))}),at(Zt,we))})},{deep:!0,immediate:!1}),d.nextTick(()=>{Ce(),y.value==="auto"?m=setTimeout(()=>{v.value=!1},3e3):y.value==="show"&&(v.value=!0)}),r.value.type==="show"&&(d.nextTick(()=>{Ee(),document.title="预览"}),window.onresize=()=>{Ee()})})),d.onUnmounted(()=>{window.removeEventListener("keydown",ut),m&&(clearTimeout(m),m=null),window.removeEventListener("mix-dashboard-theme-change",p),yt&&(yt(),yt=null),rt&&rt.close(),sessionStorage.removeItem("object_alias_uid_mapping")}),d.provide("sharedWorker",je),d.provide("session",rt),d.provide("switchSheet",Pe=>{Pe>=0&&Pe<r.value.sheets.length&&(a.value=Pe)}),d.provide("getSheets",()=>r.value.sheets),d.provide("getCurrentSheet",()=>a.value),(Pe,Ne)=>{var Ze,Qe,Zt;return r.value.sheets.length>0?(d.openBlock(),d.createElementBlock("div",{key:0,id:i[r.value.type],class:"w-[100%] h-[100%]","data-theme":c.value},[d.createElementVNode("div",{class:"layout",style:d.normalizeStyle({background:le((Ze=o.value)==null?void 0:Ze.background)})},[o.value?(d.openBlock(),d.createElementBlock("div",zat,[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(A.value,we=>(d.openBlock(),d.createElementBlock("div",{key:we.id,class:"layer-container",style:d.normalizeStyle({opacity:we.opacity/100,pointerEvents:"none"})},[d.withDirectives(d.createVNode(d.unref(G8),{layout:we.components,"onUpdate:layout":Ge=>we.components=Ge,"col-num":o.value.col,"row-height":d.unref(n).height,margin:d.unref(n).margin,"is-draggable":!1,"is-resizable":!1,"is-mirrored":!1,"vertical-compact":!1,"use-css-transforms":!0},{default:d.withCtx(()=>[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(we.components,Ge=>(d.openBlock(),d.createBlock(d.unref(rd),d.mergeProps({key:Ge.i},{ref_for:!0},ye(Ge),{"data-id":Ge.id,style:{pointerEvents:"auto",visibility:xe(Ge.id)?"hidden":"visible"},onClick:Ue=>he(Ge,"click"),onDblclick:Ue=>he(Ge,"dblclick")}),{default:d.withCtx(()=>[fe.value[Ge.type]?(d.openBlock(),d.createBlock(d.resolveDynamicComponent(fe.value[Ge.type]),{key:0,conf:Ge,theme:c.value,mode:"preview"},null,8,["conf","theme"])):d.createCommentVNode("",!0)]),_:2},1040,["data-id","style","onClick","onDblclick"]))),128))]),_:2},1032,["layout","onUpdate:layout","col-num","row-height","margin"]),[[d.vShow,we.visible]])],4))),128))])):d.createCommentVNode("",!0)],4),R.value?(d.openBlock(),d.createElementBlock("div",{key:0,class:"modal-overlay",onClick:d.withModifiers(ae,["self"])},[d.createElementVNode("div",{class:"modal-container",style:d.normalizeStyle(ve(B.value))},[d.createElementVNode("button",{class:"modal-close-btn",onClick:ae,title:"关闭"},[...Ne[0]||(Ne[0]=[d.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[d.createElementVNode("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),d.createElementVNode("line",{x1:"6",y1:"6",x2:"18",y2:"18"})],-1)])]),d.createElementVNode("div",Bat,[I.value==="sheet"&&W.value?(d.openBlock(),d.createElementBlock("div",Hat,[d.createVNode(d.unref(G8),{layout:W.value.components,"col-num":((Qe=X.value)==null?void 0:Qe.col)||o.value.col,"row-height":d.unref(n).height,margin:d.unref(n).margin,"is-draggable":!1,"is-resizable":!1,"is-mirrored":!1,"vertical-compact":!1,"use-css-transforms":!0},{default:d.withCtx(()=>[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(W.value.components||[],we=>(d.openBlock(),d.createBlock(d.unref(rd),d.mergeProps({key:we.i},{ref_for:!0},ye(we),{"data-id":we.id,style:{pointerEvents:"auto"}}),{default:d.withCtx(()=>[fe.value[we.type]?(d.openBlock(),d.createBlock(d.resolveDynamicComponent(fe.value[we.type]),{key:0,conf:we,theme:c.value,mode:"preview"},null,8,["conf","theme"])):d.createCommentVNode("",!0)]),_:2},1040,["data-id"]))),128))]),_:1},8,["layout","col-num","row-height","margin"])])):d.createCommentVNode("",!0),I.value==="sheet"&&X.value?(d.openBlock(!0),d.createElementBlock(d.Fragment,{key:1},d.renderList((X.value.layers||[]).filter(we=>we.visible&&!we.isSticky),we=>(d.openBlock(),d.createElementBlock("div",{key:we.id,class:"layer-container",style:d.normalizeStyle({opacity:we.opacity/100,pointerEvents:"none"})},[d.createVNode(d.unref(G8),{layout:we.components,"onUpdate:layout":Ge=>we.components=Ge,"col-num":X.value.col||o.value.col,"row-height":d.unref(n).height,margin:d.unref(n).margin,"is-draggable":!1,"is-resizable":!1,"is-mirrored":!1,"vertical-compact":!1,"use-css-transforms":!0},{default:d.withCtx(()=>[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(we.components,Ge=>(d.openBlock(),d.createBlock(d.unref(rd),d.mergeProps({key:Ge.i},{ref_for:!0},ye(Ge),{"data-id":Ge.id,style:{pointerEvents:"auto"}}),{default:d.withCtx(()=>[fe.value[Ge.type]?(d.openBlock(),d.createBlock(d.resolveDynamicComponent(fe.value[Ge.type]),{key:0,conf:Ge,theme:c.value,mode:"preview"},null,8,["conf","theme"])):d.createCommentVNode("",!0)]),_:2},1040,["data-id"]))),128))]),_:2},1032,["layout","onUpdate:layout","col-num","row-height","margin"])],4))),128)):(d.openBlock(),d.createBlock(d.unref(G8),{key:2,layout:(Zt=$.value)==null?void 0:Zt.components,"col-num":o.value.col,"row-height":d.unref(n).height,margin:d.unref(n).margin,"is-draggable":!1,"is-resizable":!1,"is-mirrored":!1,"vertical-compact":!1,"use-css-transforms":!0},{default:d.withCtx(()=>{var we;return[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(((we=$.value)==null?void 0:we.components)||[],Ge=>(d.openBlock(),d.createBlock(d.unref(rd),d.mergeProps({key:Ge.i},{ref_for:!0},ye(Ge),{"data-id":Ge.id,style:{pointerEvents:"auto"}}),{default:d.withCtx(()=>[fe.value[Ge.type]?(d.openBlock(),d.createBlock(d.resolveDynamicComponent(fe.value[Ge.type]),{key:0,conf:Ge,theme:c.value,mode:"preview"},null,8,["conf","theme"])):d.createCommentVNode("",!0)]),_:2},1040,["data-id"]))),128))]}),_:1},8,["layout","col-num","row-height","margin"]))])],4)])):d.createCommentVNode("",!0),u.value?(d.openBlock(),d.createElementBlock("div",{key:1,class:"theme-toggle-btn",onClick:f,title:c.value==="light"?"切换到暗色模式":"切换到亮色模式"},[c.value==="light"?(d.openBlock(),d.createElementBlock("svg",Fat,[...Ne[1]||(Ne[1]=[d.createElementVNode("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"},null,-1)])])):(d.openBlock(),d.createElementBlock("svg",Uat,[...Ne[2]||(Ne[2]=[d.createStaticVNode('<circle cx="12" cy="12" r="5" data-v-65516e38></circle><line x1="12" y1="1" x2="12" y2="3" data-v-65516e38></line><line x1="12" y1="21" x2="12" y2="23" data-v-65516e38></line><line x1="4.22" y1="4.22" x2="5.64" y2="5.64" data-v-65516e38></line><line x1="18.36" y1="18.36" x2="19.78" y2="19.78" data-v-65516e38></line><line x1="1" y1="12" x2="3" y2="12" data-v-65516e38></line><line x1="21" y1="12" x2="23" y2="12" data-v-65516e38></line><line x1="4.22" y1="19.78" x2="5.64" y2="18.36" data-v-65516e38></line><line x1="18.36" y1="5.64" x2="19.78" y2="4.22" data-v-65516e38></line>',9)])]))],8,Vat)):d.createCommentVNode("",!0),l.value.length>1&&y.value!=="hide"?(d.openBlock(),d.createElementBlock("div",{key:2,class:"sheet-trigger-area",onMouseenter:b},null,32)):d.createCommentVNode("",!0),l.value.length>1&&y.value!=="hide"?(d.openBlock(),d.createElementBlock("div",{key:3,class:d.normalizeClass(["sheet-wrap",{"is-visible":y.value==="show"||v.value}]),style:d.normalizeStyle(C.value),onMouseenter:b,onMouseleave:g},[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(l.value,(we,Ge)=>(d.openBlock(),d.createElementBlock("div",{key:we.id||Ge,class:d.normalizeClass(["sheet-item",{active:a.value===s.value[Ge]}]),style:d.normalizeStyle(S(s.value[Ge])),onClick:Ue=>_e(s.value[Ge])},d.toDisplayString(we.caption||we.name),15,jat))),128))],38)):d.createCommentVNode("",!0)],8,kat)):d.createCommentVNode("",!0)}}}),JP=St(Gat,[["__scopeId","data-v-65516e38"]]),KP=d.defineComponent({name:"MixDesignShow",__name:"DesignShow",props:{script:{},uid:{},enableWebSocket:{type:Boolean,default:!0}},setup(t){const e=t;return(n,r)=>(d.openBlock(),d.createBlock(JP,{script:e.script,uid:e.uid,enableWebSocket:e.enableWebSocket},null,8,["script","uid","enableWebSocket"]))}}),QP=d.defineComponent({name:"MixDesignPro",__name:"DesignPro",props:{script:{},uid:{},enableWebSocket:{type:Boolean,default:!0}},setup(t){const e=t;return(n,r)=>(d.openBlock(),d.createBlock(JP,{script:e.script,uid:e.uid,enableWebSocket:e.enableWebSocket},null,8,["script","uid","enableWebSocket"]))}}),$P=d.defineComponent({name:"MixDesignApp",__name:"DesignApp",props:{script:{},uid:{},enableWebSocket:{type:Boolean,default:!0}},setup(t){const e=t;return(n,r)=>(d.openBlock(),d.createBlock(JP,{script:e.script,uid:e.uid,enableWebSocket:e.enableWebSocket},null,8,["script","uid","enableWebSocket"]))}}),eL={url:"/apiproxy/api",appId:"AUP6255392800002",appSecret:"ac8fe574-c067-4cd2-0edf-5b5d9e6593e6",wsUrl:"wss://mixuis.mixyun.top/apiproxy/ws/api"};let ul=ze({},eL),E5="",MC=0;function Aee(t){ul=ze(ze({},ul),t),t.url&&!t.wsUrl&&(ul.wsUrl=Xat(t.url)),E5="",MC=0,console.log("[Auth] 配置已更新",ul)}function Xat(t){try{let e=t.replace("/apiproxy/api","/apiproxy/ws/api");return e=e.replace(/^https?:\/\//,"wss://"),e}catch(e){return console.error("[Auth] WebSocket URL 推导失败:",e),ul.wsUrl||eL.wsUrl}}function Cee(){return ul.wsUrl||eL.wsUrl}function Tee(){return zt(this,null,function*(){var e,n,r,i;const t=Date.now();if(console.log("[Auth] 当前配置:",ul),E5&&MC>t+3e5)return E5;try{const a=yield ci.post(ul.url,{action:"get_access_token",app_id:ul.appId,app_secret:ul.appSecret});if(((e=a.data)==null?void 0:e.code)===200&&((r=(n=a.data)==null?void 0:n.result)!=null&&r.access_token)){E5=a.data.result.access_token;const o=a.data.result.expires_in||7200;return MC=t+o*1e3,console.log("[Auth] Token 获取成功"),E5}else{const o=((i=a.data)==null?void 0:i.msg)||"未知错误";throw new Error(`Token 获取失败: ${o}`)}}catch(a){throw console.error("[Auth] Token 获取异常:",a),a}})}const Wat=Object.freeze(Object.defineProperty({__proto__:null,configureAuth:Aee,getAuthToken:Tee,getWsUrl:Cee},Symbol.toStringTag,{value:"Module"})),Yat=[KP,QP,$P],Zat=function(t){Yat.forEach(e=>{t.component(e.name||e.__name,e)})},qat={install:Zat,DesignShow:KP,DesignPro:QP,DesignApp:$P},Zf={multiple:{mosaic:"get_tools_mosaic_list"},single:{mosaic:"get_memory_mosaic_values"},result:{mosaic:"get_tools_mosaic_list",statistics:"get_tools_statistics_list"},near:{statistics:"get_tools_last_statistics_list",calculate:"get_tools_last_statistics_list"}},Jat=["crd","vlu","arrayCard"];class Kat{constructor(){}getHistoryData(e,n){var p,v,m,y,g;if(n==="retainer1")return this.getRetainerHistoryData(e,1);if(n==="retainer2")return this.getRetainerHistoryData(e,4);let r="result";const{conf:i,uid:a}=e,{data:o,common:s,options:l}=i,c=s.source||"mosaic";c==="mosaic"&&(r=Jat.includes(n)?"single":"multiple"),["statistics","calculate"].includes(c)&&(o.filter(x=>{var w;return(w=x.periodUnit)==null?void 0:w.includes("near")}).length&&["bar","lin"].includes(n)?r="near":r="result");const u={block_mapping:"mixtools",action:this.getAction(r,c),condition:[]};let f=((p=l.points)==null?void 0:p.value)||1,h="";if(s.multiObject||(h=gi(s,!!s.useAlias,a)),s.source==="summary"?(u.block_mapping="schema",u.action="get_statistical_quantity",delete u.condition):o.forEach(b=>{var x;if(s.multiObject&&(h=gi(b,!!s.useAlias,a)),b.object_id=h||b.object_id,(x=s==null?void 0:s.rate)!=null&&x.checked)u.condition.push(this.get_mosaic_by_timespan(b,f,s.rate));else{const w=`get_${c}_item`;typeof this[w]=="function"&&u.condition.push(this[w](b,r,f,n))}}),n==="scd"&&((v=l.multipleImg)!=null&&v.value)){const b=JSON.parse(sessionStorage.getItem(w0)||"{}");h=((m=l.object)==null?void 0:m.value)||"",s.useAlias&&((y=l.object)!=null&&y.value)&&(h=b[l.object.value]||l.object.value),u.condition.push({block_mapping:"influxdbproxy",action:"get_last_mosaic_list_by_item",keys:[(g=l.statusFv)==null?void 0:g.value],object_id:h||a,items:1})}return n==="sankey"&&(s.multiObject&&(h=gi(s,!!s.useAlias,a)),u.condition.unshift({block_mapping:"influxdbproxy",action:"get_last_mosaic_list_by_item",keys:[s.originFv],object_id:h,items:1})),new Promise((b,x)=>{_n.platform(w=>{b(w.result)},u)})}getAction(e,n){if(e==="multiple"&&n==="mosaic")return Zf.multiple.mosaic;if(e==="single"&&n==="mosaic")return Zf.single.mosaic;if(e==="near"&&n==="statistics")return Zf.near.statistics;if(e==="near"&&n==="calculate")return Zf.near.calculate;switch(n){case"mosaic":case"index":case"deviation":case"stability":case"balance":case"increment":case"risk":return Zf.result.mosaic;case"statistics":case"calculate":return Zf.result.statistics;default:return"get_tools_mosaic_list"}}get_mosaic_item(e,n,r,i){let a={block_mapping:n==="single"?"mosaic":"influxdbproxy",action:n==="single"?"get_last_fv_by_objid":"get_last_mosaic_list_by_item",keys:[e.fv],object_id:e.object_id,items:r||1};return i==="evn"&&(a.keys=[e.fv,e.status_fv]),i==="cmc"&&(a.keys=[e.item_fv]),["ctrSwitch"].includes(i)&&(a.keys=[e.status_fv]),["progressBar","progressCircle"].includes(i)&&e.maxType==="fv"&&(a.keys=[e.fv,e.max]),a}get_mosaic_by_timespan(e,n,r){const i=Ct().unix(),a=i-r.value*Number(n);return{block_mapping:"influxdbproxy",action:"get_mosaic_list_with_time_span",start_time:Ct(a*1e3).format("YYYY-MM-DD HH:mm:ss"),end_time:Ct(i*1e3).format("YYYY-MM-DD HH:mm:ss"),time_span:r.value,time_swing:r.value,keys:[e.fv],object_id:e.object_id}}get_statistics_item(e,n,r){var i;return(i=e.periodUnit)!=null&&i.includes("near")?this.get_neardate_item(e,"statistics"):{now_time:Ct().format("YYYY-MM-DD HH:mm:ss"),change_number:e.periodValue||1,object_id:e.object_id,time_type:e.periodUnit||"hour",action:"get_statistics_list",script_uid:e.fv,length:Number(r)||1,block_mapping:"statistics"}}get_calculate_item(e,n,r){var a;if((a=e.periodUnit)!=null&&a.includes("near"))return this.get_neardate_item(e,"calculate");let i=this.get_statistics_item(e,n,r);return i.action="get_calculate_list",i}get_neardate_item(e,n){var r,i;return{block_mapping:"apim",action:`get_${n}_list`,script_uid:e.fv,object_id:e.object_id,end:Ct().format("YYYY-MM-DD HH:mm:ss"),time_type:((r=e.periodUnit)==null?void 0:r.split("near-")[1])||"hour",last:(i=e.periodValue)!=null?i:1}}get_index_item(e,n,r,i){const a=e.is_alias?"alias":"uid";return{page_index:1,page_size:r,block_mapping:"index",action:"get_index_result_list",where_and:[[a,"=",e.fv],["object_id","=",e.object_id]]}}get_deviation_item(e,n,r,i){return $e(ze({},this.get_index_item(e,n,r,i)),{block_mapping:"deviation",action:"get_deviation_result_list"})}get_stability_item(e,n,r,i){return $e(ze({},this.get_index_item(e,n,r,i)),{block_mapping:"stability",action:"get_stability_result_list"})}get_balance_item(e,n,r,i){return $e(ze({},this.get_index_item(e,n,r,i)),{block_mapping:"balance",action:"get_balance_result_list"})}get_increment_item(e,n,r,i){return $e(ze({},this.get_index_item(e,n,r,i)),{block_mapping:"increment",action:"get_increment_result_list"})}get_risk_item(e,n,r,i){return $e(ze({},this.get_index_item(e,n,r,i)),{block_mapping:"risk",action:"get_risk_result_list"})}get_summary_item(){return{block_mapping:"schema",action:"get_statistical_quantity"}}getRangeLineHistoryData(e){var c,u;const{conf:n,uid:r}=e,i=((u=(c=n==null?void 0:n.options)==null?void 0:c.points)==null?void 0:u.value)||100,a=n.common.source||"mosaic",o=JSON.parse(sessionStorage.getItem("object_alias_uid_mapping")||"{}"),s=n.data[0]||{};let l="";return n.useAlias?l=s.object_alias&&o[s.object_alias]||r:l=s.object_id||r,a==="deviation"?this.getDeviationHistory(n,l,i):this.getEigenHistory(n,l,i)}getDeviationHistory(e,n,r){const i=e.data[0]||{},a=i.is_alias?"alias":"uid",o={page_index:1,page_size:r,block_mapping:"deviation",action:"get_deviation_result_list",where_and:[["object_id","=",n]]};return i.fv&&o.where_and.unshift([a,"=",i.fv]),new Promise(s=>{_n.platform(l=>{s(this.formatDeviation(l.result))},o)})}getEigenHistory(e,n,r){return zt(this,null,function*(){const i={times:[],data:[],range:{}};(yield new Promise(s=>{const l={keys:[e.data[0].fv],object_id:n,page_index:1,page_size:r,block_mapping:"apim",action:"get_mosaic_list"};_n.platform(c=>{const u=c.result.data?c.result.data.sort((f,h)=>Ct(f.time).valueOf()-Ct(h.time).valueOf()):[];s(u)},l)})).forEach(s=>{var l;i.times.push(Ct(s.time).format("YYYY-MM-DD HH:mm:ss")),i.data.push((l=s[e.data[0].fv])!=null?l:"-")});const o={action:"get_adaps_report_list",block_mapping:"eigen",where_and:[["start",">=",i.times[0]],["end","<=",i.times[i.times.length-1]],["project_uid","=",e.data[0].project_id],["object_id","=",n]]};return new Promise(s=>{_n.platform(l=>{i.range=this.formatEigen(l.result.data,i.times),s(i)},o)})})}formatDeviation(e){const n={times:[],data:[],range:{}},r={};e.data.sort((a,o)=>Ct(a.created).valueOf()-Ct(o.created).valueOf()).forEach((a,o)=>{n.times.push(a.created),n.data.push(a.data.Dev),a.data.Base&&(r[a.data.Base]?r[a.data.Base].push([o,o]):r[a.data.Base]=[[o,o]])});for(const a in r){const o=[],s=r[a];if(s.length===0)continue;let l=[s[0]];for(let c=1;c<s.length;c++)s[c][0]-s[c-1][0]===1?l.push(s[c]):(o.push(l),l=[s[c]]);o.push(l),r[a]=o.map(c=>[c[0][0],c[c.length-1][0]])}return n.range=r,n}formatEigen(e,n){const r={};return e.sort((a,o)=>Ct(a.created).valueOf()-Ct(o.created).valueOf()).forEach(a=>{const o=JSON.parse(a.detail),s=[Ct(a.start).format("YYYY-MM-DD HH:mm:ss"),Ct(a.end).format("YYYY-MM-DD HH:mm:ss")];o.Main.forEach(l=>{var h;const c=(h=l.report)!=null&&h.start?[Ct(l.report[0].start.datetime).format("YYYY-MM-DD HH:mm:ss"),Ct(l.report[0].end.datetime).format("YYYY-MM-DD HH:mm:ss")]:s,u=n.indexOf(c[0]),f=n.indexOf(c[1]);u===-1||f===-1||(r[l.key_type]?r[l.key_type].push([u,f]):r[l.key_type]=[[u,f]])})}),r}getSwitchHistoryData(e){const{conf:n,uid:r}=e,{common:i}=n,a=gi(i,!!i.useAlias,r),o={block_mapping:"mosaic",action:"get_last_fv_by_objid",keys:[i.statusFv],object_id:a,items:1};return new Promise(s=>{_n.platform(l=>{s(l.result)},o)})}getRetainerHistoryData(e,n=1){return zt(this,null,function*(){const{conf:r,uid:i}=e,{data:a,common:o}=r,s=yield _n.getTokenForBackend(),l={block_mapping:"mixtask",action:"user_action",user_action:"get_retainer_result",args:{items:n,token:s,condition:[]}};return a.forEach(c=>{let u="";o.multiObject?u=gi(c,!!o.useAlias,i):u=gi(o,!!o.useAlias,i),l.args.condition.push({object_id:u||c.object_id,retainer:c.retainer||"",retainer_code:c.retainer_code||"",fv:c.fv||""})}),new Promise((c,u)=>{_n.platform(f=>{if(f.code===200&&f.result){const h=Array.isArray(f.result)?f.result[0]:f.result;c(h)}else u(f)},l)})})}getGridviewHistoryData(e){const{conf:n,uid:r}=e,{common:i,data:a}=n,o=i.source||"mosaic";let s="result";o==="mosaic"&&(s="single");const l={block_mapping:"mixtools",action:this.getAction(s,o),condition:[]};let c="";return i.multiObject||(c=gi(i,!!i.useAlias,r)),o==="summary"?(l.block_mapping="schema",l.action="get_statistical_quantity",delete l.condition):a.forEach(u=>{u.forEach(f=>{if(f.isValue){i.multiObject&&(c=gi({object_id:f.object,object_alias:f.object},!!i.useAlias,r)),f.object_id=c;const h=`get_${o}_item`;typeof this[h]=="function"&&l.condition.push(this[h](f,s,1,""))}})}),new Promise(u=>{_n.platform(f=>{u(f.result)},l)})}}const tL=Object.freeze(Object.defineProperty({__proto__:null,default:Kat},Symbol.toStringTag,{value:"Module"}));exports.DesignApp=$P;exports.DesignPro=QP;exports.DesignShow=KP;exports.configureAuth=Aee;exports.default=qat;exports.getAuthToken=Tee;exports.getWsUrl=Cee;
|
|
8855
|
+
`,kat=["id","data-theme"],zat={key:0,class:"canvas"},Bat={class:"modal-content"},Hat={key:0,class:"modal-sticky-area"},Vat=["title"],Fat={key:0,xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},Uat={key:1,xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},jat=["onClick"],Gat=d.defineComponent({name:"MixBasePreview",__name:"BasePreview",props:{script:{},uid:{},enableWebSocket:{type:Boolean,default:!0}},setup(t){const e=t;let n=d.reactive({margin:[10,10],height:40});const r=d.ref({sheets:[]}),i={pro:"ProContainer",show:"ShowContainer",app:"AppContainer"},a=d.ref(0),o=d.computed(()=>r.value.sheets[a.value]),s=d.computed(()=>{var Ne;return(((Ne=r.value)==null?void 0:Ne.sheets)||[]).map((Ze,Qe)=>({s:Ze,idx:Qe})).filter(({s:Ze})=>!(Ze!=null&&Ze.hideInPreviewTabs)).map(({idx:Ze})=>Ze)}),l=d.computed(()=>s.value.map(Pe=>r.value.sheets[Pe])),c=d.ref("light"),u=d.ref(!0),f=()=>{c.value=_ee.toggleTheme(),h(c.value)},h=Pe=>{const Ne=document.documentElement;Pe==="dark"?(Ne.setAttribute("data-theme","dark"),Ne.classList.add("dark")):(Ne.setAttribute("data-theme","light"),Ne.classList.remove("dark"))},p=Pe=>{const{theme:Ne}=Pe.detail;c.value=Ne,h(Ne)},v=d.ref(!0);let m=null;const y=d.computed(()=>localStorage.getItem("dashboardTabDisplayMode")||"auto"),g=()=>{y.value==="auto"&&(m&&clearTimeout(m),m=setTimeout(()=>{v.value=!1},3e3))},b=()=>{m&&(clearTimeout(m),m=null),v.value=!0},x=Pe=>{var Ze,Qe;const Ne=(Qe=(Ze=r.value)==null?void 0:Ze.sheets)==null?void 0:Qe[Pe];return(Ne==null?void 0:Ne.tabStyle)||{bgColor:"transparent",activeBgColor:"transparent",textColor:"#666666",activeTextColor:"#333333",fontSize:14,height:40,borderRadius:0}},w=d.computed(()=>x(a.value)),C=d.computed(()=>({height:`${w.value.height}px`})),S=Pe=>{const Ne=a.value===Pe,Ze=x(Pe);return{backgroundColor:Ne?Ze.activeBgColor:Ze.bgColor,color:Ne?Ze.activeTextColor:Ze.textColor,fontSize:`${Ze.fontSize}px`,height:`${Ze.height-8}px`,lineHeight:`${Ze.height-8}px`,borderRadius:`${Ze.borderRadius}px`}},A=d.computed(()=>{var Ne;const Pe=[...((Ne=o.value)==null?void 0:Ne.layers)||[]].sort((Ze,Qe)=>Ze.order-Qe.order);return T.value?Pe.filter(Ze=>Ze.id!==T.value):Pe});d.computed(()=>{var Pe;return[...((Pe=o.value)==null?void 0:Pe.layers)||[]].sort((Ne,Ze)=>Ne.order-Ze.order)});const T=d.ref(null),E=d.ref([]),M=d.ref(null),D=d.ref(null),O=d.ref([]),N=d.ref(null),I=d.computed(()=>D.value!==null&&D.value!==void 0?"sheet":E.value.length?"page":(T.value,"layer")),R=d.computed(()=>!!T.value||E.value.length>0||D.value!==null&&D.value!==void 0),B=d.computed(()=>{var Pe;return T.value&&(((Pe=o.value)==null?void 0:Pe.layers)||[]).find(Ne=>Ne.id===T.value)||null}),F=Pe=>{var Ze,Qe;const Ne=Number(Pe);return!Number.isFinite(Ne)||Ne<0?null:((Qe=(Ze=r.value)==null?void 0:Ze.sheets)==null?void 0:Qe[Ne])||null},V=(Pe,Ne)=>{if(!Array.isArray(Pe)||!Array.isArray(Ne)||!Ne.length)return[];const Ze=new Map(Pe.map(Qe=>[Qe.id,Qe]));return Ne.map(Qe=>Ze.get(Qe)).filter(Boolean)},j=d.computed(()=>{var Ze;const Pe=E.value||[];if(!Pe.length)return[];const Ne=new Map((((Ze=o.value)==null?void 0:Ze.layers)||[]).map(Qe=>[Qe.id,Qe]));return Pe.map(Qe=>Ne.get(Qe)).filter(Boolean).sort((Qe,Zt)=>{var we,Ge;return((we=Qe.order)!=null?we:0)-((Ge=Zt.order)!=null?Ge:0)})}),X=d.computed(()=>D.value===null||D.value===void 0?null:F(D.value)),W=d.computed(()=>{var Ne;return(((Ne=X.value)==null?void 0:Ne.layers)||[]).find(Ze=>!!Ze.isSticky)||null}),J=d.computed(()=>{var Qe,Zt;const Pe=((Qe=X.value)==null?void 0:Qe.layers)||[],Ne=(Zt=W.value)==null?void 0:Zt.id;let Ze=Pe.filter(we=>we.id!==Ne);return Array.isArray(O.value)&&O.value.length&&(Ze=V(Ze,O.value)),[...Ze].sort((we,Ge)=>{var Ue,Ve;return((Ue=we.order)!=null?Ue:0)-((Ve=Ge.order)!=null?Ve:0)})}),$=d.computed(()=>{var Pe,Ne,Ze,Qe,Zt,we;if(D.value!==null&&D.value!==void 0){const Ge=N.value||((Ne=(Pe=J.value)==null?void 0:Pe[0])==null?void 0:Ne.id);return Ge&&(((Ze=X.value)==null?void 0:Ze.layers)||[]).find(Ue=>Ue.id===Ge)||null}if(E.value.length){const Ge=M.value||((Zt=(Qe=j.value)==null?void 0:Qe[0])==null?void 0:Zt.id);return Ge&&(((we=o.value)==null?void 0:we.layers)||[]).find(Ue=>Ue.id===Ge)||null}return B.value}),q=()=>{D.value=null,O.value=[],N.value=null},re=()=>{E.value=[],M.value=null},Q=()=>{T.value=null,re(),q()},ce=Pe=>{var Zt,we;Q();const Ne={width:Pe==null?void 0:Pe.width,height:Pe==null?void 0:Pe.height};Ne&&(Ne.width||Ne.height)?se.value={width:(Zt=Ne.width)!=null?Zt:se.value.width,height:(we=Ne.height)!=null?we:se.value.height}:se.value={width:80,height:80};const Ze=Pe==null?void 0:Pe.sheetIndex,Qe=()=>{var Ue;const Ge=(Pe==null?void 0:Pe.targetType)||"layer";if(Ge==="page"){const Ve=Array.isArray(Pe==null?void 0:Pe.pageLayerIds)?Pe.pageLayerIds:[];E.value=Ve,M.value=(Ve==null?void 0:Ve[0])||null;return}if(Ge==="sheet"){D.value=(Ue=Pe==null?void 0:Pe.targetSheetIndex)!=null?Ue:null,O.value=Array.isArray(Pe==null?void 0:Pe.sheetLayerIds)?Pe.sheetLayerIds:[],N.value=null;return}re(),q(),T.value=(Pe==null?void 0:Pe.layerId)||null};if(Ze===-1||Ze===void 0||Ze===null){Qe();return}if(typeof Ze=="number"&&Ze>=0&&Ze!==a.value){a.value=Ze,d.nextTick(()=>{Qe()});return}Qe()},ae=()=>{Q()},ee=Pe=>{if(((Pe==null?void 0:Pe.targetType)||"layer")==="page"){const Qe=Array.isArray(Pe==null?void 0:Pe.pageLayerIds)?Pe.pageLayerIds:[];if(E.value.length===Qe.length&&E.value.every((we,Ge)=>we===Qe[Ge])){ae();return}ce(Pe);return}const Ze=Pe==null?void 0:Pe.layerId;if(Ze){if(T.value===Ze){ae();return}ce(Pe)}},he=(Pe,Ne)=>{const Ze=Pe==null?void 0:Pe.modalBinding;if(Ze&&Ze.enabled){if((Ze.triggerEvent||"click")!==Ne||(Ze.triggerMode||"direct")==="linkhub")return;switch((Ze==null?void 0:Ze.action)||"show"){case"show":ce(Ze);break;case"hide":ae();break;default:ee(Ze);break}return}},se=d.ref({width:80,height:80}),ve=Pe=>{const Ne=Number(se.value.width)||80,Ze=Number(se.value.height)||80;return{width:`${Ne}%`,height:`${Ze}%`,maxWidth:"100%",maxHeight:"100%"}},xe=Pe=>{var Ne;if(!((Ne=o.value)!=null&&Ne.layers))return!1;for(const Ze of o.value.layers)for(const Qe of Ze.components)if(Qe.type==="glbModel"&&Qe.data&&Array.isArray(Qe.data)){for(const Zt of Qe.data)if(Zt.targetComponentId===Pe)return!0}return!1},fe=d.ref({});let Be={},je=null;if(e.enableWebSocket)try{const Pe=new Blob([Rat],{type:"application/javascript"}),Ne=URL.createObjectURL(Pe);je=new SharedWorker(Ne),console.log("✅ [BasePreview] SharedWorker 已创建 (Blob 模式)")}catch(Pe){console.warn("⚠️ [BasePreview] SharedWorker 创建失败:",Pe)}const rt=new Iat;d.ref(!1),je&&(rt.init(je),je.port.onmessage=Pe=>{rt.processWorkerMessage(Pe)});const oe=()=>zt(null,null,function*(){try{const{getAuthToken:Pe,getWsUrl:Ne}=yield Promise.resolve().then(()=>Wat),Ze=yield Pe(),Qe=Ne();je&&(je.port.postMessage({type:"init_connection",url:Qe,token:Ze}),console.log("[Data] 数据连接已初始化, WebSocket URL:",Qe))}catch(Pe){console.error("[Data] 初始化失败:",Pe),At.ElMessage.error("数据连接初始化失败")}}),ye=Pe=>({x:Pe.x,y:Pe.y,w:Pe.w,h:Pe.h,i:Pe.i}),Ce=()=>{let Pe=1920,Ne=o.value.col||20;if(r.value.type==="pro"&&(Pe=document.body.offsetWidth-400-16-(Ne+1)*n.margin[0],n.height=Math.round(Pe/Ne)),r.value.type==="show"){let Ze=o.value.screenHeight;document.querySelector("#ShowContainer")&&(Ze=Ze-(Ne+1)*n.margin[0]),n.height=Ze/Ne}},le=Pe=>Pe?Pe.startsWith("#")||Pe.startsWith("rgb")||Pe.startsWith("rgba")?Pe:`url(${ie(Pe)})`:"",ie=Pe=>{if(Pe=="defaultBg1"&&(Pe=Oat),Pe=="defaultBg2"&&(Pe=Nat),Pe)return Pe},Ae=Pe=>(Pe&&Pe.dashboard&&Array.isArray(Pe.dashboard)&&Pe.dashboard.length>0&&(Pe=Pe.dashboard[0]),!Pe||!Pe.sheets?{sheets:[],type:""}:(Pe.sheets.forEach(Ne=>{if(!Ne.layers&&Ne.components){const Qe={id:WT("layer"),name:"图层 1",visible:!0,opacity:100,order:0,locked:!1,components:Ne.components||[]};Ne.layers=[Qe],Ne.activeLayerId=Qe.id,delete Ne.components}Ne.layers.forEach(Ze=>{Ze.components.forEach(Qe=>{var Ue;const{type:Zt}=Qe;let we=JSON.parse(JSON.stringify(Be[Qe.type].OPTIONS)),Ge=JSON.parse(JSON.stringify(Be[Qe.type].DATA));for(let Ve in we){const Lt=we[Ve]&&typeof we[Ve]=="object"&&"value"in we[Ve],_t=(Ue=Qe.options)==null?void 0:Ue[Ve],sn=_t&&typeof _t=="object"&&"value"in _t?_t.value:_t;Lt?we[Ve].value=sn!=null?sn:we[Ve].value:we[Ve]=sn!=null?sn:we[Ve]}Array.isArray(Qe.data)&&Qe.data.length&&(Qe.data=Qe.data.map((Ve,Lt)=>(Zt==="gridview"?Ve=Ve.map((_t,sn)=>(_t=Object.assign({},Ge[0][0],_t),_t)):Ve=Object.assign({},Ge[0],Ve),Ve))),Qe.options=we,Qe.source=Be[Qe.type].SOURCE||[],Qe.params=Be[Qe.type].PARAMS||[],Qe.common=Object.assign({},Be[Qe.type].COMMON,Qe.common)})})}),Pe)),He=()=>zt(null,null,function*(){var Pe;try{const Ne=yield _n.post("get_object_list",{select:["name","uid","alias"]});if((Ne==null?void 0:Ne.code)!==200||!((Pe=Ne==null?void 0:Ne.result)!=null&&Pe.data))return console.warn("获取对象别名失败:",(Ne==null?void 0:Ne.msg)||Ne),{};let Ze={};return Ne.result.data.forEach(Qe=>{Ze[Qe.alias]=Qe.uid}),Ze}catch(Ne){return console.error("获取对象别名异常:",Ne),{}}}),_e=Pe=>{a.value=Pe,d.nextTick(()=>{y.value==="auto"?(m&&clearTimeout(m),m=setTimeout(()=>{v.value=!1},3e3)):y.value==="show"&&(m&&(clearTimeout(m),m=null),v.value=!0)})},Ee=()=>{const{screenHeight:Pe,screenWidth:Ne}=o.value;let Ze=document.documentElement,Qe=document.getElementById("ShowContainer"),Zt=Ze.clientWidth,we=Ze.clientHeight,Ge=we/Pe,Ue=Zt/Ne,Ve=Ue>Ge?Ge:Ue,Lt=Zt/2-Ne*Ve/2,_t=we/2-Pe*Ve/2;Qe.style.width=Ne+"px",Qe.style.height=Pe+"px",Qe.style.transform=`scale(${Ve}, ${Ve}) translate(${Lt/Ve}px, ${_t/Ve}px)`},ut=Pe=>{Pe.key==="Escape"&&window.close()},lt=Pe=>{const Ne=(Pe==null?void 0:Pe.detail)||{},Ze=Ne.action||"show",Qe=Ne.layerId;if(Ne.sheetIndex,Ne.size,!(!Qe&&Ze!=="hide")){if(Ze==="hide"){ae();return}if(Ze==="toggle"){ee(Ne);return}ce(Ne)}},dt=Ra(),tn=()=>{var Ze;const Pe=[];return(((Ze=r.value)==null?void 0:Ze.sheets)||[]).forEach((Qe,Zt)=>{var we;(we=Qe.layers)==null||we.forEach(Ge=>{var Ue;(Ue=Ge.components)==null||Ue.forEach(Ve=>{var _t,sn,mr,Vr;const Lt=Ve==null?void 0:Ve.modalBinding;if(Lt&&Lt.enabled&&Lt.triggerMode==="linkhub"){const Zn=((sn=(_t=Ve==null?void 0:Ve.options)==null?void 0:_t.linkChannel)==null?void 0:sn.value)||"",Gr=((Vr=(mr=Ve==null?void 0:Ve.options)==null?void 0:mr.customChannel)==null?void 0:Vr.value)||"",Zi=Zn==="custom"&&Gr?Gr:Zn;console.log("[LinkHub Modal] 找到 linkhub 模式组件:",{componentId:Ve==null?void 0:Ve.id,linkChannelValue:Zn,customChannelValue:Gr,linkChannel:Zi,binding:Lt}),Zi&&Pe.push({binding:Lt,linkChannel:Zi,component:Ve,sheetIndex:Zt,layerId:Ge.id})}})})}),console.log("[LinkHub Modal] 所有 linkhub 绑定:",Pe),Pe},at=(Pe,Ne)=>{if(console.log("[LinkHub Modal] 收到事件:",{channel:Pe,event:Ne}),!Ne||!Ne.topic){console.log("[LinkHub Modal] 事件无效,跳过");return}const Ze=tn();console.log("[LinkHub Modal] 所有绑定:",Ze);const Qe=Ze.filter(Ue=>Ue.linkChannel===Pe);if(console.log("[LinkHub Modal] 匹配的绑定:",Qe,"频道:",Pe),Qe.length===0){console.log("[LinkHub Modal] 没有匹配的绑定,跳过");return}const we=Qe[0].binding;console.log("[LinkHub Modal] 使用绑定:",we);const Ge=(we==null?void 0:we.action)||"show";if(Ge==="hide"){console.log("[LinkHub Modal] 执行 hide 操作"),ae();return}if(Ge==="show"){const Ue=(we==null?void 0:we.targetType)||"layer";if(Ue==="sheet"){const Ve=we==null?void 0:we.targetSheetIndex;if(D.value===Ve){console.log("[LinkHub Modal] 弹窗已打开,跳过");return}}else if(Ue==="layer"){const Ve=we==null?void 0:we.layerId;if(T.value===Ve){console.log("[LinkHub Modal] 弹窗已打开,跳过");return}}console.log("[LinkHub Modal] 执行 show 操作,打开弹窗"),ce(we);return}if(Ge==="toggle"){console.log("[LinkHub Modal] 执行 toggle 操作"),ee(we);return}};let yt=null;const Yt=new Set;return d.onMounted(()=>zt(null,null,function*(){window.addEventListener("keydown",ut),window.addEventListener("mix-modal",lt);const Pe=localStorage.getItem("dashboardDefaultTheme")||"light";u.value=localStorage.getItem("dashboardShowThemeToggle")!=="false",Pe==="auto"?c.value=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":c.value=Pe,h(c.value),window.addEventListener("mix-dashboard-theme-change",p),yield oe();const Ne=yield He();sessionStorage.setItem("object_alias_uid_mapping",JSON.stringify(Ne)),fe.value=yield J5.loadComponents(),Be=yield J5.getAllExposedProps(),e.script&&(r.value=Ae(e.script)),window.__mix_preview_params=r.value,yt=d.watch(()=>dt.channels,(Ze,Qe)=>{!r.value||!r.value.sheets||r.value.sheets.length===0||Object.keys(Ze).forEach(Zt=>{const we=Ze[Zt];if(!we||!we.topic)return;const Ge=we.topic.uniqueId;Yt.has(Ge)||(Yt.add(Ge),console.log("[LinkHub Modal] 检测到新事件:",{channel:Zt,newEventId:Ge,event:JSON.parse(JSON.stringify(we))}),at(Zt,we))})},{deep:!0,immediate:!1}),d.nextTick(()=>{Ce(),y.value==="auto"?m=setTimeout(()=>{v.value=!1},3e3):y.value==="show"&&(v.value=!0)}),r.value.type==="show"&&(d.nextTick(()=>{Ee(),document.title="预览"}),window.onresize=()=>{Ee()})})),d.onUnmounted(()=>{window.removeEventListener("keydown",ut),m&&(clearTimeout(m),m=null),window.removeEventListener("mix-dashboard-theme-change",p),yt&&(yt(),yt=null),rt&&rt.close(),sessionStorage.removeItem("object_alias_uid_mapping")}),d.provide("sharedWorker",je),d.provide("session",rt),d.provide("switchSheet",Pe=>{Pe>=0&&Pe<r.value.sheets.length&&(a.value=Pe)}),d.provide("getSheets",()=>r.value.sheets),d.provide("getCurrentSheet",()=>a.value),(Pe,Ne)=>{var Ze,Qe,Zt;return r.value.sheets.length>0?(d.openBlock(),d.createElementBlock("div",{key:0,id:i[r.value.type],class:"w-[100%] h-[100%]","data-theme":c.value},[d.createElementVNode("div",{class:"layout",style:d.normalizeStyle({background:le((Ze=o.value)==null?void 0:Ze.background)})},[o.value?(d.openBlock(),d.createElementBlock("div",zat,[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(A.value,we=>(d.openBlock(),d.createElementBlock("div",{key:we.id,class:"layer-container",style:d.normalizeStyle({opacity:we.opacity/100,pointerEvents:"none"})},[d.withDirectives(d.createVNode(d.unref(G8),{layout:we.components,"onUpdate:layout":Ge=>we.components=Ge,"col-num":o.value.col,"row-height":d.unref(n).height,margin:d.unref(n).margin,"is-draggable":!1,"is-resizable":!1,"is-mirrored":!1,"vertical-compact":!1,"use-css-transforms":!0},{default:d.withCtx(()=>[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(we.components,Ge=>(d.openBlock(),d.createBlock(d.unref(rd),d.mergeProps({key:Ge.i},{ref_for:!0},ye(Ge),{"data-id":Ge.id,style:{pointerEvents:"auto",visibility:xe(Ge.id)?"hidden":"visible"},onClick:Ue=>he(Ge,"click"),onDblclick:Ue=>he(Ge,"dblclick")}),{default:d.withCtx(()=>[fe.value[Ge.type]?(d.openBlock(),d.createBlock(d.resolveDynamicComponent(fe.value[Ge.type]),{key:0,conf:Ge,theme:c.value,mode:"preview"},null,8,["conf","theme"])):d.createCommentVNode("",!0)]),_:2},1040,["data-id","style","onClick","onDblclick"]))),128))]),_:2},1032,["layout","onUpdate:layout","col-num","row-height","margin"]),[[d.vShow,we.visible]])],4))),128))])):d.createCommentVNode("",!0)],4),R.value?(d.openBlock(),d.createElementBlock("div",{key:0,class:"modal-overlay",onClick:d.withModifiers(ae,["self"])},[d.createElementVNode("div",{class:"modal-container",style:d.normalizeStyle(ve(B.value))},[d.createElementVNode("button",{class:"modal-close-btn",onClick:ae,title:"关闭"},[...Ne[0]||(Ne[0]=[d.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[d.createElementVNode("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),d.createElementVNode("line",{x1:"6",y1:"6",x2:"18",y2:"18"})],-1)])]),d.createElementVNode("div",Bat,[I.value==="sheet"&&W.value?(d.openBlock(),d.createElementBlock("div",Hat,[d.createVNode(d.unref(G8),{layout:W.value.components,"col-num":((Qe=X.value)==null?void 0:Qe.col)||o.value.col,"row-height":d.unref(n).height,margin:d.unref(n).margin,"is-draggable":!1,"is-resizable":!1,"is-mirrored":!1,"vertical-compact":!1,"use-css-transforms":!0},{default:d.withCtx(()=>[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(W.value.components||[],we=>(d.openBlock(),d.createBlock(d.unref(rd),d.mergeProps({key:we.i},{ref_for:!0},ye(we),{"data-id":we.id,style:{pointerEvents:"auto"}}),{default:d.withCtx(()=>[fe.value[we.type]?(d.openBlock(),d.createBlock(d.resolveDynamicComponent(fe.value[we.type]),{key:0,conf:we,theme:c.value,mode:"preview"},null,8,["conf","theme"])):d.createCommentVNode("",!0)]),_:2},1040,["data-id"]))),128))]),_:1},8,["layout","col-num","row-height","margin"])])):d.createCommentVNode("",!0),I.value==="sheet"&&X.value?(d.openBlock(!0),d.createElementBlock(d.Fragment,{key:1},d.renderList((X.value.layers||[]).filter(we=>we.visible&&!we.isSticky),we=>(d.openBlock(),d.createElementBlock("div",{key:we.id,class:"layer-container",style:d.normalizeStyle({opacity:we.opacity/100,pointerEvents:"none"})},[d.createVNode(d.unref(G8),{layout:we.components,"onUpdate:layout":Ge=>we.components=Ge,"col-num":X.value.col||o.value.col,"row-height":d.unref(n).height,margin:d.unref(n).margin,"is-draggable":!1,"is-resizable":!1,"is-mirrored":!1,"vertical-compact":!1,"use-css-transforms":!0},{default:d.withCtx(()=>[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(we.components,Ge=>(d.openBlock(),d.createBlock(d.unref(rd),d.mergeProps({key:Ge.i},{ref_for:!0},ye(Ge),{"data-id":Ge.id,style:{pointerEvents:"auto"}}),{default:d.withCtx(()=>[fe.value[Ge.type]?(d.openBlock(),d.createBlock(d.resolveDynamicComponent(fe.value[Ge.type]),{key:0,conf:Ge,theme:c.value,mode:"preview"},null,8,["conf","theme"])):d.createCommentVNode("",!0)]),_:2},1040,["data-id"]))),128))]),_:2},1032,["layout","onUpdate:layout","col-num","row-height","margin"])],4))),128)):(d.openBlock(),d.createBlock(d.unref(G8),{key:2,layout:(Zt=$.value)==null?void 0:Zt.components,"col-num":o.value.col,"row-height":d.unref(n).height,margin:d.unref(n).margin,"is-draggable":!1,"is-resizable":!1,"is-mirrored":!1,"vertical-compact":!1,"use-css-transforms":!0},{default:d.withCtx(()=>{var we;return[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(((we=$.value)==null?void 0:we.components)||[],Ge=>(d.openBlock(),d.createBlock(d.unref(rd),d.mergeProps({key:Ge.i},{ref_for:!0},ye(Ge),{"data-id":Ge.id,style:{pointerEvents:"auto"}}),{default:d.withCtx(()=>[fe.value[Ge.type]?(d.openBlock(),d.createBlock(d.resolveDynamicComponent(fe.value[Ge.type]),{key:0,conf:Ge,theme:c.value,mode:"preview"},null,8,["conf","theme"])):d.createCommentVNode("",!0)]),_:2},1040,["data-id"]))),128))]}),_:1},8,["layout","col-num","row-height","margin"]))])],4)])):d.createCommentVNode("",!0),u.value?(d.openBlock(),d.createElementBlock("div",{key:1,class:"theme-toggle-btn",onClick:f,title:c.value==="light"?"切换到暗色模式":"切换到亮色模式"},[c.value==="light"?(d.openBlock(),d.createElementBlock("svg",Fat,[...Ne[1]||(Ne[1]=[d.createElementVNode("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"},null,-1)])])):(d.openBlock(),d.createElementBlock("svg",Uat,[...Ne[2]||(Ne[2]=[d.createStaticVNode('<circle cx="12" cy="12" r="5" data-v-65516e38></circle><line x1="12" y1="1" x2="12" y2="3" data-v-65516e38></line><line x1="12" y1="21" x2="12" y2="23" data-v-65516e38></line><line x1="4.22" y1="4.22" x2="5.64" y2="5.64" data-v-65516e38></line><line x1="18.36" y1="18.36" x2="19.78" y2="19.78" data-v-65516e38></line><line x1="1" y1="12" x2="3" y2="12" data-v-65516e38></line><line x1="21" y1="12" x2="23" y2="12" data-v-65516e38></line><line x1="4.22" y1="19.78" x2="5.64" y2="18.36" data-v-65516e38></line><line x1="18.36" y1="5.64" x2="19.78" y2="4.22" data-v-65516e38></line>',9)])]))],8,Vat)):d.createCommentVNode("",!0),l.value.length>1&&y.value!=="hide"?(d.openBlock(),d.createElementBlock("div",{key:2,class:"sheet-trigger-area",onMouseenter:b},null,32)):d.createCommentVNode("",!0),l.value.length>1&&y.value!=="hide"?(d.openBlock(),d.createElementBlock("div",{key:3,class:d.normalizeClass(["sheet-wrap",{"is-visible":y.value==="show"||v.value}]),style:d.normalizeStyle(C.value),onMouseenter:b,onMouseleave:g},[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(l.value,(we,Ge)=>(d.openBlock(),d.createElementBlock("div",{key:we.id||Ge,class:d.normalizeClass(["sheet-item",{active:a.value===s.value[Ge]}]),style:d.normalizeStyle(S(s.value[Ge])),onClick:Ue=>_e(s.value[Ge])},d.toDisplayString(we.caption||we.name),15,jat))),128))],38)):d.createCommentVNode("",!0)],8,kat)):d.createCommentVNode("",!0)}}}),JP=St(Gat,[["__scopeId","data-v-65516e38"]]),KP=d.defineComponent({name:"MixDesignShow",__name:"DesignShow",props:{script:{},uid:{},enableWebSocket:{type:Boolean,default:!0}},setup(t){const e=t;return(n,r)=>(d.openBlock(),d.createBlock(JP,{script:e.script,uid:e.uid,enableWebSocket:e.enableWebSocket},null,8,["script","uid","enableWebSocket"]))}}),QP=d.defineComponent({name:"MixDesignPro",__name:"DesignPro",props:{script:{},uid:{},enableWebSocket:{type:Boolean,default:!0}},setup(t){const e=t;return(n,r)=>(d.openBlock(),d.createBlock(JP,{script:e.script,uid:e.uid,enableWebSocket:e.enableWebSocket},null,8,["script","uid","enableWebSocket"]))}}),$P=d.defineComponent({name:"MixDesignApp",__name:"DesignApp",props:{script:{},uid:{},enableWebSocket:{type:Boolean,default:!0}},setup(t){const e=t;return(n,r)=>(d.openBlock(),d.createBlock(JP,{script:e.script,uid:e.uid,enableWebSocket:e.enableWebSocket},null,8,["script","uid","enableWebSocket"]))}}),eL={url:"/apiproxy/api",appId:"AUP6255392800002",appSecret:"ac8fe574-c067-4cd2-0edf-5b5d9e6593e6",wsUrl:"wss://mixuis.mixyun.top/apiproxy/ws/api"};let ul=ze({},eL),E5="",MC=0;function Aee(t){ul=ze(ze({},ul),t),t.url&&!t.wsUrl&&(ul.wsUrl=Xat(t.url)),E5="",MC=0,console.log("[Auth] 配置已更新",ul)}function Xat(t){try{let e=t.replace("/apiproxy/api","/apiproxy/ws/api");return e.startsWith("https://")?e=e.replace("https://","wss://"):e.startsWith("http://")&&(e=e.replace("http://","ws://")),e}catch(e){return console.error("[Auth] WebSocket URL 推导失败:",e),ul.wsUrl||eL.wsUrl}}function Cee(){return ul.wsUrl||eL.wsUrl}function Tee(){return zt(this,null,function*(){var e,n,r,i;const t=Date.now();if(console.log("[Auth] 当前配置:",ul),E5&&MC>t+3e5)return E5;try{const a=yield ci.post(ul.url,{action:"get_access_token",app_id:ul.appId,app_secret:ul.appSecret});if(((e=a.data)==null?void 0:e.code)===200&&((r=(n=a.data)==null?void 0:n.result)!=null&&r.access_token)){E5=a.data.result.access_token;const o=a.data.result.expires_in||7200;return MC=t+o*1e3,console.log("[Auth] Token 获取成功"),E5}else{const o=((i=a.data)==null?void 0:i.msg)||"未知错误";throw new Error(`Token 获取失败: ${o}`)}}catch(a){throw console.error("[Auth] Token 获取异常:",a),a}})}const Wat=Object.freeze(Object.defineProperty({__proto__:null,configureAuth:Aee,getAuthToken:Tee,getWsUrl:Cee},Symbol.toStringTag,{value:"Module"})),Yat=[KP,QP,$P],Zat=function(t){Yat.forEach(e=>{t.component(e.name||e.__name,e)})},qat={install:Zat,DesignShow:KP,DesignPro:QP,DesignApp:$P},Zf={multiple:{mosaic:"get_tools_mosaic_list"},single:{mosaic:"get_memory_mosaic_values"},result:{mosaic:"get_tools_mosaic_list",statistics:"get_tools_statistics_list"},near:{statistics:"get_tools_last_statistics_list",calculate:"get_tools_last_statistics_list"}},Jat=["crd","vlu","arrayCard"];class Kat{constructor(){}getHistoryData(e,n){var p,v,m,y,g;if(n==="retainer1")return this.getRetainerHistoryData(e,1);if(n==="retainer2")return this.getRetainerHistoryData(e,4);let r="result";const{conf:i,uid:a}=e,{data:o,common:s,options:l}=i,c=s.source||"mosaic";c==="mosaic"&&(r=Jat.includes(n)?"single":"multiple"),["statistics","calculate"].includes(c)&&(o.filter(x=>{var w;return(w=x.periodUnit)==null?void 0:w.includes("near")}).length&&["bar","lin"].includes(n)?r="near":r="result");const u={block_mapping:"mixtools",action:this.getAction(r,c),condition:[]};let f=((p=l.points)==null?void 0:p.value)||1,h="";if(s.multiObject||(h=gi(s,!!s.useAlias,a)),s.source==="summary"?(u.block_mapping="schema",u.action="get_statistical_quantity",delete u.condition):o.forEach(b=>{var x;if(s.multiObject&&(h=gi(b,!!s.useAlias,a)),b.object_id=h||b.object_id,(x=s==null?void 0:s.rate)!=null&&x.checked)u.condition.push(this.get_mosaic_by_timespan(b,f,s.rate));else{const w=`get_${c}_item`;typeof this[w]=="function"&&u.condition.push(this[w](b,r,f,n))}}),n==="scd"&&((v=l.multipleImg)!=null&&v.value)){const b=JSON.parse(sessionStorage.getItem(w0)||"{}");h=((m=l.object)==null?void 0:m.value)||"",s.useAlias&&((y=l.object)!=null&&y.value)&&(h=b[l.object.value]||l.object.value),u.condition.push({block_mapping:"influxdbproxy",action:"get_last_mosaic_list_by_item",keys:[(g=l.statusFv)==null?void 0:g.value],object_id:h||a,items:1})}return n==="sankey"&&(s.multiObject&&(h=gi(s,!!s.useAlias,a)),u.condition.unshift({block_mapping:"influxdbproxy",action:"get_last_mosaic_list_by_item",keys:[s.originFv],object_id:h,items:1})),new Promise((b,x)=>{_n.platform(w=>{b(w.result)},u)})}getAction(e,n){if(e==="multiple"&&n==="mosaic")return Zf.multiple.mosaic;if(e==="single"&&n==="mosaic")return Zf.single.mosaic;if(e==="near"&&n==="statistics")return Zf.near.statistics;if(e==="near"&&n==="calculate")return Zf.near.calculate;switch(n){case"mosaic":case"index":case"deviation":case"stability":case"balance":case"increment":case"risk":return Zf.result.mosaic;case"statistics":case"calculate":return Zf.result.statistics;default:return"get_tools_mosaic_list"}}get_mosaic_item(e,n,r,i){let a={block_mapping:n==="single"?"mosaic":"influxdbproxy",action:n==="single"?"get_last_fv_by_objid":"get_last_mosaic_list_by_item",keys:[e.fv],object_id:e.object_id,items:r||1};return i==="evn"&&(a.keys=[e.fv,e.status_fv]),i==="cmc"&&(a.keys=[e.item_fv]),["ctrSwitch"].includes(i)&&(a.keys=[e.status_fv]),["progressBar","progressCircle"].includes(i)&&e.maxType==="fv"&&(a.keys=[e.fv,e.max]),a}get_mosaic_by_timespan(e,n,r){const i=Ct().unix(),a=i-r.value*Number(n);return{block_mapping:"influxdbproxy",action:"get_mosaic_list_with_time_span",start_time:Ct(a*1e3).format("YYYY-MM-DD HH:mm:ss"),end_time:Ct(i*1e3).format("YYYY-MM-DD HH:mm:ss"),time_span:r.value,time_swing:r.value,keys:[e.fv],object_id:e.object_id}}get_statistics_item(e,n,r){var i;return(i=e.periodUnit)!=null&&i.includes("near")?this.get_neardate_item(e,"statistics"):{now_time:Ct().format("YYYY-MM-DD HH:mm:ss"),change_number:e.periodValue||1,object_id:e.object_id,time_type:e.periodUnit||"hour",action:"get_statistics_list",script_uid:e.fv,length:Number(r)||1,block_mapping:"statistics"}}get_calculate_item(e,n,r){var a;if((a=e.periodUnit)!=null&&a.includes("near"))return this.get_neardate_item(e,"calculate");let i=this.get_statistics_item(e,n,r);return i.action="get_calculate_list",i}get_neardate_item(e,n){var r,i;return{block_mapping:"apim",action:`get_${n}_list`,script_uid:e.fv,object_id:e.object_id,end:Ct().format("YYYY-MM-DD HH:mm:ss"),time_type:((r=e.periodUnit)==null?void 0:r.split("near-")[1])||"hour",last:(i=e.periodValue)!=null?i:1}}get_index_item(e,n,r,i){const a=e.is_alias?"alias":"uid";return{page_index:1,page_size:r,block_mapping:"index",action:"get_index_result_list",where_and:[[a,"=",e.fv],["object_id","=",e.object_id]]}}get_deviation_item(e,n,r,i){return $e(ze({},this.get_index_item(e,n,r,i)),{block_mapping:"deviation",action:"get_deviation_result_list"})}get_stability_item(e,n,r,i){return $e(ze({},this.get_index_item(e,n,r,i)),{block_mapping:"stability",action:"get_stability_result_list"})}get_balance_item(e,n,r,i){return $e(ze({},this.get_index_item(e,n,r,i)),{block_mapping:"balance",action:"get_balance_result_list"})}get_increment_item(e,n,r,i){return $e(ze({},this.get_index_item(e,n,r,i)),{block_mapping:"increment",action:"get_increment_result_list"})}get_risk_item(e,n,r,i){return $e(ze({},this.get_index_item(e,n,r,i)),{block_mapping:"risk",action:"get_risk_result_list"})}get_summary_item(){return{block_mapping:"schema",action:"get_statistical_quantity"}}getRangeLineHistoryData(e){var c,u;const{conf:n,uid:r}=e,i=((u=(c=n==null?void 0:n.options)==null?void 0:c.points)==null?void 0:u.value)||100,a=n.common.source||"mosaic",o=JSON.parse(sessionStorage.getItem("object_alias_uid_mapping")||"{}"),s=n.data[0]||{};let l="";return n.useAlias?l=s.object_alias&&o[s.object_alias]||r:l=s.object_id||r,a==="deviation"?this.getDeviationHistory(n,l,i):this.getEigenHistory(n,l,i)}getDeviationHistory(e,n,r){const i=e.data[0]||{},a=i.is_alias?"alias":"uid",o={page_index:1,page_size:r,block_mapping:"deviation",action:"get_deviation_result_list",where_and:[["object_id","=",n]]};return i.fv&&o.where_and.unshift([a,"=",i.fv]),new Promise(s=>{_n.platform(l=>{s(this.formatDeviation(l.result))},o)})}getEigenHistory(e,n,r){return zt(this,null,function*(){const i={times:[],data:[],range:{}};(yield new Promise(s=>{const l={keys:[e.data[0].fv],object_id:n,page_index:1,page_size:r,block_mapping:"apim",action:"get_mosaic_list"};_n.platform(c=>{const u=c.result.data?c.result.data.sort((f,h)=>Ct(f.time).valueOf()-Ct(h.time).valueOf()):[];s(u)},l)})).forEach(s=>{var l;i.times.push(Ct(s.time).format("YYYY-MM-DD HH:mm:ss")),i.data.push((l=s[e.data[0].fv])!=null?l:"-")});const o={action:"get_adaps_report_list",block_mapping:"eigen",where_and:[["start",">=",i.times[0]],["end","<=",i.times[i.times.length-1]],["project_uid","=",e.data[0].project_id],["object_id","=",n]]};return new Promise(s=>{_n.platform(l=>{i.range=this.formatEigen(l.result.data,i.times),s(i)},o)})})}formatDeviation(e){const n={times:[],data:[],range:{}},r={};e.data.sort((a,o)=>Ct(a.created).valueOf()-Ct(o.created).valueOf()).forEach((a,o)=>{n.times.push(a.created),n.data.push(a.data.Dev),a.data.Base&&(r[a.data.Base]?r[a.data.Base].push([o,o]):r[a.data.Base]=[[o,o]])});for(const a in r){const o=[],s=r[a];if(s.length===0)continue;let l=[s[0]];for(let c=1;c<s.length;c++)s[c][0]-s[c-1][0]===1?l.push(s[c]):(o.push(l),l=[s[c]]);o.push(l),r[a]=o.map(c=>[c[0][0],c[c.length-1][0]])}return n.range=r,n}formatEigen(e,n){const r={};return e.sort((a,o)=>Ct(a.created).valueOf()-Ct(o.created).valueOf()).forEach(a=>{const o=JSON.parse(a.detail),s=[Ct(a.start).format("YYYY-MM-DD HH:mm:ss"),Ct(a.end).format("YYYY-MM-DD HH:mm:ss")];o.Main.forEach(l=>{var h;const c=(h=l.report)!=null&&h.start?[Ct(l.report[0].start.datetime).format("YYYY-MM-DD HH:mm:ss"),Ct(l.report[0].end.datetime).format("YYYY-MM-DD HH:mm:ss")]:s,u=n.indexOf(c[0]),f=n.indexOf(c[1]);u===-1||f===-1||(r[l.key_type]?r[l.key_type].push([u,f]):r[l.key_type]=[[u,f]])})}),r}getSwitchHistoryData(e){const{conf:n,uid:r}=e,{common:i}=n,a=gi(i,!!i.useAlias,r),o={block_mapping:"mosaic",action:"get_last_fv_by_objid",keys:[i.statusFv],object_id:a,items:1};return new Promise(s=>{_n.platform(l=>{s(l.result)},o)})}getRetainerHistoryData(e,n=1){return zt(this,null,function*(){const{conf:r,uid:i}=e,{data:a,common:o}=r,s=yield _n.getTokenForBackend(),l={block_mapping:"mixtask",action:"user_action",user_action:"get_retainer_result",args:{items:n,token:s,condition:[]}};return a.forEach(c=>{let u="";o.multiObject?u=gi(c,!!o.useAlias,i):u=gi(o,!!o.useAlias,i),l.args.condition.push({object_id:u||c.object_id,retainer:c.retainer||"",retainer_code:c.retainer_code||"",fv:c.fv||""})}),new Promise((c,u)=>{_n.platform(f=>{if(f.code===200&&f.result){const h=Array.isArray(f.result)?f.result[0]:f.result;c(h)}else u(f)},l)})})}getGridviewHistoryData(e){const{conf:n,uid:r}=e,{common:i,data:a}=n,o=i.source||"mosaic";let s="result";o==="mosaic"&&(s="single");const l={block_mapping:"mixtools",action:this.getAction(s,o),condition:[]};let c="";return i.multiObject||(c=gi(i,!!i.useAlias,r)),o==="summary"?(l.block_mapping="schema",l.action="get_statistical_quantity",delete l.condition):a.forEach(u=>{u.forEach(f=>{if(f.isValue){i.multiObject&&(c=gi({object_id:f.object,object_alias:f.object},!!i.useAlias,r)),f.object_id=c;const h=`get_${o}_item`;typeof this[h]=="function"&&l.condition.push(this[h](f,s,1,""))}})}),new Promise(u=>{_n.platform(f=>{u(f.result)},l)})}}const tL=Object.freeze(Object.defineProperty({__proto__:null,default:Kat},Symbol.toStringTag,{value:"Module"}));exports.DesignApp=$P;exports.DesignPro=QP;exports.DesignShow=KP;exports.configureAuth=Aee;exports.default=qat;exports.getAuthToken=Tee;exports.getWsUrl=Cee;
|
package/dist/mixdashboards.js
CHANGED
|
@@ -137817,7 +137817,7 @@ function cst(t) {
|
|
|
137817
137817
|
function ust(t) {
|
|
137818
137818
|
try {
|
|
137819
137819
|
let e = t.replace("/apiproxy/api", "/apiproxy/ws/api");
|
|
137820
|
-
return e = e.replace(
|
|
137820
|
+
return e.startsWith("https://") ? e = e.replace("https://", "wss://") : e.startsWith("http://") && (e = e.replace("http://", "ws://")), e;
|
|
137821
137821
|
} catch (e) {
|
|
137822
137822
|
return console.error("[Auth] WebSocket URL 推导失败:", e), Bl.wsUrl || QL.wsUrl;
|
|
137823
137823
|
}
|