yh-hiprint 2.6.2 → 2.6.4

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.
@@ -989,6 +989,8 @@ onMounted(async () => {
989
989
  });
990
990
  </script>
991
991
  <style lang="scss">
992
+ @use './libs/css/hiprint.css';
993
+ @use './libs//css/print-lock.css';
992
994
  .hiprint-designer {
993
995
  width: calc(100% + 32px);
994
996
  height: calc(100% - 30px);
@@ -1079,6 +1081,9 @@ onMounted(async () => {
1079
1081
  overflow: hidden;
1080
1082
  .el-scrollbar__view {
1081
1083
  padding: 20px 10px 40px 20px;
1084
+ #hiprint-printTemplate {
1085
+ position: relative;
1086
+ }
1082
1087
  }
1083
1088
  }
1084
1089
  &_right {
@@ -192,4 +192,7 @@ async function getData(query) {
192
192
  }
193
193
  }
194
194
  </script>
195
- <style lang="scss"></style>
195
+ <style lang="scss">
196
+ @use './libs/css/hiprint.css';
197
+ @use './libs//css/print-lock.css';
198
+ </style>
package/index.js CHANGED
@@ -105,7 +105,12 @@ const clientPrintHandler = async (code, params, data) => {
105
105
  loading = ElLoading.service({
106
106
  text: "正在获取打印模板"
107
107
  });
108
- let reqParams = params ? JSON.parse(params) : [];
108
+ let reqParams = [];
109
+ try {
110
+ reqParams = params ? JSON.parse(params) : [];
111
+ } catch (error) {
112
+ console.error(error);
113
+ }
109
114
  // 获取打印模板
110
115
  let res = await getPrintTemplate(code, reqParams);
111
116
  if (res.status !== 200 || !res.data || !res.data.json) {
@@ -151,6 +156,13 @@ const showPrinterSelectionDialog = (printerList, templateJson, templateData, tem
151
156
  return new Promise((resolve) => {
152
157
  // 获取上次选择的打印机
153
158
  const lastSelectedPrinter = localStorage.getItem('lastSelectedPrinter') || '';
159
+
160
+ let json = {};
161
+ try {
162
+ json = JSON.parse(templateJson);
163
+ } catch (error) {
164
+ console.error('客户端打印解析模板失败:', error);
165
+ }
154
166
  // 创建挂载点
155
167
  const mountPoint = document.createElement('div');
156
168
  document.body.appendChild(mountPoint);
@@ -185,7 +197,7 @@ const showPrinterSelectionDialog = (printerList, templateJson, templateData, tem
185
197
 
186
198
  try {
187
199
  // 创建打印模板实例
188
- let hiprintTemplate = new hiprint.PrintTemplate({ template: JSON.parse(templateJson) });
200
+ let hiprintTemplate = new hiprint.PrintTemplate({ template: json });
189
201
 
190
202
  loading.setText("正在发送打印任务");
191
203
 
@@ -194,8 +206,8 @@ const showPrinterSelectionDialog = (printerList, templateJson, templateData, tem
194
206
  printer: this.selectedPrinter,
195
207
  title: templateName,
196
208
  pageSize: {
197
- width: (templateJson.width || 210) * 1000,
198
- height: (templateJson.height || 297) * 1000
209
+ width: (json?.panels[0]?.width || 210) * 1000,
210
+ height: (json?.panels[0]?.height || 297) * 1000
199
211
  }
200
212
  });
201
213
 
@@ -316,7 +328,7 @@ export default {
316
328
  `连接【${clientUrl}】失败!<br>请确保已<a href="${clientApp}" target="_blank">下载</a>并<a href="hiprint://" target="_blank">运行</a>打印客户端!`,
317
329
  '客户端未连接',
318
330
  {
319
- dangerouslyUseHtmlString: true,
331
+ dangerouslyUseHTMLString: true,
320
332
  confirmButtonText: '确定'
321
333
  }
322
334
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yh-hiprint",
3
- "version": "2.6.2",
3
+ "version": "2.6.4",
4
4
  "description": "Hiprint for Vue3 by NoahLiu in ForceCon in Hunan Changesha",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",