yh-hiprint 2.6.14 → 2.6.16

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.
Files changed (2) hide show
  1. package/index.ts +50 -23
  2. package/package.json +2 -2
package/index.ts CHANGED
@@ -9,6 +9,7 @@ import {
9
9
  ElMessage,
10
10
  } from 'element-plus';
11
11
  import {createApp, createVNode} from 'vue';
12
+ import {Router} from "vue-router"
12
13
  import {
13
14
  hiprint,
14
15
  defaultElementTypeProvider,
@@ -191,9 +192,11 @@ const silentHiprint = async ({
191
192
  (window as unknown as CustomWindow).silentHiprint = silentHiprint;
192
193
 
193
194
  interface InstallOptions {
194
- router?: any;
195
+ router?: Router | undefined;
195
196
  pinia?: any;
196
197
  isAdmin?: boolean;
198
+ isNew?: boolean;
199
+ addInitTask: (cl:any) => void
197
200
  }
198
201
 
199
202
  // 客户端打印处理函数
@@ -480,33 +483,57 @@ import printCss from './libs/css/hiprint.css?inline';
480
483
  export default {
481
484
  install(
482
485
  app: any,
483
- {router, pinia, isAdmin, clientPrint = false}: InstallOptions & {clientPrint?: boolean}
486
+ {router, pinia, clientPrint = false,isNew = false, addInitTask}: InstallOptions & {clientPrint?: boolean}
484
487
  ): void {
485
488
  app.provide('$hiprint', hiprintFun);
486
489
  app.provide('$silentHiprint', silentHiprint);
487
490
 
488
- if (router) {
489
- router.addRoute('Index', {
490
- path: 'hiprint/designer',
491
- name: '打印设计器',
492
- meta: {
493
- icon: 'md-planet',
494
- title: '打印设计器',
495
- },
496
- component: () => import('./HiprintDesigner.vue'),
497
- });
498
- router.addRoute({
499
- path: '/preview',
500
- name: 'printView',
501
- meta: {
502
- icon: 'md-planet',
503
- title: 'printView',
504
- },
505
- component: () => import('./hiprintPreview.vue'),
506
- });
491
+ if(isNew) {
492
+ addInitTask(async () => {
493
+ if (!router || !router.hasRoute('Index')) return;
494
+ router.addRoute('Index', {
495
+ path: 'hiprint/designer',
496
+ name: '打印设计器',
497
+ meta: {
498
+ icon: 'md-planet',
499
+ title: '打印设计器',
500
+ },
501
+ component: () => import('./HiprintDesigner.vue'),
502
+ });
503
+ router.addRoute({
504
+ path: '/preview',
505
+ name: 'printView',
506
+ meta: {
507
+ icon: 'md-planet',
508
+ title: 'printView',
509
+ },
510
+ component: () => import('./hiprintPreview.vue'),
511
+ });
512
+ })
507
513
  } else {
508
- if (!router) {
509
- cLog('没有传递 router 对象,所以无法将路由添加到应用中', true);
514
+ if (router) {
515
+ router.addRoute('Index', {
516
+ path: 'hiprint/designer',
517
+ name: '打印设计器',
518
+ meta: {
519
+ icon: 'md-planet',
520
+ title: '打印设计器',
521
+ },
522
+ component: () => import('./HiprintDesigner.vue'),
523
+ });
524
+ router.addRoute({
525
+ path: '/preview',
526
+ name: 'printView',
527
+ meta: {
528
+ icon: 'md-planet',
529
+ title: 'printView',
530
+ },
531
+ component: () => import('./hiprintPreview.vue'),
532
+ });
533
+ } else {
534
+ if (!router) {
535
+ cLog('没有传递 router 对象,所以无法将路由添加到应用中', true);
536
+ }
510
537
  }
511
538
  }
512
539
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yh-hiprint",
3
- "version": "2.6.14",
3
+ "version": "2.6.16",
4
4
  "description": "Hiprint for Vue3 by NoahLiu in ForceCon in Hunan Changesha",
5
5
  "type": "module",
6
6
  "exports": {
@@ -26,4 +26,4 @@
26
26
  "element-plus": "^2.9.0"
27
27
  },
28
28
  "author": "Liubin"
29
- }
29
+ }