goview_vue/dist/static/js/useSync.hook-02ee83df.js
2023-06-06 12:12:26 +08:00

2 lines
4.7 KiB
JavaScript

var D=Object.defineProperty,G=Object.defineProperties;var J=Object.getOwnPropertyDescriptors;var F=Object.getOwnPropertySymbols;var K=Object.prototype.hasOwnProperty,x=Object.prototype.propertyIsEnumerable;var O=(t,e,n)=>e in t?D(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,U=(t,e)=>{for(var n in e||(e={}))K.call(e,n)&&O(t,n,e[n]);if(F)for(var n of F(e))x.call(e,n)&&O(t,n,e[n]);return t},y=(t,e)=>G(t,J(e));var g=(t,e,n)=>new Promise((s,T)=>{var A=c=>{try{m(n.next(c))}catch(o){T(o)}},I=c=>{try{m(n.throw(c))}catch(o){T(o)}},m=c=>c.done?s(c.value):Promise.resolve(c.value).then(A,I);m((n=n.apply(t,e)).next())});import{k as H,bq as j,aL as h,aY as l,cE as q,cF as b,R as P,aJ as Y,L as R,aK as z,a9 as Q,cG as W,a2 as X,cw as w,aU as L,aV as V}from"./index-414f6242.js";import{u as Z,a as tt,P as E,f as u,C as et,g as at}from"./chartEditStore-71df5cf8.js";import{u as ot,C as _}from"./chartLayoutStore-5945c8c3.js";import{f as nt,d as rt,e as it}from"./index-3e379f1f.js";import{b as st,u as $,s as dt,f as ft}from"./project.api-d17fa7c6.js";const ct=t=>t,St=(t,e)=>{try{if(e.id){const n="vnodeBeforeMount"in e.events,s="vnodeMounted"in e.events;return n&&(t.events.advancedEvents.vnodeBeforeMount=e==null?void 0:e.events.vnodeBeforeMount),s&&(t.events.advancedEvents.vnodeMounted=e==null?void 0:e.events.vnodeMounted),(n||s)&&(e.events={baseEvent:{[L.ON_CLICK]:void 0,[L.ON_DBL_CLICK]:void 0,[L.ON_MOUSE_ENTER]:void 0,[L.ON_MOUSE_LEAVE]:void 0},advancedEvents:{[V.VNODE_MOUNTED]:void 0,[V.VNODE_BEFORE_MOUNT]:void 0},interactEvents:[]}),t}}catch(n){return t}},v=(t,e,n=!1)=>{if(St(t,e),n)return w(t,e);const s=e.option;if(!s)return w(t,e);if(e.option=void 0,s)return y(U({},w(t,e)),{option:s})},pt=()=>{const t=Z(),e=tt(),n=H(),s=ot(),T=(o,S=!1,f=!1)=>g(void 0,null,function*(){S&&(t.componentList=[],e.clearBackStack(),e.clearForwardStack()),o.editCanvasConfig=ct(o.editCanvasConfig),o.componentList.forEach(a=>g(void 0,null,function*(){const i=r=>{window.$vue.component(r.chartConfig.chartKey)||(window.$vue.component(r.chartConfig.chartKey,nt(r.chartConfig)),window.$vue.component(r.chartConfig.conKey,rt(r.chartConfig)))};a.isGroup?a.groupList.forEach(r=>{i(r)}):i(a)}));const C=(a,i)=>g(void 0,null,function*(){let r=yield it(a.chartConfig);a.chartConfig.redirectComponent&&(a.chartConfig.dataset&&(r.option.dataset=a.chartConfig.dataset),r.chartConfig.title=a.chartConfig.title,r.chartConfig.chartFrame=a.chartConfig.chartFrame),i?i(f?v(r,y(U({},a),{id:R()})):v(r,a)):f?t.addComponentList(v(r,y(U({},a),{id:R()})),!1,!0):t.addComponentList(v(r,a),!1,!0)});for(const a in o)if(a===et.COMPONENT_LIST){let i=0;const r=o[a].length;for(const d of o[a]){let N=parseInt((parseFloat(`${++i/r}`)*100).toString());if(s.setItemUnHandle(_.PERCENTAGE,N),d.isGroup){let p=new at;f?p=v(p,y(U({},d),{id:R()})):p=v(p,d);const M=[];for(const k of d.groupList)yield C(k,B=>{M.push(B)});p.groupList=M,t.addComponentList(p,!1,!0)}else yield C(d);N===100&&(e.clearBackStack(),e.clearForwardStack())}}else{if(a!=="editCanvasConfig"&&a!=="requestGlobalConfig")return;v(t[a],o[a],!0)}s.setItemUnHandle(_.PERCENTAGE,0)}),A=o=>{const{id:S,projectName:f,remarks:C,indexImage:a,state:i}=o;t.setProjectInfo(E.PROJECT_ID,S),t.setProjectInfo(E.PROJECT_NAME,f),t.setProjectInfo(E.REMARKS,C),t.setProjectInfo(E.THUMBNAIL,a),t.setProjectInfo(E.RELEASE,i===1)},I=()=>g(void 0,null,function*(){t.componentList=[],t.setEditCanvas(u.SAVE_STATUS,l.START);try{const o=yield ft({projectId:h()});if(o&&o.code===P.SUCCESS){if(o.data){A(o.data),yield T(z(o.data.content));return}else t.setProjectInfo(E.PROJECT_ID,h());setTimeout(()=>{t.setEditCanvas(u.SAVE_STATUS,l.SUCCESS)},1e3);return}t.setEditCanvas(u.SAVE_STATUS,l.FAILURE)}catch(o){t.setEditCanvas(u.SAVE_STATUS,l.FAILURE),Q()}}),m=j((o=!0)=>g(void 0,null,function*(){if(!h())return;let S=t.getProjectInfo[E.PROJECT_ID];if(S===null||S===""){window.$message.error("数据初未始化成功,请刷新页面!");return}t.setEditCanvas(u.SAVE_STATUS,l.START);try{if(o){const a=document.querySelector(".go-edit-range"),i=yield q(a,{backgroundColor:null,allowTaint:!0,useCORS:!0});let r=new FormData;r.append("object",b(i.toDataURL(),`${h()}_index_preview.png`));const d=yield st(r);d&&d.code===P.SUCCESS&&(d.data.fileurl?yield $({id:h(),indexImage:`${d.data.fileurl}`}):yield $({id:h(),indexImage:`${n.getFetchInfo.OSSUrl}${d.data.fileName}`}))}}catch(a){console.log(a)}let f=new FormData;f.append("projectId",S),f.append("content",Y(t.getStorageInfo||{}));const C=yield dt(f);if(C&&C.code===P.SUCCESS){setTimeout(()=>{t.setEditCanvas(u.SAVE_STATUS,l.SUCCESS)},1e3);return}t.setEditCanvas(u.SAVE_STATUS,l.FAILURE)}),3e3);return{updateComponent:T,updateStoreInfo:A,dataSyncFetch:I,dataSyncUpdate:m,intervalDataSyncUpdate:()=>{const o=setInterval(()=>{m()},W*1e3);X(()=>{clearInterval(o)})}}};export{pt as u};