hprint-designer 0.1.0 → 0.1.1

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.
@@ -8,8 +8,10 @@ export interface HPrintDesignerOptions {
8
8
  }
9
9
  export declare class HPrintDesigner {
10
10
  private _hiprint;
11
+ private _defaultProvider;
11
12
  private opts;
12
13
  constructor(opts?: HPrintDesignerOptions);
13
14
  load(): Promise<any>;
14
15
  get raw(): any;
16
+ get defaultProvider(): any;
15
17
  }
@@ -487,7 +487,7 @@ const HprintPlugin = {
487
487
  };
488
488
  class HPrintDesigner {
489
489
  constructor(Ee = {}) {
490
- this._hiprint = null, this.opts = Ee;
490
+ this._hiprint = null, this._defaultProvider = null, this.opts = Ee;
491
491
  }
492
492
  // Lazy-load vue-plugin-hiprint (keeps socket.io out of the initial bundle
493
493
  // until silent print is actually used).
@@ -496,7 +496,7 @@ class HPrintDesigner {
496
496
  if (this._hiprint) return this._hiprint;
497
497
  injectPrintLockCss();
498
498
  const Ee = yield Promise.resolve().then(() => vuePluginHiprint);
499
- return this._hiprint = Ee.hiprint, this._hiprint.init({
499
+ return this._hiprint = Ee.hiprint, this._defaultProvider = Ee.defaultElementTypeProvider, this._hiprint.init({
500
500
  host: this.opts.host || "http://localhost:17521",
501
501
  token: this.opts.token || "hprint-designer",
502
502
  lang: this.opts.lang || "cn"
@@ -506,6 +506,10 @@ class HPrintDesigner {
506
506
  get raw() {
507
507
  return this._hiprint;
508
508
  }
509
+ // The defaultElementTypeProvider from vue-plugin-hiprint (needed by hiprint.init).
510
+ get defaultProvider() {
511
+ return this._defaultProvider;
512
+ }
509
513
  }
510
514
  let _id = 0;
511
515
  const nextId = () => String(++_id);
@@ -1162,7 +1166,7 @@ const PrintDesigner = {
1162
1166
  methods: {
1163
1167
  initDesigner() {
1164
1168
  this.hiprint.init({
1165
- providers: [new this.hiprint.defaultElementTypeProvider()],
1169
+ providers: [new this.designer.defaultProvider()],
1166
1170
  host: this.host,
1167
1171
  token: this.token
1168
1172
  }), this.hiprint.PrintElementTypeManager.buildByHtml(window.$(".ep-draggable-item")), this.tpl = new this.hiprint.PrintTemplate({
@@ -350,8 +350,8 @@ table.hiprint-printElement-tableTarget {
350
350
  text-align: left;
351
351
  clear: both;
352
352
  }
353
- `,PRINT_LOCK_LINK_ID="hprint-print-lock";function injectPrintLockCss(){if(typeof document=="undefined"||document.getElementById(PRINT_LOCK_LINK_ID))return;const Ce=document.createElement("link");Ce.id=PRINT_LOCK_LINK_ID,Ce.rel="stylesheet",Ce.type="text/css",Ce.media="print",Ce.href="data:text/css;charset=utf-8,"+encodeURIComponent(rawCss),document.head.appendChild(Ce)}function http(Me,Se){return D1(this,arguments,function*(Ce,Ee,Be={}){const Pe=Ce.replace(/\/$/,"")+"/"+Ee.replace(/^\//,""),De=yield fetch(Pe,{method:Be.method||"GET",headers:wA({"Content-Type":"application/json"},Be.headers||{}),body:Be.body!==void 0?JSON.stringify(Be.body):void 0,signal:Be.signal});if(!De.ok){const je=yield De.text().catch(()=>"");throw new Error(`HTTP ${De.status} ${Be.method||"GET"} ${Ee}: ${je}`)}if(De.status!==204)return De.json()})}class RestAdapter{constructor(Ee){this.opts=Ee}listTemplates(Ee){return D1(this,null,function*(){const Be=Ee?"?"+new URLSearchParams(Ee).toString():"";return http(this.opts.baseURL,"templates"+Be)})}getTemplate(Ee){return D1(this,null,function*(){return http(this.opts.baseURL,`templates/${Ee}`)})}createTemplate(Ee){return D1(this,null,function*(){return http(this.opts.baseURL,"templates",{method:"POST",body:Ee})})}updateTemplate(Ee,Be,Me){return D1(this,null,function*(){const Se={};return Me!==void 0&&(Se["If-Match"]=String(Me)),http(this.opts.baseURL,`templates/${Ee}`,{method:"PUT",body:Be,headers:Se})})}deleteTemplate(Ee){return D1(this,null,function*(){yield http(this.opts.baseURL,`templates/${Ee}`,{method:"DELETE"})})}listFonts(){return D1(this,null,function*(){return http(this.opts.baseURL,"fonts")})}uploadFont(Ee,Be){return D1(this,null,function*(){const Me=Array.isArray(Ee)?Ee:[Ee],Se=new FormData;Me.forEach(je=>Se.append("files",je,je.name)),Se.append("name",Be.name),Se.append("family",Be.family);const Pe=this.opts.baseURL.replace(/\/$/,"")+"/fonts",De=yield fetch(Pe,{method:"POST",body:Se});if(!De.ok)throw new Error(`uploadFont failed: ${De.status}`);return De.json()})}updateFont(Ee,Be){return D1(this,null,function*(){return http(this.opts.baseURL,`fonts/${Ee}`,{method:"PUT",body:Be})})}deleteFont(Ee){return D1(this,null,function*(){yield http(this.opts.baseURL,`fonts/${Ee}`,{method:"DELETE"})})}getClientRelease(){return D1(this,null,function*(){return http(this.opts.baseURL,"client-release")})}}const HprintPlugin={install(Ce,Ee={}){injectPrintLockCss(),Ce.component(Ee.componentName||"print-designer",()=>Promise.resolve().then(()=>PrintDesigner$1));const Be=Ee.adapter||(Ee.baseURL?new RestAdapter({baseURL:Ee.baseURL}):void 0);Ce.prototype.$hprintOptions=wf(wA({},Ee),{resolvedAdapter:Be})}};class HPrintDesigner{constructor(Ee={}){this._hiprint=null,this.opts=Ee}load(){return D1(this,null,function*(){if(this._hiprint)return this._hiprint;injectPrintLockCss();const Ee=yield Promise.resolve().then(()=>vuePluginHiprint);return this._hiprint=Ee.hiprint,this._hiprint.init({host:this.opts.host||"http://localhost:17521",token:this.opts.token||"hprint-designer",lang:this.opts.lang||"cn"}),typeof Ee.disAutoConnect=="function"&&Ee.disAutoConnect(),this._hiprint})}get raw(){return this._hiprint}}let _id=0;const nextId=()=>String(++_id);class MockAdapter{constructor(){this.templates=new Map,this.fonts=new Map}listTemplates(Ee){return D1(this,null,function*(){let Be=Array.from(this.templates.values());if(Ee&&Ee.keyword){const Me=String(Ee.keyword).toLowerCase();Be=Be.filter(Se=>Se.name.toLowerCase().includes(Me))}return Be.sort((Me,Se)=>Se.updatedAt.localeCompare(Me.updatedAt)),{items:Be,total:Be.length}})}getTemplate(Ee){return D1(this,null,function*(){const Be=this.templates.get(Ee);if(!Be)throw new Error(`template ${Ee} not found`);return Be})}createTemplate(Ee){return D1(this,null,function*(){const Be=wf(wA({},Ee),{id:nextId(),version:1,updatedAt:new Date().toISOString()});return this.templates.set(Be.id,Be),Be})}updateTemplate(Ee,Be,Me){return D1(this,null,function*(){const Se=this.templates.get(Ee);if(!Se)throw new Error(`template ${Ee} not found`);if(Me!==void 0&&Me!==Se.version)throw new Error(`version mismatch: expected ${Se.version}, got ${Me}`);const Pe=wf(wA(wA({},Se),Be),{id:Se.id,version:Se.version+1,updatedAt:new Date().toISOString()});return this.templates.set(Ee,Pe),Pe})}deleteTemplate(Ee){return D1(this,null,function*(){this.templates.delete(Ee)})}listFonts(){return D1(this,null,function*(){return Array.from(this.fonts.values())})}uploadFont(Ee,Be){return D1(this,null,function*(){const Me=Array.isArray(Ee)?Ee:[Ee],Se={id:nextId(),name:Be.name,family:Be.family,files:Me.map(Pe=>({format:Pe.name.split(".").pop()||"ttf",url:URL.createObjectURL(Pe),size:Pe.size})),createdAt:new Date().toISOString()};return this.fonts.set(Se.id,Se),Se})}updateFont(Ee,Be){return D1(this,null,function*(){const Me=this.fonts.get(Ee);if(!Me)throw new Error(`font ${Ee} not found`);const Se=wA(wA({},Me),Be);return this.fonts.set(Ee,Se),Se})}deleteFont(Ee){return D1(this,null,function*(){this.fonts.delete(Ee)})}getClientRelease(){return D1(this,null,function*(){return{version:"1.0.13",officialUrl:"https://github.com/CcSimple/electron-hiprint/releases",selfHostedUrl:void 0,minCompatibleVersion:"1.0.0",publishedAt:new Date().toISOString()}})}}function normalizeComponent(Ce,Ee,Be,Me,Se,Pe,De,je){var Re=typeof Ce=="function"?Ce.options:Ce;return Ee&&(Re.render=Ee,Re.staticRenderFns=Be,Re._compiled=!0),Pe&&(Re._scopeId="data-v-"+Pe),{exports:Ce,options:Re}}const _sfc_main$8={name:"Toolbar",components:{"a-button":antDesignVue.Button,"a-button-group":antDesignVue.Button.Group,"a-popconfirm":antDesignVue.Popconfirm},props:{zoomPct:{type:Number,default:100},readonly:{type:Boolean,default:!1},clientOpen:{type:Boolean,default:!1},curPaper:{type:String,default:"A4"}},data(){return{paperTypes:{A4:{width:210,height:296.6},A5:{width:210,height:147.6},Ticket:{width:80,height:130},Invitation:{width:180,height:120}}}}};var _sfc_render$8=function(){var Ee=this,Be=Ee._self._c;return Be("div",{staticClass:"hprint-designer__toolbar"},[Be("a-button-group",Ee._l(Ee.paperTypes,function(Me,Se){return Be("a-button",{key:Se,attrs:{type:Ee.curPaper===Se?"primary":"default"},on:{click:function(Pe){return Ee.$emit("set-paper",wA({type:Se},Me))}}},[Ee._v(Ee._s(Se))])}),1),Be("a-button",{attrs:{icon:"zoom-out"},on:{click:function(Me){return Ee.$emit("zoom",-1)}}}),Be("span",{staticStyle:{"min-width":"48px","text-align":"center"}},[Ee._v(Ee._s(Ee.zoomPct)+"%")]),Be("a-button",{attrs:{icon:"zoom-in"},on:{click:function(Me){return Ee.$emit("zoom",1)}}}),Be("a-button",{attrs:{icon:"reload"},on:{click:function(Me){return Ee.$emit("rotate")}}}),Be("a-button",{attrs:{icon:"eye"},on:{click:function(Me){return Ee.$emit("preview")}}}),Be("a-button",{attrs:{icon:"printer"},on:{click:function(Me){return Ee.$emit("print-browser")}}},[Ee._v("浏览器打印")]),Be("a-button",{attrs:{type:"primary",icon:"printer"},on:{click:function(Me){return Ee.$emit("print-silent")}}},[Ee._v("直接打印")]),Be("a-button",{attrs:{type:"primary"},on:{click:function(Me){return Ee.$emit("save")}}},[Ee._v("保存")]),Be("a-popconfirm",{attrs:{title:"确认清空?"},on:{confirm:function(Me){return Ee.$emit("clear")}}},[Be("a-button",{attrs:{type:"danger",icon:"close"}},[Ee._v("清空")])],1),Be("a-button",{attrs:{type:"link"},on:{click:function(Me){return Ee.$emit("open-client")}}},[Be("span",{staticClass:"hprint-designer__status-dot",class:Ee.clientOpen?"hprint-designer__status-dot--ok":"hprint-designer__status-dot--warn"}),Ee._v(" 客户端 ")]),Ee.readonly?Be("span",{staticClass:"hprint-muted"},[Ee._v("只读模式")]):Ee._e()],1)},_sfc_staticRenderFns$8=[],__component__$8=normalizeComponent(_sfc_main$8,_sfc_render$8,_sfc_staticRenderFns$8,!1,null,null);const Toolbar=__component__$8.exports,_sfc_main$7={name:"DesignCanvas"};var _sfc_render$7=function(){var Ee=this;return Ee._self._c,Ee._m(0)},_sfc_staticRenderFns$7=[function(){var Ce=this,Ee=Ce._self._c;return Ee("div",{staticClass:"hprint-designer__center"},[Ee("div",{staticClass:"hiprint-printTemplate",attrs:{id:"hprint-printTemplate"}}),Ee("div",{staticClass:"hiprint-printPagination"})])}],__component__$7=normalizeComponent(_sfc_main$7,_sfc_render$7,_sfc_staticRenderFns$7,!1,null,null);const DesignCanvas=__component__$7.exports;function getDragGroups(){return[{title:"常用组件",items:[{tid:"defaultModule.text",label:"文本",icon:"glyphicon-text-width"},{tid:"defaultModule.image",label:"图片",icon:"glyphicon-picture"},{tid:"defaultModule.longText",label:"长文",icon:"glyphicon-subscript"},{tid:"defaultModule.table",label:"表格",icon:"glyphicon-th"},{tid:"defaultModule.emptyTable",label:"空白表格",icon:"glyphicon-th"},{tid:"defaultModule.html",label:"HTML",icon:"glyphicon-header"},{tid:"defaultModule.customText",label:"自定义",icon:"glyphicon-text-width"}]},{title:"条码",items:[{tid:"defaultModule.barcode",label:"条形码",icon:"glyphicon-barcode"},{tid:"defaultModule.qrcode",label:"二维码",icon:"glyphicon-qrcode"}]},{title:"辅助图形",items:[{tid:"defaultModule.hline",label:"横线",icon:"glyphicon-resize-horizontal"},{tid:"defaultModule.vline",label:"竖线",icon:"glyphicon-resize-vertical"},{tid:"defaultModule.rect",label:"矩形",icon:"glyphicon-unchecked"},{tid:"defaultModule.oval",label:"椭圆",icon:"glyphicon-record"}]}]}const _sfc_main$6={name:"DragPanel",components:{"a-row":antDesignVue.Row,"a-col":antDesignVue.Col},data(){return{groups:getDragGroups()}},methods:{chunk(Ce,Ee){const Be=[];for(let Me=0;Me<Ce.length;Me+=Ee)Be.push(Ce.slice(Me,Me+Ee));return Be}}};var _sfc_render$6=function(){var Ee=this,Be=Ee._self._c;return Be("div",{staticClass:"hprint-designer__left"},Ee._l(Ee.groups,function(Me){return Be("div",{key:Me.title},[Be("div",{staticClass:"hprint-designer__drag-group-title"},[Ee._v(Ee._s(Me.title))]),Ee._l(Ee.chunk(Me.items,2),function(Se,Pe){return Be("a-row",{key:Pe},Ee._l(Se,function(De){return Be("a-col",{key:De.tid,attrs:{span:12}},[Be("a",{staticClass:"hprint-designer__drag-item ep-draggable-item",attrs:{tid:De.tid},on:{dragstart:function(je){return Ee.$emit("drag-start",De)}}},[Be("span",{staticClass:"glyphicon",class:De.icon,attrs:{"aria-hidden":"true"}}),Be("span",[Ee._v(Ee._s(De.label))])])])}),1)})],2)}),0)},_sfc_staticRenderFns$6=[],__component__$6=normalizeComponent(_sfc_main$6,_sfc_render$6,_sfc_staticRenderFns$6,!1,null,null);const DragPanel=__component__$6.exports,_sfc_main$5={name:"ElementProps",props:{selector:{type:String,default:"#hprint-element-setting"}},data(){return{hasSelection:!1}},mounted(){this.$on("selection-changed",Ce=>{this.hasSelection=Ce})}};var _sfc_render$5=function(){var Ee=this,Be=Ee._self._c;return Be("div",{staticClass:"hprint-element-props"},[Be("div",{attrs:{id:"hprint-element-setting"}}),Ee.hasSelection?Ee._e():Be("p",{staticClass:"hprint-muted"},[Ee._v("选中元素后在此编辑属性")])])},_sfc_staticRenderFns$5=[],__component__$5=normalizeComponent(_sfc_main$5,_sfc_render$5,_sfc_staticRenderFns$5,!1,null,"c0d94aa0");const ElementProps=__component__$5.exports;function getFormatterPresets(){return[{label:"金额 ¥#,##0.00",value:"money"},{label:"日期 YYYY-MM-DD",value:"date"},{label:"日期时间 YYYY-MM-DD HH:mm",value:"datetime"}]}const _sfc_main$4={name:"FieldPanel",components:{"a-button":antDesignVue.Button,"a-table":antDesignVue.Table,"a-modal":antDesignVue.Modal,"a-form-model":antDesignVue.FormModel,"a-form-model-item":antDesignVue.FormModel.Item,"a-input":antDesignVue.Input,"a-select":antDesignVue.Select,"a-select-option":antDesignVue.Select.Option,"a-switch":antDesignVue.Switch},props:{fields:{type:Array,default:()=>[]}},data(){return{editVisible:!1,editing:this.blankField(),formatterPresets:getFormatterPresets(),types:["string","number","date","datetime","image","qrcode","barcode","longtext"],columns:[{title:"key",dataIndex:"key"},{title:"名称",dataIndex:"label"},{title:"类型",dataIndex:"type"},{title:"操作",scopedSlots:{customRender:"action"}}]}},methods:{blankField(){return{key:"",label:"",type:"string",sample:"",group:"",required:!1}},addField(){this.editing=this.blankField(),this.editVisible=!0},saveEdit(){if(!this.editing.key){this.$message.warning("字段 key 必填");return}this.$emit("upsert-field",wA({},this.editing)),this.editVisible=!1},removeField(Ce){this.$emit("remove-field",Ce)}}};var _sfc_render$4=function(){var Ee=this,Be=Ee._self._c;return Be("div",{staticClass:"hprint-field-panel"},[Be("a-button",{attrs:{size:"small",type:"primary",icon:"plus"},on:{click:Ee.addField}},[Ee._v("新增字段")]),Be("a-table",{attrs:{"data-source":Ee.fields,columns:Ee.columns,pagination:!1,"row-key":"key",size:"small"},scopedSlots:Ee._u([{key:"action",fn:function(Me,Se){return[Be("a-button",{attrs:{size:"small",type:"link"},on:{click:function(Pe){return Ee.removeField(Se.key)}}},[Ee._v("删除")])]}}])}),Be("a-modal",{attrs:{title:"字段编辑",visible:Ee.editVisible},on:{"update:visible":function(Me){Ee.editVisible=Me},ok:Ee.saveEdit,cancel:function(Me){Ee.editVisible=!1}}},[Be("a-form-model",{attrs:{layout:"vertical"}},[Be("a-form-model-item",{attrs:{label:"字段 key"}},[Be("a-input",{model:{value:Ee.editing.key,callback:function(Me){Ee.$set(Ee.editing,"key",Me)},expression:"editing.key"}})],1),Be("a-form-model-item",{attrs:{label:"显示名"}},[Be("a-input",{model:{value:Ee.editing.label,callback:function(Me){Ee.$set(Ee.editing,"label",Me)},expression:"editing.label"}})],1),Be("a-form-model-item",{attrs:{label:"类型"}},[Be("a-select",{model:{value:Ee.editing.type,callback:function(Me){Ee.$set(Ee.editing,"type",Me)},expression:"editing.type"}},Ee._l(Ee.types,function(Me){return Be("a-select-option",{key:Me,attrs:{value:Me}},[Ee._v(Ee._s(Me))])}),1)],1),Be("a-form-model-item",{attrs:{label:"示例值"}},[Be("a-input",{model:{value:Ee.editing.sample,callback:function(Me){Ee.$set(Ee.editing,"sample",Me)},expression:"editing.sample"}})],1),Be("a-form-model-item",{attrs:{label:"分组"}},[Be("a-input",{model:{value:Ee.editing.group,callback:function(Me){Ee.$set(Ee.editing,"group",Me)},expression:"editing.group"}})],1),Be("a-form-model-item",{attrs:{label:"格式化"}},[Be("a-select",{attrs:{"allow-clear":""},model:{value:Ee.editing.formatter,callback:function(Me){Ee.$set(Ee.editing,"formatter",Me)},expression:"editing.formatter"}},Ee._l(Ee.formatterPresets,function(Me){return Be("a-select-option",{key:Me.value,attrs:{value:Me.value}},[Ee._v(Ee._s(Me.label))])}),1)],1),Be("a-form-model-item",{attrs:{label:"必填"}},[Be("a-switch",{model:{value:Ee.editing.required,callback:function(Me){Ee.$set(Ee.editing,"required",Me)},expression:"editing.required"}})],1)],1)],1)],1)},_sfc_staticRenderFns$4=[],__component__$4=normalizeComponent(_sfc_main$4,_sfc_render$4,_sfc_staticRenderFns$4,!1,null,null);const FieldPanel=__component__$4.exports,_sfc_main$3={name:"FontPanel",components:{"a-button":antDesignVue.Button,"a-list":antDesignVue.List,"a-list-item":antDesignVue.List.Item,"a-list-item-meta":antDesignVue.List.Item.Meta,"a-modal":antDesignVue.Modal,"a-form-model":antDesignVue.FormModel,"a-form-model-item":antDesignVue.FormModel.Item,"a-input":antDesignVue.Input},props:{fonts:{type:Array,default:()=>[]}},data(){return{uploadVisible:!1,meta:{name:"",family:""},files:[]}},methods:{onFileChange(Ce){this.files=Array.from(Ce.target.files||[])},doUpload(){return D1(this,null,function*(){if(!this.meta.name||!this.meta.family){antDesignVue.message.warning("名称与 font-family 必填");return}if(!this.files.length){antDesignVue.message.warning("请选择字体文件");return}this.$emit("upload-font",{files:this.files,meta:wA({},this.meta)}),this.uploadVisible=!1,this.meta={name:"",family:""},this.files=[]})},removeFont(Ce){this.$emit("remove-font",Ce)}}};var _sfc_render$3=function(){var Ee=this,Be=Ee._self._c;return Be("div",{staticClass:"hprint-font-panel"},[Be("a-button",{attrs:{size:"small",type:"primary",icon:"upload"},on:{click:function(Me){Ee.uploadVisible=!0}}},[Ee._v("上传字体")]),Be("a-list",{attrs:{"data-source":Ee.fonts,size:"small"},scopedSlots:Ee._u([{key:"renderItem",fn:function(Me){return Be("a-list-item",{},[Be("a-list-item-meta",{attrs:{title:Me.name,description:Me.family}}),Be("a",{attrs:{slot:"actions"},slot:"actions"},[Be("a-button",{attrs:{size:"small",type:"link"},on:{click:function(Se){return Ee.removeFont(Me.id)}}},[Ee._v("删除")])],1)],1)}}])}),Be("a-modal",{attrs:{title:"上传字体",visible:Ee.uploadVisible},on:{"update:visible":function(Me){Ee.uploadVisible=Me},ok:Ee.doUpload,cancel:function(Me){Ee.uploadVisible=!1}}},[Be("a-form-model",{attrs:{layout:"vertical"}},[Be("a-form-model-item",{attrs:{label:"展示名"}},[Be("a-input",{model:{value:Ee.meta.name,callback:function(Me){Ee.$set(Ee.meta,"name",Me)},expression:"meta.name"}})],1),Be("a-form-model-item",{attrs:{label:"CSS font-family"}},[Be("a-input",{model:{value:Ee.meta.family,callback:function(Me){Ee.$set(Ee.meta,"family",Me)},expression:"meta.family"}})],1),Be("a-form-model-item",{attrs:{label:"字体文件(woff2/woff/ttf,可多选)"}},[Be("input",{attrs:{type:"file",multiple:"",accept:".woff2,.woff,.ttf"},on:{change:Ee.onFileChange}})])],1)],1)],1)},_sfc_staticRenderFns$3=[],__component__$3=normalizeComponent(_sfc_main$3,_sfc_render$3,_sfc_staticRenderFns$3,!1,null,null);const FontPanel=__component__$3.exports,_sfc_main$2={name:"RightTabs",components:{"a-tabs":antDesignVue.Tabs,"a-tab-pane":antDesignVue.Tabs.TabPane,"element-props":ElementProps,"field-panel":FieldPanel,"font-panel":FontPanel},props:{fields:{type:Array,default:()=>[]},fonts:{type:Array,default:()=>[]},propsSelector:{type:String,default:"#hprint-element-setting"}},data(){return{active:"props"}},methods:{onSel(Ce){this.$emit("selection-changed",Ce)}}};var _sfc_render$2=function(){var Ee=this,Be=Ee._self._c;return Be("div",{staticClass:"hprint-designer__right"},[Be("a-tabs",{attrs:{size:"small"},model:{value:Ee.active,callback:function(Me){Ee.active=Me},expression:"active"}},[Be("a-tab-pane",{key:"props",attrs:{tab:"元素属性"}},[Be("element-props",{attrs:{selector:Ee.propsSelector},on:{"selection-changed":Ee.onSel}})],1),Be("a-tab-pane",{key:"fields",attrs:{tab:"字段管理"}},[Be("field-panel",{attrs:{fields:Ee.fields},on:{"upsert-field":function(Me){return Ee.$emit("upsert-field",Me)},"remove-field":function(Me){return Ee.$emit("remove-field",Me)}}})],1),Be("a-tab-pane",{key:"fonts",attrs:{tab:"字体管理"}},[Be("font-panel",{attrs:{fonts:Ee.fonts},on:{"upload-font":function(Me){return Ee.$emit("upload-font",Me)},"remove-font":function(Me){return Ee.$emit("remove-font",Me)}}})],1),Be("a-tab-pane",{key:"info",attrs:{tab:"模板信息"}},[Ee._t("info")],2)],1)],1)},_sfc_staticRenderFns$2=[],__component__$2=normalizeComponent(_sfc_main$2,_sfc_render$2,_sfc_staticRenderFns$2,!1,null,null);const RightTabs=__component__$2.exports;function getSocket(){return typeof window!="undefined"?window.hiwebSocket:void 0}function isClientOpen(){var Ce;return!!((Ce=getSocket())!=null&&Ce.opened)}function getClientInfo(){const Ce=getSocket();return wA({opened:!!(Ce!=null&&Ce.opened)},(Ce==null?void 0:Ce.clientInfo)||{})}function compareVersions(Ce,Ee){const Be=Ce.split(".").map(Pe=>parseInt(Pe,10)||0),Me=Ee.split(".").map(Pe=>parseInt(Pe,10)||0),Se=Math.max(Be.length,Me.length);for(let Pe=0;Pe<Se;Pe++){const De=Be[Pe]||0,je=Me[Pe]||0;if(De!==je)return De-je}return 0}function isVersionBelow(Ce,Ee){return compareVersions(Ce,Ee)<0}function detectPlatform(Ce){const Ee=((typeof navigator!="undefined"?navigator.platform:"")||"").toLowerCase();return Ee.includes("win")?"win":Ee.includes("mac")?"mac":Ee.includes("linux")?"linux":"win"}const _sfc_main$1={name:"ClientGuide",components:{"a-modal":antDesignVue.Modal,"a-alert":antDesignVue.Alert,"a-steps":antDesignVue.Steps,"a-step":antDesignVue.Steps.Step,"a-button":antDesignVue.Button,"a-space":antDesignVue.Space},props:{visible:{type:Boolean,default:!1},release:{type:Object,default:()=>({})}},data(){return{platform:detectPlatform()}},computed:{opened(){return isClientOpen()},clientVersion(){return getClientInfo().version||"未知"},statusClass(){return this.opened?"hprint-designer__status-dot--ok":"hprint-designer__status-dot--warn"},statusText(){const Ce=getClientInfo();return this.opened?`已连接 v${Ce.version} @${Ce.hostname||""}`:"未连接"},showVersionWarn(){if(!this.opened||!this.release.minCompatibleVersion)return!1;const Ce=getClientInfo().version;return Ce?isVersionBelow(Ce,this.release.minCompatibleVersion):!1}},methods:{close(){this.$emit("update:visible",!1)},downloadOfficial(){this.release.officialUrl&&window.open(this.release.officialUrl,"_blank")},downloadSelfHosted(){this.release.selfHostedUrl&&window.open(this.release.selfHostedUrl,"_blank")},launchScheme(){window.open("hiprint://","_blank")},retry(){this.$emit("retry")}}};var _sfc_render$1=function(){var Ee=this,Be=Ee._self._c;return Be("div",{staticClass:"hprint-client-guide"},[Be("a-modal",{attrs:{title:"打印客户端",visible:Ee.visible,footer:null,width:"560px"},on:{"update:visible":function(Me){Ee.visible=Me},cancel:Ee.close}},[Be("div",{staticClass:"hprint-client-status"},[Be("span",{staticClass:"hprint-designer__status-dot",class:Ee.statusClass}),Be("span",[Ee._v(Ee._s(Ee.statusText))])]),Ee.showVersionWarn?Be("a-alert",{staticStyle:{margin:"12px 0"},attrs:{type:"warning","show-icon":""}},[Be("span",{attrs:{slot:"message"},slot:"message"},[Ee._v("当前客户端版本 "+Ee._s(Ee.clientVersion)+" 过低,建议升级到 "+Ee._s(Ee.release.version))])]):Ee._e(),Be("div",{staticClass:"hprint-download-block"},[Be("a-button",{attrs:{type:"primary",size:"large",icon:"download"},on:{click:Ee.downloadOfficial}},[Ee._v(" 下载客户端("+Ee._s(Ee.platform)+") ")]),Ee.release.selfHostedUrl?Be("p",{staticClass:"hprint-muted"},[Ee._v(" 官方下载慢或不可访问? "),Be("a",{on:{click:Ee.downloadSelfHosted}},[Ee._v("使用服务端备用下载")])]):Ee._e()],1),Be("a-steps",{staticStyle:{margin:"16px 0"},attrs:{current:0,direction:"vertical",size:"small"}},[Be("a-step",{attrs:{title:"下载安装包"}}),Be("a-step",{attrs:{title:"以管理员身份运行(注册 hiprint:// 协议)"}}),Be("a-step",{attrs:{title:"运行客户端后自动回连"}})],1),Be("a-space",[Be("a-button",{attrs:{icon:"link"},on:{click:Ee.launchScheme}},[Ee._v("一键唤起已装客户端")]),Be("a-button",{attrs:{type:"primary"},on:{click:Ee.retry}},[Ee._v("我已安装,重新检测")])],1)],1)],1)},_sfc_staticRenderFns$1=[],__component__$1=normalizeComponent(_sfc_main$1,_sfc_render$1,_sfc_staticRenderFns$1,!1,null,"5d978621");const ClientGuide=__component__$1.exports,formatMap={woff2:"format('woff2')",woff:"format('woff')",ttf:"format('truetype')"},priority=["woff2","woff","ttf"];function buildFontFaceCss(Ce){return Ce.map(Ee=>{const Me=[...Ee.files].sort((Se,Pe)=>priority.indexOf(Se.format)-priority.indexOf(Pe.format)).map(Se=>`url('${Se.url}') ${formatMap[Se.format]}`).join(", ");return`@font-face { font-family: '${Ee.family}'; src: ${Me}; }`}).join(`
354
- `)}function buildStyleHandlerCss(Ce){return buildFontFaceCss(Ce)}function toHiprintFontList(Ce){return Ce.map(Ee=>({title:Ee.name,value:Ee.family}))}const STYLE_ID="hprint-fonts";class FontManager{constructor(){this.el=null}inject(Ee){if(this.cleanup(),!Ee.length)return;const Be=buildFontFaceCss(Ee),Me=document.createElement("style");Me.id=STYLE_ID,Me.textContent=Be,document.head.appendChild(Me),this.el=Me}cleanup(){this.el&&(this.el.remove(),this.el=null)}}function buildPreviewData(Ce){const Ee={};for(const Be of Ce)Ee[Be.key]=Be.sample===void 0||Be.sample===null?"":Be.sample;return Ee}const PrintDesigner={name:"PrintDesigner",components:{"a-button":antDesignVue.Button,"a-switch":antDesignVue.Switch,toolbar:Toolbar,"design-canvas":DesignCanvas,"drag-panel":DragPanel,"right-tabs":RightTabs,"client-guide":ClientGuide},props:{templateId:{type:String,default:""},readonly:{type:Boolean,default:!1},host:{type:String,default:"http://localhost:17521"},token:{type:String,default:"hprint-designer"},adapter:{type:Object,default:null}},data(){return{designer:null,hiprint:null,template:null,tpl:null,fontMgr:new FontManager,fonts:[],fields:[],zoomPct:100,sampleOn:!0,curPaper:"A4",clientOpen:!1,clientGuideVisible:!1,clientRelease:{},_clientTimer:null,backend:null}},mounted(){return D1(this,null,function*(){this.designer=new HPrintDesigner({host:this.host,token:this.token}),this.hiprint=yield this.designer.load(),this.backend=this.adapter||this.$hprintOptions&&this.$hprintOptions.resolvedAdapter||new MockAdapter,this.fonts=yield this.backend.listFonts(),this.fontMgr.inject(this.fonts),this.templateId?this.template=yield this.backend.getTemplate(this.templateId):this.template={name:"新建模板",panels:[],fields:[],status:"draft"},this.fields=this.template.fields||[],this.initDesigner()})},beforeDestroy(){this.fontMgr.cleanup(),this._clientTimer&&clearInterval(this._clientTimer)},methods:{initDesigner(){this.hiprint.init({providers:[new this.hiprint.defaultElementTypeProvider],host:this.host,token:this.token}),this.hiprint.PrintElementTypeManager.buildByHtml(window.$(".ep-draggable-item")),this.tpl=new this.hiprint.PrintTemplate({template:this.template.panels.length?this.template:{},settingContainer:"#hprint-element-setting",paginationContainer:".hiprint-printPagination",fontList:toHiprintFontList(this.fonts),history:!0,onDataChanged:(Ce,Ee)=>{this.$emit("data-change",{type:Ce,json:Ee})}}),this.tpl.design("#hprint-printTemplate",{grid:!0}),this.refreshPreview(),this.pollClient()},styleHandler(){return buildStyleHandlerCss(this.fonts)+"<style>.hiprint-printElement-text{}</style>"},previewData(){return this.sampleOn?buildPreviewData(this.fields):{}},refreshPreview(){if(this.tpl){const Ce=this.tpl.getHtml(this.previewData());this.$emit("data-change",{type:"preview",html:Ce})}},setPaper(Ce){this.curPaper=Ce.type||"A4",this.tpl&&this.tpl.setPaper(Ce.width,Ce.height)},onZoom(Ce){this.zoomPct=Math.max(50,Math.min(500,this.zoomPct+Ce*10)),this.tpl&&this.tpl.zoom(this.zoomPct/100)},onRotate(){this.tpl&&this.tpl.rotatePaper()},onPreview(){this.refreshPreview()},onPrintBrowser(){this.tpl&&this.tpl.print(this.previewData(),{},{styleHandler:this.styleHandler}),this.$emit("print",{mode:"browser"})},onPrintSilent(){return D1(this,null,function*(){if(!isClientOpen()){this.clientGuideVisible=!0;return}if(!this.clientRelease.version)try{this.clientRelease=yield this.backend.getClientRelease()}catch(Ce){}this.tpl&&this.tpl.print2(this.previewData(),{printer:"",title:this.template.name,styleHandler:this.styleHandler}),this.$emit("print",{mode:"silent"})})},onSave(){return D1(this,null,function*(){const Ce=this.tpl.getJson(),Ee={name:this.template.name,panels:Ce,fields:this.fields,status:this.template.status};if(this.template.id){const Be=yield this.backend.updateTemplate(this.template.id,Ee,this.template.version);this.template=Be,this.$emit("save",Be)}else{const Be=yield this.backend.createTemplate(wA({},Ee));this.template=Be,this.$emit("save",Be)}})},onClear(){this.tpl&&this.tpl.clear()},onDragStart(){},upsertField(Ce){const Ee=this.fields.findIndex(Be=>Be.key===Ce.key);Ee>=0?this.fields.splice(Ee,1,Ce):this.fields.push(Ce),this.refreshPreview()},removeField(Ce){this.fields=this.fields.filter(Ee=>Ee.key!==Ce),this.refreshPreview()},uploadFont(Be){return D1(this,arguments,function*({files:Ce,meta:Ee}){yield this.backend.uploadFont(Ce,Ee),this.fonts=yield this.backend.listFonts(),this.fontMgr.inject(this.fonts),this.tpl&&this.tpl.setFontList(toHiprintFontList(this.fonts))})},removeFont(Ce){return D1(this,null,function*(){yield this.backend.deleteFont(Ce),this.fonts=yield this.backend.listFonts(),this.fontMgr.inject(this.fonts)})},pollClient(){const Ce=()=>{this.clientOpen=isClientOpen()};Ce(),this._clientTimer=setInterval(Ce,2e3)},onClientRetry(){this.clientOpen=isClientOpen(),this.clientOpen&&(this.clientGuideVisible=!1)}}},_sfc_main=PrintDesigner;var _sfc_render=function(){var Ee=this,Be=Ee._self._c;return Ee._self._setupProxy,Be("div",{staticClass:"hprint-designer"},[Be("toolbar",{attrs:{"zoom-pct":Ee.zoomPct,readonly:Ee.readonly,"client-open":Ee.clientOpen,"cur-paper":Ee.curPaper},on:{"set-paper":Ee.setPaper,zoom:Ee.onZoom,rotate:Ee.onRotate,preview:Ee.onPreview,"print-browser":Ee.onPrintBrowser,"print-silent":Ee.onPrintSilent,save:Ee.onSave,clear:Ee.onClear,"open-client":function(Me){Ee.clientGuideVisible=!0}}}),Be("div",{staticClass:"hprint-designer__body"},[Be("drag-panel",{on:{"drag-start":Ee.onDragStart}}),Be("design-canvas",{ref:"canvas"}),Be("right-tabs",{attrs:{fields:Ee.fields,fonts:Ee.fonts},on:{"upsert-field":Ee.upsertField,"remove-field":Ee.removeField,"upload-font":Ee.uploadFont,"remove-font":Ee.removeFont}})],1),Be("div",{staticClass:"hprint-designer__footer"},[Be("a-button",{attrs:{size:"small",icon:"undo",disabled:Ee.readonly},on:{click:function(Me){return Ee.$emit("undo")}}},[Ee._v("撤销")]),Be("a-button",{attrs:{size:"small",icon:"redo",disabled:Ee.readonly},on:{click:function(Me){return Ee.$emit("redo")}}},[Ee._v("重做")]),Be("a-switch",{attrs:{"checked-children":"示例数据","un-checked-children":"空白"},on:{change:Ee.refreshPreview},model:{value:Ee.sampleOn,callback:function(Me){Ee.sampleOn=Me},expression:"sampleOn"}}),Be("span",[Ee._v("缩放 "+Ee._s(Ee.zoomPct)+"%")])],1),Be("client-guide",{attrs:{visible:Ee.clientGuideVisible,release:Ee.clientRelease},on:{"update:visible":function(Me){Ee.clientGuideVisible=Me},retry:Ee.onClientRetry}})],1)},_sfc_staticRenderFns=[],__component__=normalizeComponent(_sfc_main,_sfc_render,_sfc_staticRenderFns,!1,null,null);const PrintDesigner_default=__component__.exports,PrintDesigner$1=Object.freeze(Object.defineProperty({__proto__:null,PrintDesigner,default:PrintDesigner_default},Symbol.toStringTag,{value:"Module"})),VERSION="0.1.0";var commonjsGlobal=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function getDefaultExportFromCjs(Ce){return Ce&&Ce.__esModule&&Object.prototype.hasOwnProperty.call(Ce,"default")?Ce.default:Ce}function getAugmentedNamespace(Ce){if(Ce.__esModule)return Ce;var Ee=Ce.default;if(typeof Ee=="function"){var Be=function Me(){return this instanceof Me?Reflect.construct(Ee,arguments,this.constructor):Ee.apply(this,arguments)};Be.prototype=Ee.prototype}else Be={};return Object.defineProperty(Be,"__esModule",{value:!0}),Object.keys(Ce).forEach(function(Me){var Se=Object.getOwnPropertyDescriptor(Ce,Me);Object.defineProperty(Be,Me,Se.get?Se:{enumerable:!0,get:function(){return Ce[Me]}})}),Be}var vuePluginHiprint$1={exports:{}},jquery={exports:{}};/*!
353
+ `,PRINT_LOCK_LINK_ID="hprint-print-lock";function injectPrintLockCss(){if(typeof document=="undefined"||document.getElementById(PRINT_LOCK_LINK_ID))return;const Ce=document.createElement("link");Ce.id=PRINT_LOCK_LINK_ID,Ce.rel="stylesheet",Ce.type="text/css",Ce.media="print",Ce.href="data:text/css;charset=utf-8,"+encodeURIComponent(rawCss),document.head.appendChild(Ce)}function http(Me,Se){return D1(this,arguments,function*(Ce,Ee,Be={}){const Pe=Ce.replace(/\/$/,"")+"/"+Ee.replace(/^\//,""),De=yield fetch(Pe,{method:Be.method||"GET",headers:wA({"Content-Type":"application/json"},Be.headers||{}),body:Be.body!==void 0?JSON.stringify(Be.body):void 0,signal:Be.signal});if(!De.ok){const je=yield De.text().catch(()=>"");throw new Error(`HTTP ${De.status} ${Be.method||"GET"} ${Ee}: ${je}`)}if(De.status!==204)return De.json()})}class RestAdapter{constructor(Ee){this.opts=Ee}listTemplates(Ee){return D1(this,null,function*(){const Be=Ee?"?"+new URLSearchParams(Ee).toString():"";return http(this.opts.baseURL,"templates"+Be)})}getTemplate(Ee){return D1(this,null,function*(){return http(this.opts.baseURL,`templates/${Ee}`)})}createTemplate(Ee){return D1(this,null,function*(){return http(this.opts.baseURL,"templates",{method:"POST",body:Ee})})}updateTemplate(Ee,Be,Me){return D1(this,null,function*(){const Se={};return Me!==void 0&&(Se["If-Match"]=String(Me)),http(this.opts.baseURL,`templates/${Ee}`,{method:"PUT",body:Be,headers:Se})})}deleteTemplate(Ee){return D1(this,null,function*(){yield http(this.opts.baseURL,`templates/${Ee}`,{method:"DELETE"})})}listFonts(){return D1(this,null,function*(){return http(this.opts.baseURL,"fonts")})}uploadFont(Ee,Be){return D1(this,null,function*(){const Me=Array.isArray(Ee)?Ee:[Ee],Se=new FormData;Me.forEach(je=>Se.append("files",je,je.name)),Se.append("name",Be.name),Se.append("family",Be.family);const Pe=this.opts.baseURL.replace(/\/$/,"")+"/fonts",De=yield fetch(Pe,{method:"POST",body:Se});if(!De.ok)throw new Error(`uploadFont failed: ${De.status}`);return De.json()})}updateFont(Ee,Be){return D1(this,null,function*(){return http(this.opts.baseURL,`fonts/${Ee}`,{method:"PUT",body:Be})})}deleteFont(Ee){return D1(this,null,function*(){yield http(this.opts.baseURL,`fonts/${Ee}`,{method:"DELETE"})})}getClientRelease(){return D1(this,null,function*(){return http(this.opts.baseURL,"client-release")})}}const HprintPlugin={install(Ce,Ee={}){injectPrintLockCss(),Ce.component(Ee.componentName||"print-designer",()=>Promise.resolve().then(()=>PrintDesigner$1));const Be=Ee.adapter||(Ee.baseURL?new RestAdapter({baseURL:Ee.baseURL}):void 0);Ce.prototype.$hprintOptions=wf(wA({},Ee),{resolvedAdapter:Be})}};class HPrintDesigner{constructor(Ee={}){this._hiprint=null,this._defaultProvider=null,this.opts=Ee}load(){return D1(this,null,function*(){if(this._hiprint)return this._hiprint;injectPrintLockCss();const Ee=yield Promise.resolve().then(()=>vuePluginHiprint);return this._hiprint=Ee.hiprint,this._defaultProvider=Ee.defaultElementTypeProvider,this._hiprint.init({host:this.opts.host||"http://localhost:17521",token:this.opts.token||"hprint-designer",lang:this.opts.lang||"cn"}),typeof Ee.disAutoConnect=="function"&&Ee.disAutoConnect(),this._hiprint})}get raw(){return this._hiprint}get defaultProvider(){return this._defaultProvider}}let _id=0;const nextId=()=>String(++_id);class MockAdapter{constructor(){this.templates=new Map,this.fonts=new Map}listTemplates(Ee){return D1(this,null,function*(){let Be=Array.from(this.templates.values());if(Ee&&Ee.keyword){const Me=String(Ee.keyword).toLowerCase();Be=Be.filter(Se=>Se.name.toLowerCase().includes(Me))}return Be.sort((Me,Se)=>Se.updatedAt.localeCompare(Me.updatedAt)),{items:Be,total:Be.length}})}getTemplate(Ee){return D1(this,null,function*(){const Be=this.templates.get(Ee);if(!Be)throw new Error(`template ${Ee} not found`);return Be})}createTemplate(Ee){return D1(this,null,function*(){const Be=wf(wA({},Ee),{id:nextId(),version:1,updatedAt:new Date().toISOString()});return this.templates.set(Be.id,Be),Be})}updateTemplate(Ee,Be,Me){return D1(this,null,function*(){const Se=this.templates.get(Ee);if(!Se)throw new Error(`template ${Ee} not found`);if(Me!==void 0&&Me!==Se.version)throw new Error(`version mismatch: expected ${Se.version}, got ${Me}`);const Pe=wf(wA(wA({},Se),Be),{id:Se.id,version:Se.version+1,updatedAt:new Date().toISOString()});return this.templates.set(Ee,Pe),Pe})}deleteTemplate(Ee){return D1(this,null,function*(){this.templates.delete(Ee)})}listFonts(){return D1(this,null,function*(){return Array.from(this.fonts.values())})}uploadFont(Ee,Be){return D1(this,null,function*(){const Me=Array.isArray(Ee)?Ee:[Ee],Se={id:nextId(),name:Be.name,family:Be.family,files:Me.map(Pe=>({format:Pe.name.split(".").pop()||"ttf",url:URL.createObjectURL(Pe),size:Pe.size})),createdAt:new Date().toISOString()};return this.fonts.set(Se.id,Se),Se})}updateFont(Ee,Be){return D1(this,null,function*(){const Me=this.fonts.get(Ee);if(!Me)throw new Error(`font ${Ee} not found`);const Se=wA(wA({},Me),Be);return this.fonts.set(Ee,Se),Se})}deleteFont(Ee){return D1(this,null,function*(){this.fonts.delete(Ee)})}getClientRelease(){return D1(this,null,function*(){return{version:"1.0.13",officialUrl:"https://github.com/CcSimple/electron-hiprint/releases",selfHostedUrl:void 0,minCompatibleVersion:"1.0.0",publishedAt:new Date().toISOString()}})}}function normalizeComponent(Ce,Ee,Be,Me,Se,Pe,De,je){var Re=typeof Ce=="function"?Ce.options:Ce;return Ee&&(Re.render=Ee,Re.staticRenderFns=Be,Re._compiled=!0),Pe&&(Re._scopeId="data-v-"+Pe),{exports:Ce,options:Re}}const _sfc_main$8={name:"Toolbar",components:{"a-button":antDesignVue.Button,"a-button-group":antDesignVue.Button.Group,"a-popconfirm":antDesignVue.Popconfirm},props:{zoomPct:{type:Number,default:100},readonly:{type:Boolean,default:!1},clientOpen:{type:Boolean,default:!1},curPaper:{type:String,default:"A4"}},data(){return{paperTypes:{A4:{width:210,height:296.6},A5:{width:210,height:147.6},Ticket:{width:80,height:130},Invitation:{width:180,height:120}}}}};var _sfc_render$8=function(){var Ee=this,Be=Ee._self._c;return Be("div",{staticClass:"hprint-designer__toolbar"},[Be("a-button-group",Ee._l(Ee.paperTypes,function(Me,Se){return Be("a-button",{key:Se,attrs:{type:Ee.curPaper===Se?"primary":"default"},on:{click:function(Pe){return Ee.$emit("set-paper",wA({type:Se},Me))}}},[Ee._v(Ee._s(Se))])}),1),Be("a-button",{attrs:{icon:"zoom-out"},on:{click:function(Me){return Ee.$emit("zoom",-1)}}}),Be("span",{staticStyle:{"min-width":"48px","text-align":"center"}},[Ee._v(Ee._s(Ee.zoomPct)+"%")]),Be("a-button",{attrs:{icon:"zoom-in"},on:{click:function(Me){return Ee.$emit("zoom",1)}}}),Be("a-button",{attrs:{icon:"reload"},on:{click:function(Me){return Ee.$emit("rotate")}}}),Be("a-button",{attrs:{icon:"eye"},on:{click:function(Me){return Ee.$emit("preview")}}}),Be("a-button",{attrs:{icon:"printer"},on:{click:function(Me){return Ee.$emit("print-browser")}}},[Ee._v("浏览器打印")]),Be("a-button",{attrs:{type:"primary",icon:"printer"},on:{click:function(Me){return Ee.$emit("print-silent")}}},[Ee._v("直接打印")]),Be("a-button",{attrs:{type:"primary"},on:{click:function(Me){return Ee.$emit("save")}}},[Ee._v("保存")]),Be("a-popconfirm",{attrs:{title:"确认清空?"},on:{confirm:function(Me){return Ee.$emit("clear")}}},[Be("a-button",{attrs:{type:"danger",icon:"close"}},[Ee._v("清空")])],1),Be("a-button",{attrs:{type:"link"},on:{click:function(Me){return Ee.$emit("open-client")}}},[Be("span",{staticClass:"hprint-designer__status-dot",class:Ee.clientOpen?"hprint-designer__status-dot--ok":"hprint-designer__status-dot--warn"}),Ee._v(" 客户端 ")]),Ee.readonly?Be("span",{staticClass:"hprint-muted"},[Ee._v("只读模式")]):Ee._e()],1)},_sfc_staticRenderFns$8=[],__component__$8=normalizeComponent(_sfc_main$8,_sfc_render$8,_sfc_staticRenderFns$8,!1,null,null);const Toolbar=__component__$8.exports,_sfc_main$7={name:"DesignCanvas"};var _sfc_render$7=function(){var Ee=this;return Ee._self._c,Ee._m(0)},_sfc_staticRenderFns$7=[function(){var Ce=this,Ee=Ce._self._c;return Ee("div",{staticClass:"hprint-designer__center"},[Ee("div",{staticClass:"hiprint-printTemplate",attrs:{id:"hprint-printTemplate"}}),Ee("div",{staticClass:"hiprint-printPagination"})])}],__component__$7=normalizeComponent(_sfc_main$7,_sfc_render$7,_sfc_staticRenderFns$7,!1,null,null);const DesignCanvas=__component__$7.exports;function getDragGroups(){return[{title:"常用组件",items:[{tid:"defaultModule.text",label:"文本",icon:"glyphicon-text-width"},{tid:"defaultModule.image",label:"图片",icon:"glyphicon-picture"},{tid:"defaultModule.longText",label:"长文",icon:"glyphicon-subscript"},{tid:"defaultModule.table",label:"表格",icon:"glyphicon-th"},{tid:"defaultModule.emptyTable",label:"空白表格",icon:"glyphicon-th"},{tid:"defaultModule.html",label:"HTML",icon:"glyphicon-header"},{tid:"defaultModule.customText",label:"自定义",icon:"glyphicon-text-width"}]},{title:"条码",items:[{tid:"defaultModule.barcode",label:"条形码",icon:"glyphicon-barcode"},{tid:"defaultModule.qrcode",label:"二维码",icon:"glyphicon-qrcode"}]},{title:"辅助图形",items:[{tid:"defaultModule.hline",label:"横线",icon:"glyphicon-resize-horizontal"},{tid:"defaultModule.vline",label:"竖线",icon:"glyphicon-resize-vertical"},{tid:"defaultModule.rect",label:"矩形",icon:"glyphicon-unchecked"},{tid:"defaultModule.oval",label:"椭圆",icon:"glyphicon-record"}]}]}const _sfc_main$6={name:"DragPanel",components:{"a-row":antDesignVue.Row,"a-col":antDesignVue.Col},data(){return{groups:getDragGroups()}},methods:{chunk(Ce,Ee){const Be=[];for(let Me=0;Me<Ce.length;Me+=Ee)Be.push(Ce.slice(Me,Me+Ee));return Be}}};var _sfc_render$6=function(){var Ee=this,Be=Ee._self._c;return Be("div",{staticClass:"hprint-designer__left"},Ee._l(Ee.groups,function(Me){return Be("div",{key:Me.title},[Be("div",{staticClass:"hprint-designer__drag-group-title"},[Ee._v(Ee._s(Me.title))]),Ee._l(Ee.chunk(Me.items,2),function(Se,Pe){return Be("a-row",{key:Pe},Ee._l(Se,function(De){return Be("a-col",{key:De.tid,attrs:{span:12}},[Be("a",{staticClass:"hprint-designer__drag-item ep-draggable-item",attrs:{tid:De.tid},on:{dragstart:function(je){return Ee.$emit("drag-start",De)}}},[Be("span",{staticClass:"glyphicon",class:De.icon,attrs:{"aria-hidden":"true"}}),Be("span",[Ee._v(Ee._s(De.label))])])])}),1)})],2)}),0)},_sfc_staticRenderFns$6=[],__component__$6=normalizeComponent(_sfc_main$6,_sfc_render$6,_sfc_staticRenderFns$6,!1,null,null);const DragPanel=__component__$6.exports,_sfc_main$5={name:"ElementProps",props:{selector:{type:String,default:"#hprint-element-setting"}},data(){return{hasSelection:!1}},mounted(){this.$on("selection-changed",Ce=>{this.hasSelection=Ce})}};var _sfc_render$5=function(){var Ee=this,Be=Ee._self._c;return Be("div",{staticClass:"hprint-element-props"},[Be("div",{attrs:{id:"hprint-element-setting"}}),Ee.hasSelection?Ee._e():Be("p",{staticClass:"hprint-muted"},[Ee._v("选中元素后在此编辑属性")])])},_sfc_staticRenderFns$5=[],__component__$5=normalizeComponent(_sfc_main$5,_sfc_render$5,_sfc_staticRenderFns$5,!1,null,"c0d94aa0");const ElementProps=__component__$5.exports;function getFormatterPresets(){return[{label:"金额 ¥#,##0.00",value:"money"},{label:"日期 YYYY-MM-DD",value:"date"},{label:"日期时间 YYYY-MM-DD HH:mm",value:"datetime"}]}const _sfc_main$4={name:"FieldPanel",components:{"a-button":antDesignVue.Button,"a-table":antDesignVue.Table,"a-modal":antDesignVue.Modal,"a-form-model":antDesignVue.FormModel,"a-form-model-item":antDesignVue.FormModel.Item,"a-input":antDesignVue.Input,"a-select":antDesignVue.Select,"a-select-option":antDesignVue.Select.Option,"a-switch":antDesignVue.Switch},props:{fields:{type:Array,default:()=>[]}},data(){return{editVisible:!1,editing:this.blankField(),formatterPresets:getFormatterPresets(),types:["string","number","date","datetime","image","qrcode","barcode","longtext"],columns:[{title:"key",dataIndex:"key"},{title:"名称",dataIndex:"label"},{title:"类型",dataIndex:"type"},{title:"操作",scopedSlots:{customRender:"action"}}]}},methods:{blankField(){return{key:"",label:"",type:"string",sample:"",group:"",required:!1}},addField(){this.editing=this.blankField(),this.editVisible=!0},saveEdit(){if(!this.editing.key){this.$message.warning("字段 key 必填");return}this.$emit("upsert-field",wA({},this.editing)),this.editVisible=!1},removeField(Ce){this.$emit("remove-field",Ce)}}};var _sfc_render$4=function(){var Ee=this,Be=Ee._self._c;return Be("div",{staticClass:"hprint-field-panel"},[Be("a-button",{attrs:{size:"small",type:"primary",icon:"plus"},on:{click:Ee.addField}},[Ee._v("新增字段")]),Be("a-table",{attrs:{"data-source":Ee.fields,columns:Ee.columns,pagination:!1,"row-key":"key",size:"small"},scopedSlots:Ee._u([{key:"action",fn:function(Me,Se){return[Be("a-button",{attrs:{size:"small",type:"link"},on:{click:function(Pe){return Ee.removeField(Se.key)}}},[Ee._v("删除")])]}}])}),Be("a-modal",{attrs:{title:"字段编辑",visible:Ee.editVisible},on:{"update:visible":function(Me){Ee.editVisible=Me},ok:Ee.saveEdit,cancel:function(Me){Ee.editVisible=!1}}},[Be("a-form-model",{attrs:{layout:"vertical"}},[Be("a-form-model-item",{attrs:{label:"字段 key"}},[Be("a-input",{model:{value:Ee.editing.key,callback:function(Me){Ee.$set(Ee.editing,"key",Me)},expression:"editing.key"}})],1),Be("a-form-model-item",{attrs:{label:"显示名"}},[Be("a-input",{model:{value:Ee.editing.label,callback:function(Me){Ee.$set(Ee.editing,"label",Me)},expression:"editing.label"}})],1),Be("a-form-model-item",{attrs:{label:"类型"}},[Be("a-select",{model:{value:Ee.editing.type,callback:function(Me){Ee.$set(Ee.editing,"type",Me)},expression:"editing.type"}},Ee._l(Ee.types,function(Me){return Be("a-select-option",{key:Me,attrs:{value:Me}},[Ee._v(Ee._s(Me))])}),1)],1),Be("a-form-model-item",{attrs:{label:"示例值"}},[Be("a-input",{model:{value:Ee.editing.sample,callback:function(Me){Ee.$set(Ee.editing,"sample",Me)},expression:"editing.sample"}})],1),Be("a-form-model-item",{attrs:{label:"分组"}},[Be("a-input",{model:{value:Ee.editing.group,callback:function(Me){Ee.$set(Ee.editing,"group",Me)},expression:"editing.group"}})],1),Be("a-form-model-item",{attrs:{label:"格式化"}},[Be("a-select",{attrs:{"allow-clear":""},model:{value:Ee.editing.formatter,callback:function(Me){Ee.$set(Ee.editing,"formatter",Me)},expression:"editing.formatter"}},Ee._l(Ee.formatterPresets,function(Me){return Be("a-select-option",{key:Me.value,attrs:{value:Me.value}},[Ee._v(Ee._s(Me.label))])}),1)],1),Be("a-form-model-item",{attrs:{label:"必填"}},[Be("a-switch",{model:{value:Ee.editing.required,callback:function(Me){Ee.$set(Ee.editing,"required",Me)},expression:"editing.required"}})],1)],1)],1)],1)},_sfc_staticRenderFns$4=[],__component__$4=normalizeComponent(_sfc_main$4,_sfc_render$4,_sfc_staticRenderFns$4,!1,null,null);const FieldPanel=__component__$4.exports,_sfc_main$3={name:"FontPanel",components:{"a-button":antDesignVue.Button,"a-list":antDesignVue.List,"a-list-item":antDesignVue.List.Item,"a-list-item-meta":antDesignVue.List.Item.Meta,"a-modal":antDesignVue.Modal,"a-form-model":antDesignVue.FormModel,"a-form-model-item":antDesignVue.FormModel.Item,"a-input":antDesignVue.Input},props:{fonts:{type:Array,default:()=>[]}},data(){return{uploadVisible:!1,meta:{name:"",family:""},files:[]}},methods:{onFileChange(Ce){this.files=Array.from(Ce.target.files||[])},doUpload(){return D1(this,null,function*(){if(!this.meta.name||!this.meta.family){antDesignVue.message.warning("名称与 font-family 必填");return}if(!this.files.length){antDesignVue.message.warning("请选择字体文件");return}this.$emit("upload-font",{files:this.files,meta:wA({},this.meta)}),this.uploadVisible=!1,this.meta={name:"",family:""},this.files=[]})},removeFont(Ce){this.$emit("remove-font",Ce)}}};var _sfc_render$3=function(){var Ee=this,Be=Ee._self._c;return Be("div",{staticClass:"hprint-font-panel"},[Be("a-button",{attrs:{size:"small",type:"primary",icon:"upload"},on:{click:function(Me){Ee.uploadVisible=!0}}},[Ee._v("上传字体")]),Be("a-list",{attrs:{"data-source":Ee.fonts,size:"small"},scopedSlots:Ee._u([{key:"renderItem",fn:function(Me){return Be("a-list-item",{},[Be("a-list-item-meta",{attrs:{title:Me.name,description:Me.family}}),Be("a",{attrs:{slot:"actions"},slot:"actions"},[Be("a-button",{attrs:{size:"small",type:"link"},on:{click:function(Se){return Ee.removeFont(Me.id)}}},[Ee._v("删除")])],1)],1)}}])}),Be("a-modal",{attrs:{title:"上传字体",visible:Ee.uploadVisible},on:{"update:visible":function(Me){Ee.uploadVisible=Me},ok:Ee.doUpload,cancel:function(Me){Ee.uploadVisible=!1}}},[Be("a-form-model",{attrs:{layout:"vertical"}},[Be("a-form-model-item",{attrs:{label:"展示名"}},[Be("a-input",{model:{value:Ee.meta.name,callback:function(Me){Ee.$set(Ee.meta,"name",Me)},expression:"meta.name"}})],1),Be("a-form-model-item",{attrs:{label:"CSS font-family"}},[Be("a-input",{model:{value:Ee.meta.family,callback:function(Me){Ee.$set(Ee.meta,"family",Me)},expression:"meta.family"}})],1),Be("a-form-model-item",{attrs:{label:"字体文件(woff2/woff/ttf,可多选)"}},[Be("input",{attrs:{type:"file",multiple:"",accept:".woff2,.woff,.ttf"},on:{change:Ee.onFileChange}})])],1)],1)],1)},_sfc_staticRenderFns$3=[],__component__$3=normalizeComponent(_sfc_main$3,_sfc_render$3,_sfc_staticRenderFns$3,!1,null,null);const FontPanel=__component__$3.exports,_sfc_main$2={name:"RightTabs",components:{"a-tabs":antDesignVue.Tabs,"a-tab-pane":antDesignVue.Tabs.TabPane,"element-props":ElementProps,"field-panel":FieldPanel,"font-panel":FontPanel},props:{fields:{type:Array,default:()=>[]},fonts:{type:Array,default:()=>[]},propsSelector:{type:String,default:"#hprint-element-setting"}},data(){return{active:"props"}},methods:{onSel(Ce){this.$emit("selection-changed",Ce)}}};var _sfc_render$2=function(){var Ee=this,Be=Ee._self._c;return Be("div",{staticClass:"hprint-designer__right"},[Be("a-tabs",{attrs:{size:"small"},model:{value:Ee.active,callback:function(Me){Ee.active=Me},expression:"active"}},[Be("a-tab-pane",{key:"props",attrs:{tab:"元素属性"}},[Be("element-props",{attrs:{selector:Ee.propsSelector},on:{"selection-changed":Ee.onSel}})],1),Be("a-tab-pane",{key:"fields",attrs:{tab:"字段管理"}},[Be("field-panel",{attrs:{fields:Ee.fields},on:{"upsert-field":function(Me){return Ee.$emit("upsert-field",Me)},"remove-field":function(Me){return Ee.$emit("remove-field",Me)}}})],1),Be("a-tab-pane",{key:"fonts",attrs:{tab:"字体管理"}},[Be("font-panel",{attrs:{fonts:Ee.fonts},on:{"upload-font":function(Me){return Ee.$emit("upload-font",Me)},"remove-font":function(Me){return Ee.$emit("remove-font",Me)}}})],1),Be("a-tab-pane",{key:"info",attrs:{tab:"模板信息"}},[Ee._t("info")],2)],1)],1)},_sfc_staticRenderFns$2=[],__component__$2=normalizeComponent(_sfc_main$2,_sfc_render$2,_sfc_staticRenderFns$2,!1,null,null);const RightTabs=__component__$2.exports;function getSocket(){return typeof window!="undefined"?window.hiwebSocket:void 0}function isClientOpen(){var Ce;return!!((Ce=getSocket())!=null&&Ce.opened)}function getClientInfo(){const Ce=getSocket();return wA({opened:!!(Ce!=null&&Ce.opened)},(Ce==null?void 0:Ce.clientInfo)||{})}function compareVersions(Ce,Ee){const Be=Ce.split(".").map(Pe=>parseInt(Pe,10)||0),Me=Ee.split(".").map(Pe=>parseInt(Pe,10)||0),Se=Math.max(Be.length,Me.length);for(let Pe=0;Pe<Se;Pe++){const De=Be[Pe]||0,je=Me[Pe]||0;if(De!==je)return De-je}return 0}function isVersionBelow(Ce,Ee){return compareVersions(Ce,Ee)<0}function detectPlatform(Ce){const Ee=((typeof navigator!="undefined"?navigator.platform:"")||"").toLowerCase();return Ee.includes("win")?"win":Ee.includes("mac")?"mac":Ee.includes("linux")?"linux":"win"}const _sfc_main$1={name:"ClientGuide",components:{"a-modal":antDesignVue.Modal,"a-alert":antDesignVue.Alert,"a-steps":antDesignVue.Steps,"a-step":antDesignVue.Steps.Step,"a-button":antDesignVue.Button,"a-space":antDesignVue.Space},props:{visible:{type:Boolean,default:!1},release:{type:Object,default:()=>({})}},data(){return{platform:detectPlatform()}},computed:{opened(){return isClientOpen()},clientVersion(){return getClientInfo().version||"未知"},statusClass(){return this.opened?"hprint-designer__status-dot--ok":"hprint-designer__status-dot--warn"},statusText(){const Ce=getClientInfo();return this.opened?`已连接 v${Ce.version} @${Ce.hostname||""}`:"未连接"},showVersionWarn(){if(!this.opened||!this.release.minCompatibleVersion)return!1;const Ce=getClientInfo().version;return Ce?isVersionBelow(Ce,this.release.minCompatibleVersion):!1}},methods:{close(){this.$emit("update:visible",!1)},downloadOfficial(){this.release.officialUrl&&window.open(this.release.officialUrl,"_blank")},downloadSelfHosted(){this.release.selfHostedUrl&&window.open(this.release.selfHostedUrl,"_blank")},launchScheme(){window.open("hiprint://","_blank")},retry(){this.$emit("retry")}}};var _sfc_render$1=function(){var Ee=this,Be=Ee._self._c;return Be("div",{staticClass:"hprint-client-guide"},[Be("a-modal",{attrs:{title:"打印客户端",visible:Ee.visible,footer:null,width:"560px"},on:{"update:visible":function(Me){Ee.visible=Me},cancel:Ee.close}},[Be("div",{staticClass:"hprint-client-status"},[Be("span",{staticClass:"hprint-designer__status-dot",class:Ee.statusClass}),Be("span",[Ee._v(Ee._s(Ee.statusText))])]),Ee.showVersionWarn?Be("a-alert",{staticStyle:{margin:"12px 0"},attrs:{type:"warning","show-icon":""}},[Be("span",{attrs:{slot:"message"},slot:"message"},[Ee._v("当前客户端版本 "+Ee._s(Ee.clientVersion)+" 过低,建议升级到 "+Ee._s(Ee.release.version))])]):Ee._e(),Be("div",{staticClass:"hprint-download-block"},[Be("a-button",{attrs:{type:"primary",size:"large",icon:"download"},on:{click:Ee.downloadOfficial}},[Ee._v(" 下载客户端("+Ee._s(Ee.platform)+") ")]),Ee.release.selfHostedUrl?Be("p",{staticClass:"hprint-muted"},[Ee._v(" 官方下载慢或不可访问? "),Be("a",{on:{click:Ee.downloadSelfHosted}},[Ee._v("使用服务端备用下载")])]):Ee._e()],1),Be("a-steps",{staticStyle:{margin:"16px 0"},attrs:{current:0,direction:"vertical",size:"small"}},[Be("a-step",{attrs:{title:"下载安装包"}}),Be("a-step",{attrs:{title:"以管理员身份运行(注册 hiprint:// 协议)"}}),Be("a-step",{attrs:{title:"运行客户端后自动回连"}})],1),Be("a-space",[Be("a-button",{attrs:{icon:"link"},on:{click:Ee.launchScheme}},[Ee._v("一键唤起已装客户端")]),Be("a-button",{attrs:{type:"primary"},on:{click:Ee.retry}},[Ee._v("我已安装,重新检测")])],1)],1)],1)},_sfc_staticRenderFns$1=[],__component__$1=normalizeComponent(_sfc_main$1,_sfc_render$1,_sfc_staticRenderFns$1,!1,null,"5d978621");const ClientGuide=__component__$1.exports,formatMap={woff2:"format('woff2')",woff:"format('woff')",ttf:"format('truetype')"},priority=["woff2","woff","ttf"];function buildFontFaceCss(Ce){return Ce.map(Ee=>{const Me=[...Ee.files].sort((Se,Pe)=>priority.indexOf(Se.format)-priority.indexOf(Pe.format)).map(Se=>`url('${Se.url}') ${formatMap[Se.format]}`).join(", ");return`@font-face { font-family: '${Ee.family}'; src: ${Me}; }`}).join(`
354
+ `)}function buildStyleHandlerCss(Ce){return buildFontFaceCss(Ce)}function toHiprintFontList(Ce){return Ce.map(Ee=>({title:Ee.name,value:Ee.family}))}const STYLE_ID="hprint-fonts";class FontManager{constructor(){this.el=null}inject(Ee){if(this.cleanup(),!Ee.length)return;const Be=buildFontFaceCss(Ee),Me=document.createElement("style");Me.id=STYLE_ID,Me.textContent=Be,document.head.appendChild(Me),this.el=Me}cleanup(){this.el&&(this.el.remove(),this.el=null)}}function buildPreviewData(Ce){const Ee={};for(const Be of Ce)Ee[Be.key]=Be.sample===void 0||Be.sample===null?"":Be.sample;return Ee}const PrintDesigner={name:"PrintDesigner",components:{"a-button":antDesignVue.Button,"a-switch":antDesignVue.Switch,toolbar:Toolbar,"design-canvas":DesignCanvas,"drag-panel":DragPanel,"right-tabs":RightTabs,"client-guide":ClientGuide},props:{templateId:{type:String,default:""},readonly:{type:Boolean,default:!1},host:{type:String,default:"http://localhost:17521"},token:{type:String,default:"hprint-designer"},adapter:{type:Object,default:null}},data(){return{designer:null,hiprint:null,template:null,tpl:null,fontMgr:new FontManager,fonts:[],fields:[],zoomPct:100,sampleOn:!0,curPaper:"A4",clientOpen:!1,clientGuideVisible:!1,clientRelease:{},_clientTimer:null,backend:null}},mounted(){return D1(this,null,function*(){this.designer=new HPrintDesigner({host:this.host,token:this.token}),this.hiprint=yield this.designer.load(),this.backend=this.adapter||this.$hprintOptions&&this.$hprintOptions.resolvedAdapter||new MockAdapter,this.fonts=yield this.backend.listFonts(),this.fontMgr.inject(this.fonts),this.templateId?this.template=yield this.backend.getTemplate(this.templateId):this.template={name:"新建模板",panels:[],fields:[],status:"draft"},this.fields=this.template.fields||[],this.initDesigner()})},beforeDestroy(){this.fontMgr.cleanup(),this._clientTimer&&clearInterval(this._clientTimer)},methods:{initDesigner(){this.hiprint.init({providers:[new this.designer.defaultProvider],host:this.host,token:this.token}),this.hiprint.PrintElementTypeManager.buildByHtml(window.$(".ep-draggable-item")),this.tpl=new this.hiprint.PrintTemplate({template:this.template.panels.length?this.template:{},settingContainer:"#hprint-element-setting",paginationContainer:".hiprint-printPagination",fontList:toHiprintFontList(this.fonts),history:!0,onDataChanged:(Ce,Ee)=>{this.$emit("data-change",{type:Ce,json:Ee})}}),this.tpl.design("#hprint-printTemplate",{grid:!0}),this.refreshPreview(),this.pollClient()},styleHandler(){return buildStyleHandlerCss(this.fonts)+"<style>.hiprint-printElement-text{}</style>"},previewData(){return this.sampleOn?buildPreviewData(this.fields):{}},refreshPreview(){if(this.tpl){const Ce=this.tpl.getHtml(this.previewData());this.$emit("data-change",{type:"preview",html:Ce})}},setPaper(Ce){this.curPaper=Ce.type||"A4",this.tpl&&this.tpl.setPaper(Ce.width,Ce.height)},onZoom(Ce){this.zoomPct=Math.max(50,Math.min(500,this.zoomPct+Ce*10)),this.tpl&&this.tpl.zoom(this.zoomPct/100)},onRotate(){this.tpl&&this.tpl.rotatePaper()},onPreview(){this.refreshPreview()},onPrintBrowser(){this.tpl&&this.tpl.print(this.previewData(),{},{styleHandler:this.styleHandler}),this.$emit("print",{mode:"browser"})},onPrintSilent(){return D1(this,null,function*(){if(!isClientOpen()){this.clientGuideVisible=!0;return}if(!this.clientRelease.version)try{this.clientRelease=yield this.backend.getClientRelease()}catch(Ce){}this.tpl&&this.tpl.print2(this.previewData(),{printer:"",title:this.template.name,styleHandler:this.styleHandler}),this.$emit("print",{mode:"silent"})})},onSave(){return D1(this,null,function*(){const Ce=this.tpl.getJson(),Ee={name:this.template.name,panels:Ce,fields:this.fields,status:this.template.status};if(this.template.id){const Be=yield this.backend.updateTemplate(this.template.id,Ee,this.template.version);this.template=Be,this.$emit("save",Be)}else{const Be=yield this.backend.createTemplate(wA({},Ee));this.template=Be,this.$emit("save",Be)}})},onClear(){this.tpl&&this.tpl.clear()},onDragStart(){},upsertField(Ce){const Ee=this.fields.findIndex(Be=>Be.key===Ce.key);Ee>=0?this.fields.splice(Ee,1,Ce):this.fields.push(Ce),this.refreshPreview()},removeField(Ce){this.fields=this.fields.filter(Ee=>Ee.key!==Ce),this.refreshPreview()},uploadFont(Be){return D1(this,arguments,function*({files:Ce,meta:Ee}){yield this.backend.uploadFont(Ce,Ee),this.fonts=yield this.backend.listFonts(),this.fontMgr.inject(this.fonts),this.tpl&&this.tpl.setFontList(toHiprintFontList(this.fonts))})},removeFont(Ce){return D1(this,null,function*(){yield this.backend.deleteFont(Ce),this.fonts=yield this.backend.listFonts(),this.fontMgr.inject(this.fonts)})},pollClient(){const Ce=()=>{this.clientOpen=isClientOpen()};Ce(),this._clientTimer=setInterval(Ce,2e3)},onClientRetry(){this.clientOpen=isClientOpen(),this.clientOpen&&(this.clientGuideVisible=!1)}}},_sfc_main=PrintDesigner;var _sfc_render=function(){var Ee=this,Be=Ee._self._c;return Ee._self._setupProxy,Be("div",{staticClass:"hprint-designer"},[Be("toolbar",{attrs:{"zoom-pct":Ee.zoomPct,readonly:Ee.readonly,"client-open":Ee.clientOpen,"cur-paper":Ee.curPaper},on:{"set-paper":Ee.setPaper,zoom:Ee.onZoom,rotate:Ee.onRotate,preview:Ee.onPreview,"print-browser":Ee.onPrintBrowser,"print-silent":Ee.onPrintSilent,save:Ee.onSave,clear:Ee.onClear,"open-client":function(Me){Ee.clientGuideVisible=!0}}}),Be("div",{staticClass:"hprint-designer__body"},[Be("drag-panel",{on:{"drag-start":Ee.onDragStart}}),Be("design-canvas",{ref:"canvas"}),Be("right-tabs",{attrs:{fields:Ee.fields,fonts:Ee.fonts},on:{"upsert-field":Ee.upsertField,"remove-field":Ee.removeField,"upload-font":Ee.uploadFont,"remove-font":Ee.removeFont}})],1),Be("div",{staticClass:"hprint-designer__footer"},[Be("a-button",{attrs:{size:"small",icon:"undo",disabled:Ee.readonly},on:{click:function(Me){return Ee.$emit("undo")}}},[Ee._v("撤销")]),Be("a-button",{attrs:{size:"small",icon:"redo",disabled:Ee.readonly},on:{click:function(Me){return Ee.$emit("redo")}}},[Ee._v("重做")]),Be("a-switch",{attrs:{"checked-children":"示例数据","un-checked-children":"空白"},on:{change:Ee.refreshPreview},model:{value:Ee.sampleOn,callback:function(Me){Ee.sampleOn=Me},expression:"sampleOn"}}),Be("span",[Ee._v("缩放 "+Ee._s(Ee.zoomPct)+"%")])],1),Be("client-guide",{attrs:{visible:Ee.clientGuideVisible,release:Ee.clientRelease},on:{"update:visible":function(Me){Ee.clientGuideVisible=Me},retry:Ee.onClientRetry}})],1)},_sfc_staticRenderFns=[],__component__=normalizeComponent(_sfc_main,_sfc_render,_sfc_staticRenderFns,!1,null,null);const PrintDesigner_default=__component__.exports,PrintDesigner$1=Object.freeze(Object.defineProperty({__proto__:null,PrintDesigner,default:PrintDesigner_default},Symbol.toStringTag,{value:"Module"})),VERSION="0.1.0";var commonjsGlobal=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function getDefaultExportFromCjs(Ce){return Ce&&Ce.__esModule&&Object.prototype.hasOwnProperty.call(Ce,"default")?Ce.default:Ce}function getAugmentedNamespace(Ce){if(Ce.__esModule)return Ce;var Ee=Ce.default;if(typeof Ee=="function"){var Be=function Me(){return this instanceof Me?Reflect.construct(Ee,arguments,this.constructor):Ee.apply(this,arguments)};Be.prototype=Ee.prototype}else Be={};return Object.defineProperty(Be,"__esModule",{value:!0}),Object.keys(Ce).forEach(function(Me){var Se=Object.getOwnPropertyDescriptor(Ce,Me);Object.defineProperty(Be,Me,Se.get?Se:{enumerable:!0,get:function(){return Ce[Me]}})}),Be}var vuePluginHiprint$1={exports:{}},jquery={exports:{}};/*!
355
355
  * jQuery JavaScript Library v3.7.1
356
356
  * https://jquery.com/
357
357
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hprint-designer",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Vue 2 print-template designer wrapping vue-plugin-hiprint — scenic tickets & invitations",
5
5
  "license": "MIT",
6
6
  "main": "dist/hprint-designer.umd.js",