goview_vue/dist/static/js/index-9dc4cbb4.js
2023-06-06 13:24:29 +08:00

2 lines
3.9 KiB
JavaScript

var d=(v,f,i)=>new Promise((S,u)=>{var g=a=>{try{n(i.next(a))}catch(c){u(c)}},r=a=>{try{n(i.throw(a))}catch(c){u(c)}},n=a=>a.done?S(a.value):Promise.resolve(a.value).then(g,r);n((i=i.apply(v,f)).next())});import{M as B}from"./EditorWorker-43e8cbc4.js";import"./editorWorker-43a98755.js";import{d as D,j as J,aH as w,aI as L,ak as R,aJ as h,aK as j,aL as A,r as s,c as M,b as t,w as o,aE as F,o as y,n as H,e as p,u as m,D as x,a6 as O,h as K}from"./index-4ec2ce15.js";import{g as z}from"./storage-a224a9c3.js";import{g as b}from"./plugin-ae137233.js";import{i as G}from"./icon-42fa39e7.js";import{u as U}from"./useSync.hook-dcdbd18a.js";import{u as q,P as Q}from"./chartEditStore-bfc6c223.js";import"./project.api-0931840b.js";import"./chartLayoutStore-810503fe.js";import"./index-96c3a075.js";import"./SettingItem-35031211.js";/* empty css */import"./SettingItemBox-f60eaa4e.js";import"./CollapseItem.vue_vue_type_script_setup_true_lang-77b092a0.js";import"./index.esm.min-2eecdcbd.js";import"./fileTypeEnum-21359a08.js";const W={class:"go-edit"},X=D({__name:"index",setup(v){const f=q(),{dataSyncUpdate:i}=U(),{ChevronBackOutlineIcon:S,DownloadIcon:u,AnalyticsIcon:g}=G.ionicons5,r=window.showOpenFilePicker,n=J("");window.$message.warning("请不要刷新此窗口!");function a(){return d(this,null,function*(){const e=yield z();F(`编辑-${e.editCanvasConfig.projectName}`),n.value=h(e)})}setTimeout(a);function c(){b({message:"导入数据将覆盖内容,此操作不可撤回,是否继续?",isMaskClosable:!0,transformOrigin:"center",onPositiveCallback:()=>d(this,null,function*(){try{const _=yield(yield r())[0].getFile(),l=new FileReader;l.readAsText(_),l.onloadend=()=>{n.value=(l.result||"").toString()},window.$message.success("导入成功!")}catch(e){window.$message.error("导入失败,请检查文件是否损坏!"),console.log(e)}})})}window.opener.addEventListener(w.CHART,e=>{window.$message.success("正在进行更新..."),L(R.GO_CHART_STORAGE_LIST,[e.detail]),n.value=h(e.detail)}),document.addEventListener("keydown",function(e){e.keyCode==83&&(navigator.platform.match("Mac")?e.metaKey:e.ctrlKey)&&(e.preventDefault(),C())});function C(){return d(this,null,function*(){if(!window.opener)return window.$message.error("源窗口已关闭,视图同步失败!");b({message:"是否覆盖源视图内容? 此操作不可撤!",isMaskClosable:!0,transformOrigin:"center",onPositiveCallback:()=>d(this,null,function*(){try{const e=j(n.value);delete e.id,i&&(f.setProjectInfo(Q.PROJECT_ID,A()),yield i(!1)),window.opener.dispatchEvent(new CustomEvent(w.JSON,{detail:e})),window.$message.success("正在同步内容...")}catch(e){window.$message.error("内容格式有误"),console.log(e)}})})})}return window.onbeforeunload=()=>{window.opener&&window.opener.dispatchEvent(new CustomEvent(w.CLOSE))},(e,_)=>{const l=s("n-text"),k=s("n-icon"),E=s("n-button"),I=s("n-tag"),P=s("n-space"),N=s("n-layout-header"),T=s("n-layout-content"),$=s("n-layout");return y(),M("div",W,[t($,null,{default:o(()=>[t(N,{class:"go-edit-header go-px-5 go-flex-items-center",bordered:""},{default:o(()=>[H("div",null,[t(l,{class:"go-edit-title go-mr-4"},{default:o(()=>[p("页面在线编辑器")]),_:1}),m(r)?(y(),x(E,{key:0,class:"go-mr-3",size:"medium",onClick:c},{icon:o(()=>[t(k,null,{default:o(()=>[t(m(u))]),_:1})]),default:o(()=>[p(" 导入 ")]),_:1})):O("",!0)]),t(P,null,{default:o(()=>[t(I,{bordered:!1,type:"warning"},{default:o(()=>[p(" 「Ctrl + S 更新视图」 ")]),_:1}),m(r)?(y(),x(E,{key:0,class:"go-mr-3",size:"medium",onClick:C},{icon:o(()=>[t(k,null,{default:o(()=>[t(m(g))]),_:1})]),default:o(()=>[p(" 保存 ")]),_:1})):O("",!0)]),_:1})]),_:1}),t(T,null,{default:o(()=>[t(m(B),{modelValue:n.value,"onUpdate:modelValue":_[0]||(_[0]=V=>n.value=V),language:"json",editorOptions:{lineNumbers:"on",minimap:{enabled:!0}}},null,8,["modelValue"])]),_:1})]),_:1})])}}});const ge=K(X,[["__scopeId","data-v-13e14cec"]]);export{ge as default};