yh-hiprint 2.6.14 → 2.6.15

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