@next-bricks/nav 1.19.1 → 1.20.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.
Files changed (92) hide show
  1. package/dist/bricks.json +1 -1
  2. package/dist/chunks/2133.98f37aac.js +2 -0
  3. package/dist/chunks/{2133.756e2e04.js.map → 2133.98f37aac.js.map} +1 -1
  4. package/dist/chunks/2252.1946803e.js +3 -0
  5. package/dist/chunks/2252.1946803e.js.map +1 -0
  6. package/dist/chunks/{3796.50b037c1.js → 3796.9b32266c.js} +3 -3
  7. package/dist/chunks/{3796.50b037c1.js.map → 3796.9b32266c.js.map} +1 -1
  8. package/dist/chunks/4185.fe4c7bfe.js +3 -0
  9. package/dist/chunks/4185.fe4c7bfe.js.map +1 -0
  10. package/dist/chunks/{4727.a0c26777.js → 4727.3539fd5e.js} +2 -2
  11. package/dist/chunks/{4727.a0c26777.js.map → 4727.3539fd5e.js.map} +1 -1
  12. package/dist/chunks/{4837.c5865dab.js → 4837.10b6260e.js} +2 -2
  13. package/dist/chunks/{4837.c5865dab.js.map → 4837.10b6260e.js.map} +1 -1
  14. package/dist/chunks/6595.7ed6ba8d.js +2 -0
  15. package/dist/chunks/{6595.bd9e01e1.js.map → 6595.7ed6ba8d.js.map} +1 -1
  16. package/dist/chunks/{7218.80bc6c0e.js → 7218.2c50aaea.js} +2 -2
  17. package/dist/chunks/{7218.80bc6c0e.js.map → 7218.2c50aaea.js.map} +1 -1
  18. package/dist/chunks/7505.bc8af307.js +2 -0
  19. package/dist/chunks/7505.bc8af307.js.map +1 -0
  20. package/dist/chunks/{8274.fa37deb0.js → 8274.2ac31d76.js} +3 -3
  21. package/dist/chunks/{8274.fa37deb0.js.map → 8274.2ac31d76.js.map} +1 -1
  22. package/dist/chunks/{9149.c981b445.js → 9149.abe30768.js} +2 -2
  23. package/dist/chunks/{9149.c981b445.js.map → 9149.abe30768.js.map} +1 -1
  24. package/dist/chunks/easyops-navbar-alerts.ce672024.js +2 -0
  25. package/dist/chunks/{easyops-navbar-alerts.a4ab065d.js.map → easyops-navbar-alerts.ce672024.js.map} +1 -1
  26. package/dist/chunks/eo-directory-tree.950a869b.js +3 -0
  27. package/dist/chunks/{eo-directory-tree.161030d2.js.map → eo-directory-tree.950a869b.js.map} +1 -1
  28. package/dist/chunks/eo-directory.e60bad48.js +3 -0
  29. package/dist/chunks/{eo-directory.8a63fdf3.js.map → eo-directory.e60bad48.js.map} +1 -1
  30. package/dist/chunks/eo-frame-breadcrumb.e49a7151.js +2 -0
  31. package/dist/chunks/{eo-frame-breadcrumb.ee00de97.js.map → eo-frame-breadcrumb.e49a7151.js.map} +1 -1
  32. package/dist/chunks/{eo-launchpad-button-v2.b06eb0f7.js → eo-launchpad-button-v2.85dd50ba.js} +3 -3
  33. package/dist/chunks/{eo-launchpad-button-v2.b06eb0f7.js.map → eo-launchpad-button-v2.85dd50ba.js.map} +1 -1
  34. package/dist/chunks/{eo-nav-menu.c6c6f3b2.js → eo-nav-menu.4827a303.js} +2 -2
  35. package/dist/chunks/{eo-nav-menu.c6c6f3b2.js.map → eo-nav-menu.4827a303.js.map} +1 -1
  36. package/dist/chunks/{eo-sidebar-menu-group.c6a274c0.js → eo-sidebar-menu-group.d02c9dca.js} +3 -3
  37. package/dist/chunks/{eo-sidebar-menu-group.c6a274c0.js.map → eo-sidebar-menu-group.d02c9dca.js.map} +1 -1
  38. package/dist/chunks/{eo-sidebar-menu-submenu.b6c0b43a.js → eo-sidebar-menu-submenu.49aba873.js} +3 -3
  39. package/dist/chunks/{eo-sidebar-menu-submenu.b6c0b43a.js.map → eo-sidebar-menu-submenu.49aba873.js.map} +1 -1
  40. package/dist/chunks/{eo-sidebar-menu.5f675037.js → eo-sidebar-menu.50034f9e.js} +2 -2
  41. package/dist/chunks/{eo-sidebar-menu.5f675037.js.map → eo-sidebar-menu.50034f9e.js.map} +1 -1
  42. package/dist/chunks/{eo-sidebar-sub-menu.96ff89b5.js → eo-sidebar-sub-menu.74a264b9.js} +3 -3
  43. package/dist/chunks/{eo-sidebar-sub-menu.96ff89b5.js.map → eo-sidebar-sub-menu.74a264b9.js.map} +1 -1
  44. package/dist/chunks/eo-sidebar.6b06933d.js +3 -0
  45. package/dist/chunks/{eo-sidebar.5fa916fb.js.map → eo-sidebar.6b06933d.js.map} +1 -1
  46. package/dist/chunks/launchpad-config.b4546023.js +3 -0
  47. package/dist/chunks/launchpad-config.b4546023.js.map +1 -0
  48. package/dist/chunks/main.4c789de6.js +2 -0
  49. package/dist/chunks/{main.577dcf1f.js.map → main.4c789de6.js.map} +1 -1
  50. package/dist/chunks/{nav-logo.d45f446c.js → nav-logo.655b630b.js} +2 -2
  51. package/dist/chunks/{nav-logo.d45f446c.js.map → nav-logo.655b630b.js.map} +1 -1
  52. package/dist/chunks/{poll-announce.f7d2378c.js → poll-announce.4c374c84.js} +3 -3
  53. package/dist/chunks/{poll-announce.f7d2378c.js.map → poll-announce.4c374c84.js.map} +1 -1
  54. package/dist/index.24313b62.js +2 -0
  55. package/dist/index.24313b62.js.map +1 -0
  56. package/dist/manifest.json +7 -1
  57. package/dist/types.json +167 -101
  58. package/dist-types/launchpad-config/MenuGroup.d.ts +4 -4
  59. package/dist-types/launchpad-config/index.d.ts +14 -4
  60. package/dist-types/launchpad-config/interfaces.d.ts +18 -12
  61. package/package.json +3 -3
  62. package/dist/chunks/2133.756e2e04.js +0 -2
  63. package/dist/chunks/2252.e1ea00e7.js +0 -3
  64. package/dist/chunks/2252.e1ea00e7.js.map +0 -1
  65. package/dist/chunks/4185.0a1811dd.js +0 -3
  66. package/dist/chunks/4185.0a1811dd.js.map +0 -1
  67. package/dist/chunks/6595.bd9e01e1.js +0 -2
  68. package/dist/chunks/7505.11d54588.js +0 -2
  69. package/dist/chunks/7505.11d54588.js.map +0 -1
  70. package/dist/chunks/easyops-navbar-alerts.a4ab065d.js +0 -2
  71. package/dist/chunks/eo-directory-tree.161030d2.js +0 -3
  72. package/dist/chunks/eo-directory.8a63fdf3.js +0 -3
  73. package/dist/chunks/eo-frame-breadcrumb.ee00de97.js +0 -2
  74. package/dist/chunks/eo-sidebar.5fa916fb.js +0 -3
  75. package/dist/chunks/launchpad-config.2707249a.js +0 -3
  76. package/dist/chunks/launchpad-config.2707249a.js.map +0 -1
  77. package/dist/chunks/main.577dcf1f.js +0 -2
  78. package/dist/index.75d2cbcd.js +0 -2
  79. package/dist/index.75d2cbcd.js.map +0 -1
  80. /package/dist/chunks/{2252.e1ea00e7.js.LICENSE.txt → 2252.1946803e.js.LICENSE.txt} +0 -0
  81. /package/dist/chunks/{3796.50b037c1.js.LICENSE.txt → 3796.9b32266c.js.LICENSE.txt} +0 -0
  82. /package/dist/chunks/{4185.0a1811dd.js.LICENSE.txt → 4185.fe4c7bfe.js.LICENSE.txt} +0 -0
  83. /package/dist/chunks/{8274.fa37deb0.js.LICENSE.txt → 8274.2ac31d76.js.LICENSE.txt} +0 -0
  84. /package/dist/chunks/{eo-directory-tree.161030d2.js.LICENSE.txt → eo-directory-tree.950a869b.js.LICENSE.txt} +0 -0
  85. /package/dist/chunks/{eo-directory.8a63fdf3.js.LICENSE.txt → eo-directory.e60bad48.js.LICENSE.txt} +0 -0
  86. /package/dist/chunks/{eo-launchpad-button-v2.b06eb0f7.js.LICENSE.txt → eo-launchpad-button-v2.85dd50ba.js.LICENSE.txt} +0 -0
  87. /package/dist/chunks/{eo-sidebar-menu-group.c6a274c0.js.LICENSE.txt → eo-sidebar-menu-group.d02c9dca.js.LICENSE.txt} +0 -0
  88. /package/dist/chunks/{eo-sidebar-menu-submenu.b6c0b43a.js.LICENSE.txt → eo-sidebar-menu-submenu.49aba873.js.LICENSE.txt} +0 -0
  89. /package/dist/chunks/{eo-sidebar-sub-menu.96ff89b5.js.LICENSE.txt → eo-sidebar-sub-menu.74a264b9.js.LICENSE.txt} +0 -0
  90. /package/dist/chunks/{eo-sidebar.5fa916fb.js.LICENSE.txt → eo-sidebar.6b06933d.js.LICENSE.txt} +0 -0
  91. /package/dist/chunks/{launchpad-config.2707249a.js.LICENSE.txt → launchpad-config.b4546023.js.LICENSE.txt} +0 -0
  92. /package/dist/chunks/{poll-announce.f7d2378c.js.LICENSE.txt → poll-announce.4c374c84.js.LICENSE.txt} +0 -0
package/dist/types.json CHANGED
@@ -2296,17 +2296,11 @@
2296
2296
  {
2297
2297
  "name": "variant",
2298
2298
  "annotation": {
2299
- "type": "union",
2300
- "types": [
2301
- {
2302
- "type": "jsLiteral",
2303
- "value": "launchpad-config"
2304
- },
2305
- {
2306
- "type": "jsLiteral",
2307
- "value": "menu-config"
2308
- }
2309
- ]
2299
+ "type": "reference",
2300
+ "typeName": {
2301
+ "type": "identifier",
2302
+ "name": "ConfigVariant"
2303
+ }
2310
2304
  }
2311
2305
  },
2312
2306
  {
@@ -2322,6 +2316,16 @@
2322
2316
  "type": "keyword",
2323
2317
  "value": "string"
2324
2318
  }
2319
+ },
2320
+ {
2321
+ "name": "blacklist",
2322
+ "annotation": {
2323
+ "type": "array",
2324
+ "elementType": {
2325
+ "type": "keyword",
2326
+ "value": "string"
2327
+ }
2328
+ }
2325
2329
  }
2326
2330
  ],
2327
2331
  "events": [
@@ -2344,6 +2348,19 @@
2344
2348
  "type": "interface",
2345
2349
  "name": "ConfigMenuGroup",
2346
2350
  "body": [
2351
+ {
2352
+ "type": "propertySignature",
2353
+ "key": {
2354
+ "type": "identifier",
2355
+ "name": "type"
2356
+ },
2357
+ "annotation": {
2358
+ "type": "jsLiteral",
2359
+ "value": "group"
2360
+ },
2361
+ "optional": true,
2362
+ "computed": false
2363
+ },
2347
2364
  {
2348
2365
  "type": "propertySignature",
2349
2366
  "key": {
@@ -2374,6 +2391,22 @@
2374
2391
  }
2375
2392
  },
2376
2393
  "computed": false
2394
+ },
2395
+ {
2396
+ "type": "propertySignature",
2397
+ "key": {
2398
+ "type": "identifier",
2399
+ "name": "blockableUrls"
2400
+ },
2401
+ "annotation": {
2402
+ "type": "array",
2403
+ "elementType": {
2404
+ "type": "keyword",
2405
+ "value": "string"
2406
+ }
2407
+ },
2408
+ "optional": true,
2409
+ "computed": false
2377
2410
  }
2378
2411
  ],
2379
2412
  "extends": [
@@ -2614,6 +2647,62 @@
2614
2647
  "value": "string"
2615
2648
  },
2616
2649
  "computed": false
2650
+ },
2651
+ {
2652
+ "type": "propertySignature",
2653
+ "key": {
2654
+ "type": "identifier",
2655
+ "name": "blockable"
2656
+ },
2657
+ "annotation": {
2658
+ "type": "keyword",
2659
+ "value": "boolean"
2660
+ },
2661
+ "optional": true,
2662
+ "computed": false,
2663
+ "description": "有可屏蔽的"
2664
+ },
2665
+ {
2666
+ "type": "propertySignature",
2667
+ "key": {
2668
+ "type": "identifier",
2669
+ "name": "hasBlocked"
2670
+ },
2671
+ "annotation": {
2672
+ "type": "keyword",
2673
+ "value": "boolean"
2674
+ },
2675
+ "optional": true,
2676
+ "computed": false,
2677
+ "description": "有可屏蔽且已屏蔽的"
2678
+ },
2679
+ {
2680
+ "type": "propertySignature",
2681
+ "key": {
2682
+ "type": "identifier",
2683
+ "name": "hasUnblocked"
2684
+ },
2685
+ "annotation": {
2686
+ "type": "keyword",
2687
+ "value": "boolean"
2688
+ },
2689
+ "optional": true,
2690
+ "computed": false,
2691
+ "description": "有可屏蔽且未屏蔽的"
2692
+ },
2693
+ {
2694
+ "type": "propertySignature",
2695
+ "key": {
2696
+ "type": "identifier",
2697
+ "name": "allBlocked"
2698
+ },
2699
+ "annotation": {
2700
+ "type": "keyword",
2701
+ "value": "boolean"
2702
+ },
2703
+ "optional": true,
2704
+ "computed": false,
2705
+ "description": "全部被屏蔽了"
2617
2706
  }
2618
2707
  ]
2619
2708
  },
@@ -2644,6 +2733,19 @@
2644
2733
  "value": "string"
2645
2734
  },
2646
2735
  "computed": false
2736
+ },
2737
+ {
2738
+ "type": "propertySignature",
2739
+ "key": {
2740
+ "type": "identifier",
2741
+ "name": "blockableUrl"
2742
+ },
2743
+ "annotation": {
2744
+ "type": "keyword",
2745
+ "value": "string"
2746
+ },
2747
+ "optional": true,
2748
+ "computed": false
2647
2749
  }
2648
2750
  ],
2649
2751
  "extends": [
@@ -2689,6 +2791,22 @@
2689
2791
  }
2690
2792
  },
2691
2793
  "computed": false
2794
+ },
2795
+ {
2796
+ "type": "propertySignature",
2797
+ "key": {
2798
+ "type": "identifier",
2799
+ "name": "blockableUrls"
2800
+ },
2801
+ "annotation": {
2802
+ "type": "array",
2803
+ "elementType": {
2804
+ "type": "keyword",
2805
+ "value": "string"
2806
+ }
2807
+ },
2808
+ "optional": true,
2809
+ "computed": false
2692
2810
  }
2693
2811
  ],
2694
2812
  "extends": [
@@ -2705,112 +2823,60 @@
2705
2823
  "type": "typeAlias",
2706
2824
  "name": "MenuAction",
2707
2825
  "annotation": {
2708
- "type": "union",
2826
+ "type": "intersection",
2709
2827
  "types": [
2710
2828
  {
2711
2829
  "type": "reference",
2712
2830
  "typeName": {
2713
2831
  "type": "identifier",
2714
- "name": "MenuSimpleAction"
2832
+ "name": "Action"
2715
2833
  }
2716
2834
  },
2717
2835
  {
2718
- "type": "reference",
2719
- "typeName": {
2720
- "type": "identifier",
2721
- "name": "MenuActionDivider"
2722
- }
2836
+ "type": "typeLiteral",
2837
+ "members": [
2838
+ {
2839
+ "type": "propertySignature",
2840
+ "key": {
2841
+ "type": "identifier",
2842
+ "name": "if"
2843
+ },
2844
+ "annotation": {
2845
+ "type": "keyword",
2846
+ "value": "unknown"
2847
+ },
2848
+ "optional": true,
2849
+ "computed": false
2850
+ }
2851
+ ]
2723
2852
  }
2724
2853
  ]
2725
2854
  }
2726
2855
  },
2727
2856
  {
2728
- "type": "interface",
2729
- "name": "MenuSimpleAction",
2730
- "body": [
2731
- {
2732
- "type": "propertySignature",
2733
- "key": {
2734
- "type": "identifier",
2735
- "name": "text"
2736
- },
2737
- "annotation": {
2738
- "type": "keyword",
2739
- "value": "string"
2740
- },
2741
- "computed": false
2742
- },
2743
- {
2744
- "type": "propertySignature",
2745
- "key": {
2746
- "type": "identifier",
2747
- "name": "event"
2748
- },
2749
- "annotation": {
2750
- "type": "keyword",
2751
- "value": "string"
2752
- },
2753
- "optional": true,
2754
- "computed": false
2755
- },
2756
- {
2757
- "type": "propertySignature",
2758
- "key": {
2759
- "type": "identifier",
2760
- "name": "if"
2761
- },
2762
- "annotation": {
2763
- "type": "keyword",
2764
- "value": "unknown"
2765
- },
2766
- "optional": true,
2767
- "computed": false
2768
- },
2769
- {
2770
- "type": "propertySignature",
2771
- "key": {
2772
- "type": "identifier",
2773
- "name": "danger"
2774
- },
2775
- "annotation": {
2776
- "type": "keyword",
2777
- "value": "boolean"
2778
- },
2779
- "optional": true,
2780
- "computed": false
2781
- }
2782
- ]
2783
- },
2784
- {
2785
- "type": "interface",
2786
- "name": "MenuActionDivider",
2787
- "body": [
2788
- {
2789
- "type": "propertySignature",
2790
- "key": {
2791
- "type": "identifier",
2792
- "name": "if"
2793
- },
2794
- "annotation": {
2795
- "type": "keyword",
2796
- "value": "unknown"
2857
+ "type": "typeAlias",
2858
+ "name": "ConfigVariant",
2859
+ "annotation": {
2860
+ "type": "union",
2861
+ "types": [
2862
+ {
2863
+ "type": "jsLiteral",
2864
+ "value": "launchpad-config"
2797
2865
  },
2798
- "optional": true,
2799
- "computed": false
2800
- },
2801
- {
2802
- "type": "propertySignature",
2803
- "key": {
2804
- "type": "identifier",
2805
- "name": "type"
2866
+ {
2867
+ "type": "jsLiteral",
2868
+ "value": "factory-launchpad-config"
2806
2869
  },
2807
- "annotation": {
2870
+ {
2808
2871
  "type": "jsLiteral",
2809
- "value": "divider"
2872
+ "value": "menu-config"
2810
2873
  },
2811
- "computed": false
2812
- }
2813
- ]
2874
+ {
2875
+ "type": "jsLiteral",
2876
+ "value": "blacklist-config"
2877
+ }
2878
+ ]
2879
+ }
2814
2880
  },
2815
2881
  {
2816
2882
  "type": "interface",
@@ -2853,7 +2919,7 @@
2853
2919
  "type": "reference",
2854
2920
  "typeName": {
2855
2921
  "type": "identifier",
2856
- "name": "MenuSimpleAction"
2922
+ "name": "MenuAction"
2857
2923
  }
2858
2924
  },
2859
2925
  "computed": false
@@ -1,9 +1,9 @@
1
1
  import React from "react";
2
- import type { ConfigMenuGroup, ConfigMenuItemDir, ConfigMenuItemNormal, MenuAction, MenuActionEventDetail } from "./interfaces";
2
+ import type { ConfigMenuGroup, ConfigMenuItemDir, ConfigMenuItemNormal, ConfigVariant, MenuAction, MenuActionEventDetail } from "./interfaces";
3
3
  export interface MenuGroupProps {
4
4
  data: ConfigMenuGroup;
5
5
  actions?: MenuAction[];
6
- variant?: "launchpad-config" | "menu-config";
6
+ variant?: ConfigVariant;
7
7
  urlTemplate?: string;
8
8
  customUrlTemplate?: string;
9
9
  onActionClick?: (detail: MenuActionEventDetail) => void;
@@ -12,7 +12,7 @@ export declare function MenuGroup({ data, actions, variant, urlTemplate, customU
12
12
  export interface MenuItemProps {
13
13
  data: ConfigMenuItemNormal;
14
14
  actions?: MenuAction[];
15
- variant?: "launchpad-config" | "menu-config";
15
+ variant?: ConfigVariant;
16
16
  urlTemplate?: string;
17
17
  customUrlTemplate?: string;
18
18
  onActionClick?: (detail: MenuActionEventDetail) => void;
@@ -21,7 +21,7 @@ export declare function MenuItem({ data, actions, variant, urlTemplate, customUr
21
21
  export interface MenuItemFolderProps {
22
22
  data: ConfigMenuItemDir;
23
23
  actions?: MenuAction[];
24
- variant?: "launchpad-config" | "menu-config";
24
+ variant?: ConfigVariant;
25
25
  urlTemplate?: string;
26
26
  customUrlTemplate?: string;
27
27
  onActionClick?: (detail: MenuActionEventDetail) => void;
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import { ReactNextElement } from "@next-core/react-element";
3
3
  import "@next-core/theme";
4
- import type { ConfigMenuGroup, MenuAction, MenuActionEventDetail } from "./interfaces";
4
+ import type { ConfigMenuGroup, ConfigVariant, MenuAction, MenuActionEventDetail } from "./interfaces";
5
5
  /**
6
6
  * 进行 Launchpad 配置。
7
7
  *
@@ -16,7 +16,7 @@ export declare class LaunchpadConfig extends ReactNextElement implements Launchp
16
16
  /**
17
17
  * @default "launchpad-config"
18
18
  */
19
- accessor variant: "launchpad-config" | "menu-config" | undefined;
19
+ accessor variant: ConfigVariant | undefined;
20
20
  /**
21
21
  * 菜单项 APP 类型的链接模板,例如可配置为 `/app/{{ id }}`。
22
22
  *
@@ -31,14 +31,24 @@ export declare class LaunchpadConfig extends ReactNextElement implements Launchp
31
31
  * `__pathname` 是运行时变量,表示 url 解析后的 pathname。
32
32
  */
33
33
  accessor customUrlTemplate: string | undefined;
34
+ /**
35
+ * 屏蔽的 URL 列表,例如可配置为 `["/app/1", "/app/2"]`。
36
+ *
37
+ * 注:仅用于 variant: "blacklist-config"。
38
+ */
39
+ accessor blacklist: string[] | undefined;
34
40
  render(): React.JSX.Element;
35
41
  }
36
42
  export interface LaunchpadConfigProps {
37
43
  menuGroups?: ConfigMenuGroup[];
38
44
  actions?: MenuAction[];
39
- variant?: "launchpad-config" | "menu-config";
45
+ variant?: ConfigVariant;
40
46
  urlTemplate?: string;
41
47
  customUrlTemplate?: string;
48
+ blacklist?: string[];
49
+ }
50
+ export interface LaunchpadConfigComponentProps extends LaunchpadConfigProps {
51
+ variant: ConfigVariant;
42
52
  onActionClick?: (detail: MenuActionEventDetail) => void;
43
53
  }
44
- export declare function LaunchpadConfigComponent({ menuGroups, actions, variant, urlTemplate, customUrlTemplate, onActionClick, }: LaunchpadConfigProps): React.JSX.Element;
54
+ export declare function LaunchpadConfigComponent({ menuGroups, actions, variant, urlTemplate, customUrlTemplate, blacklist, onActionClick, }: LaunchpadConfigComponentProps): React.JSX.Element;
@@ -1,8 +1,11 @@
1
1
  import { AppLocales } from "@next-core/types";
2
2
  import type { LegacyAntdIcon, MenuIcon } from "@next-shared/general/types";
3
+ import type { Action } from "@next-bricks/basic/actions";
3
4
  export interface ConfigMenuGroup extends ConfigMenuBase {
5
+ type?: "group";
4
6
  order?: number;
5
7
  items: ConfigMenuItem[];
8
+ blockableUrls?: string[];
6
9
  }
7
10
  export type ConfigMenuItem = ConfigMenuItemNormal | ConfigMenuItemDir;
8
11
  export type ConfigMenuItemNormal = ConfigMenuItemApp | ConfigMenuItemCustom;
@@ -14,10 +17,12 @@ export interface ConfigMenuItemApp extends ConfigMenuItemBase {
14
17
  export interface ConfigMenuItemCustom extends ConfigMenuItemBase {
15
18
  type: "custom";
16
19
  url: string;
20
+ blockableUrl?: string;
17
21
  }
18
22
  export interface ConfigMenuItemDir extends ConfigMenuItemBase {
19
23
  type: "dir";
20
24
  items: ConfigMenuItemNormal[];
25
+ blockableUrls?: string[];
21
26
  }
22
27
  interface ConfigMenuItemBase extends ConfigMenuBase {
23
28
  type: "app" | "custom" | "dir";
@@ -28,20 +33,21 @@ interface ConfigMenuBase {
28
33
  id: string;
29
34
  name: string;
30
35
  instanceId: string;
31
- }
32
- export type MenuAction = MenuSimpleAction | MenuActionDivider;
33
- export interface MenuSimpleAction {
34
- text: string;
35
- event?: string;
36
- if?: unknown;
37
- danger?: boolean;
38
- }
39
- export interface MenuActionDivider {
36
+ /** 有可屏蔽的 */
37
+ blockable?: boolean;
38
+ /** 有可屏蔽且已屏蔽的 */
39
+ hasBlocked?: boolean;
40
+ /** 有可屏蔽且未屏蔽的 */
41
+ hasUnblocked?: boolean;
42
+ /** 全部被屏蔽了 */
43
+ allBlocked?: boolean;
44
+ }
45
+ export type MenuAction = Action & {
40
46
  if?: unknown;
41
- type: "divider";
42
- }
47
+ };
43
48
  export interface MenuActionEventDetail {
44
49
  data: ConfigMenuGroup | ConfigMenuItem;
45
- action: MenuSimpleAction;
50
+ action: MenuAction;
46
51
  }
52
+ export type ConfigVariant = "launchpad-config" | "factory-launchpad-config" | "menu-config" | "blacklist-config";
47
53
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@next-bricks/nav",
3
- "version": "1.19.1",
3
+ "version": "1.20.1",
4
4
  "homepage": "https://github.com/easyops-cn/next-advanced-bricks/tree/master/bricks/nav",
5
5
  "repository": {
6
6
  "type": "git",
@@ -35,7 +35,7 @@
35
35
  "postpublish": "mv package.json.bak package.json"
36
36
  },
37
37
  "devDependencies": {
38
- "@next-core/build-next-bricks": "^1.23.9",
38
+ "@next-core/build-next-bricks": "^1.23.10",
39
39
  "@next-core/test-next": "^1.1.8"
40
40
  },
41
41
  "peerDependencies": {
@@ -43,5 +43,5 @@
43
43
  "@next-bricks/form": "*",
44
44
  "@next-bricks/icons": "*"
45
45
  },
46
- "gitHead": "bd20e7cd3c0d30cd3048f4bde97e7f67090ab8bd"
46
+ "gitHead": "fc3f65ad13d569a7d95dac05da00f993d595aebf"
47
47
  }
@@ -1,2 +0,0 @@
1
- "use strict";(globalThis.webpackChunk_next_bricks_nav=globalThis.webpackChunk_next_bricks_nav||[]).push([[2133],{2133:(e,t,n)=>{n.d(t,{fm:()=>M,ir:()=>x,pU:()=>O,sZ:()=>N});var a=n(8769),o=n(6201),s=n(962),i=n(7137),r=n(4864),c=n(9393),l=n(3346),u=n(7296),p=n(2824),d=n(2887),m=n(8406),f=n(1030);const h=10,I=10;var y,g=n(6659);async function v(){return(await(0,u.K)({page:1,pageSize:h},{interceptorParams:{ignoreLoadingBar:!0},noAbortOnRouteChange:!0})).list}function w(e,t){return e.id.toLowerCase().includes(t)||e.name.toLowerCase().includes(t)||e.description&&e.description.toLowerCase().includes(t)?e:null}function k(e,t){return e.id.toLowerCase().includes(t)||e.name.toLowerCase().includes(t)||e.description&&e.description.toLowerCase().includes(t)?e:null}const A=`launchpad-recent-visits:${null===(y=s.auth.getAuth())||void 0===y?void 0:y.org}`,F=new i.G(localStorage);let b=[],C=new Map,B=new Map,S=!1,P=[],E=!1,L=[],_=!1;const x=new r.x((async()=>{({menuGroups:b,microAppsById:C,customLinksById:B}=await async function(){var e;const t=await(0,l.i)({},{interceptorParams:{ignoreLoadingBar:!0},noAbortOnRouteChange:!0}),n=new Map;for(const e of t.storyboards){var a;const t=e.app;t.localeName=(0,g.F)(t.locales,t.name),null!==(a=s.auth.isBlockedPath)&&void 0!==a&&a.call(s.auth,t.homepage)||n.set(t.id,t)}const o=[],i=new Map;for(const a of t.desktops){const t=[];for(const o of a.items)switch(o.type){case"app":{const e=n.get(o.id);e&&t.push({...o,name:e.localeName,url:e.homepage,menuIcon:e.menuIcon});break}case"custom":null!==(e=s.auth.isBlockedHref)&&void 0!==e&&e.call(s.auth,o.url)||(t.push(o),i.set(o.id,o));break;case"dir":{const e=[];for(const t of o.items){var r;if("app"===t.type){const a=n.get(t.id);a&&e.push({...t,name:a.localeName,url:a.homepage,menuIcon:a.menuIcon})}else"custom"!==t.type||null!==(r=s.auth.isBlockedHref)&&void 0!==r&&r.call(s.auth,t.url)||(e.push(t),i.set(t.id,t))}e.length>0&&t.push({...o,items:e});break}}t.length>0&&o.push({...a,items:t})}return{menuGroups:o,microAppsById:n,customLinksById:i}}()),S=!0})),M=new r.x((async()=>{P=await async function(){const e=await v(),t=[];for(const n of e)if("microApp"===n.type){const e=n.relatedApp;e.localeName=(0,g.F)(e.locales,e.name),t.push({favoriteId:n.instanceId,type:"app",name:e.localeName,id:e.appId,url:e.homepage,instanceId:e.instanceId,menuIcon:e.menuIcon})}else if("customItem"===n.type){const e=n.relatedCustomItem;t.push({favoriteId:n.instanceId,type:"custom",name:e.name,id:e.id,url:e.url,menuIcon:e.menuIcon})}else"link"===n.type&&t.push({favoriteId:n.instanceId,type:"link",name:n.name,url:n.link,menuIcon:n.icon});return t}(),E=!0})),O=new r.x((async()=>{L=await async function(){const e=(await(0,m.y)("MICRO_APP_CATEGORY@EASYOPS",{fields:["id","type","name","icon","order","platformApps.appId","platformApps.name","platformApps.homepage","platformApps.description","platformApps.menuIcon","platformApps.locales","platformApps._object_id","platformApps.@.order","platformItems.id","platformItems.name","platformItems.url","platformItems.description","platformItems.menuIcon","platformItems._object_id","platformItems.@.order"],page:1,page_size:300,query:{type:"platform"}})).list,t=null==e?void 0:e.map((e=>{const t=e.platformApps.map((e=>{var t,n;return null!==(t=s.auth.isBlockedPath)&&void 0!==t&&t.call(s.auth,e.homepage)?null:{type:"app",name:(0,g.F)(e.locales,e.name),id:e.appId,url:e.homepage,menuIcon:e.menuIcon,description:e.description,instanceId:e.instanceId,order:null===(n=e["@"])||void 0===n?void 0:n.order}})).filter(Boolean),n=e.platformItems.map((e=>{var t,n;return null!==(t=s.auth.isBlockedHref)&&void 0!==t&&t.call(s.auth,e.url)?null:{type:"custom",name:e.name,id:e.id,url:e.url,menuIcon:e.menuIcon,description:e.description,instanceId:e.instanceId,order:null===(n=e["@"])||void 0===n?void 0:n.order}})).filter(Boolean),a=(0,f.sortBy)([...t,...n],"order");return{instanceId:e.instanceId,id:e.id,name:e.name,icon:e.icon,order:e.order,items:a}}));return[{id:"#all",name:"全部",icon:{lib:"easyops",category:"second-menu",icon:"sprint-planning-second-menu"},items:[]},...(0,f.sortBy)(t,"order")]}(),_=!0})),T=e=>(0,c.Ds)({type:"error",message:(0,o.httpErrorToString)(e)});function N(e){const[t,n]=(0,a.useState)(b),[s,i]=(0,a.useState)(C),[r,l]=(0,a.useState)(B),[u,m]=(0,a.useState)(""),[f,y]=(0,a.useState)(!S),[g,N]=(0,a.useState)(!E),[j,G]=(0,a.useState)(!_),[q,H]=(0,a.useState)([]),[z,D]=(0,a.useState)([]),[V,Y]=(0,a.useState)(P),[$,K]=(0,a.useState)(L);(0,a.useEffect)((()=>{e&&!f&&(n(b),i(C),l(B))}),[e,f]),(0,a.useEffect)((()=>{e&&!g&&Y(P)}),[e,g]),(0,a.useEffect)((()=>{e&&!j&&K(L)}),[e,j]),(0,a.useEffect)((()=>{var t;e&&H(null!==(t=F.getItem(A))&&void 0!==t?t:[])}),[e]),(0,a.useEffect)((()=>{e&&(async()=>{try{await x.fetch(),y(!1)}catch(e){(0,o.handleHttpError)(e)}})()}),[e]),(0,a.useEffect)((()=>{e&&(async()=>{try{await M.fetch(),N(!1)}catch(e){N(!1),T(e)}})()}),[e]),(0,a.useEffect)((()=>{var t;e&&null!==(t=(0,o.getRuntime)())&&void 0!==t&&t.getFeatureFlags()["launchpad-show-platform-category"]&&(async()=>{try{await O.fetch(),G(!1)}catch(e){G(!1),T(e)}})()}),[e]),(0,a.useEffect)((()=>{if(f)return;const e=q.map((e=>{if("app"===e.type){const t=s.get(e.id);return t?{type:"app",name:t.localeName,id:t.id,url:t.homepage,instanceId:t.instanceId,menuIcon:t.menuIcon}:null}return r.get(e.id)})).filter(Boolean);D(e)}),[r,f,s,q]);const Q=(0,a.useCallback)((e=>{var t;let{type:n,id:a}=e;const o=null!==(t=F.getItem(A))&&void 0!==t?t:[],s=o.findIndex((e=>e.type===n&&e.id===a));s>-1&&o.splice(s,1),o.unshift({type:n,id:a}),o.length>I&&o.pop(),F.setItem(A,o)}),[]),U=(0,a.useCallback)((e=>V.some((t=>R(e,t)))),[V]),Z=(0,a.useCallback)((e=>{const t=V.findIndex((t=>"link"===e.type?t.favoriteId===e.favoriteId:R(e,t)));let n;if(t>-1){const e=V[t];n=V.slice(0,t).concat(V.slice(t+1)),async function(e){return e.favoriteId?(0,d.r)(e.favoriteId):v().then((t=>{var n;const a=null===(n=t.find((t=>{var n,a;return"app"===e.type?"microApp"===t.type&&(null===(n=t.relatedApp)||void 0===n?void 0:n.appId)===e.id:"custom"===e.type&&(null===(a=t.relatedCustomItem)||void 0===a?void 0:a.id)===e.id})))||void 0===n?void 0:n.instanceId;if(a)return(0,d.r)(a);console.error("Menu item to unstar not found:",e)}))}(e).catch(T)}else{if(V.length>=h)return void(0,c.ui)({type:"warn",title:"收藏数量已达上限",content:`当前收藏链接数量已达上限(${h}个),请删除部分收藏后再添加。`});const t={...e};n=V.concat(t),async function(e){return(0,p.k)({type:"app"===e.type?"microApp":"customItem",relatedInstanceId:e.instanceId},{interceptorParams:{ignoreLoadingBar:!0}})}(e).then((e=>{e&&(t.favoriteId=e.instanceId)}),T)}Y(n),P=n}),[V]),J=(0,a.useMemo)((()=>function(e,t){if(!t)return e;const n=t.toLowerCase();return e.map((e=>({...e,items:e.items.map((e=>{switch(e.type){case"app":return w(e,n);case"custom":return k(e,n);case"dir":{const t=e.items.map((e=>"app"===e.type?w(e,n):"custom"===e.type?k(e,n):null)).filter(Boolean);return t.length>0?{...e,items:t}:null}}})).filter(Boolean)}))).filter((e=>e.items.length>0))}(t,u)),[t,u]),W=(0,a.useMemo)((()=>function(e,t){if(!t)return e;const n=t.toLowerCase();return e.map((e=>({...e,items:e.items.map((e=>{switch(e.type){case"app":return w(e,n);case"custom":return k(e,n)}})).filter(Boolean)})))}($,u)),[$,u]);return{loading:f,q:u,setQ:m,menuGroups:J,loadingFavorites:g,loadingPlatformCategories:j,favorites:V,recentVisits:z,pushRecentVisit:Q,isStarred:U,toggleStar:Z,platformCategories:W}}function R(e,t){return e.instanceId&&t.instanceId?t.instanceId===e.instanceId:t.type===e.type&&t.id===e.id}},9393:(e,t,n)=>{n.d(t,{Bj:()=>s,Ds:()=>c,EM:()=>i,ui:()=>r});var a=n(9006),o=n(2729);const s=(0,a.wrapBrick)("eo-icon"),i=(0,a.wrapBrick)("eo-link"),r=(0,o.unwrapProvider)("basic.show-dialog"),c=(0,o.unwrapProvider)("basic.show-notification")},4864:(e,t,n)=>{n.d(t,{x:()=>o});var a=n(4586);class o{constructor(e){(0,a.A)(this,"preFetchId",null),(0,a.A)(this,"preFetchScheduled",!1),(0,a.A)(this,"firstFetchPromise",null),(0,a.A)(this,"isFetching",!1),(0,a.A)(this,"task",void 0),this.task=e}schedulePrefetch(){if(!this.preFetchScheduled){this.preFetchScheduled=!0;const e=async()=>{this.preFetchId=null,this.fetch()};"function"==typeof window.requestIdleCallback?this.preFetchId=window.requestIdleCallback(e):this.preFetchId=setTimeout(e)}}fetch(e){let t;return this.preFetchId&&("function"==typeof window.cancelIdleCallback?cancelIdleCallback(this.preFetchId):clearTimeout(this.preFetchId),this.preFetchId=null),this.isFetching&&!e||(this.isFetching=!0,t=this.task(),t.catch((e=>{console.error(e),this.firstFetchPromise=null})).finally((()=>{this.isFetching=!1})),this.firstFetchPromise||(this.firstFetchPromise=t),!e)?this.firstFetchPromise:t}}},6659:(e,t,n)=>{n.d(t,{F:()=>o});var a=n(3324);function o(e,t){var n;if(!e)return t;const o=Object.fromEntries(Object.entries(e).filter((e=>{let[t,n]=e;return n.name})).map((e=>{let[t,n]=e;return[t,n.name]})));return null!==(n=(0,a.i18nText)(o))&&void 0!==n?n:t}}}]);
2
- //# sourceMappingURL=2133.756e2e04.js.map
@@ -1,3 +0,0 @@
1
- /*! For license information please see 2252.e1ea00e7.js.LICENSE.txt */
2
- "use strict";(globalThis.webpackChunk_next_bricks_nav=globalThis.webpackChunk_next_bricks_nav||[]).push([[2252],{2559:(e,t,n)=>{function r(e,t,n){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:n;throw new TypeError("Private element is not present on this object")}n.d(t,{A:()=>r})},6330:(e,t,n)=>{function r(e,t,n,r,o,i,s){try{var a=e[i](s),c=a.value}catch(e){return void n(e)}a.done?t(c):Promise.resolve(c).then(r,o)}function o(e){return function(){var t=this,n=arguments;return new Promise((function(o,i){var s=e.apply(t,n);function a(e){r(s,o,i,a,c,"next",e)}function c(e){r(s,o,i,a,c,"throw",e)}a(void 0)}))}}n.d(t,{A:()=>o})},2016:(e,t,n)=>{function r(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}n.d(t,{A:()=>r})},829:(e,t,n)=>{n.d(t,{A:()=>o});var r=n(2559);function o(e,t){return e.get((0,r.A)(e,t))}},918:(e,t,n)=>{n.d(t,{A:()=>o});var r=n(2016);function o(e,t,n){(0,r.A)(e,t),t.set(e,n)}},6121:(e,t,n)=>{n.d(t,{A:()=>o});var r=n(2559);function o(e,t,n){return e.set((0,r.A)(e,t),n),n}},5536:(e,t,n)=>{n.d(t,{A:()=>o});var r=n(2559);function o(e,t,n){return n((0,r.A)(e,t))}},4635:(e,t,n)=>{n.d(t,{A:()=>o});var r=n(2016);function o(e,t){(0,r.A)(e,t),t.add(e)}},4586:(e,t,n)=>{n.d(t,{A:()=>o});var r=n(1369);function o(e,t,n){return(t=(0,r.A)(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}},9740:(e,t,n)=>{n.d(t,{A:()=>i});var r=n(4586);function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function i(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach((function(t){(0,r.A)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}},2252:(e,t,n)=>{n.r(t),n.d(t,{analytics:()=>u,auth:()=>vt,checkInstalledApps:()=>o,checkPermissions:()=>mt,flowApi:()=>i,menu:()=>s,messageDispatcher:()=>gt});var r={};n.r(r),n.d(r,{authenticate:()=>v,getAuth:()=>A,isBlockedHref:()=>I,isBlockedPath:()=>b,isBlockedUrl:()=>S,isLoggedIn:()=>y,logout:()=>w});var o={};n.r(o),n.d(o,{getCheckedApp:()=>ae,preCheckInstalledApps:()=>ie,waitForCheckingApps:()=>se});var i={};n.r(i),n.d(i,{FLOW_API_PROVIDER:()=>ue,clearCollectWidgetContract:()=>be,clearDebugContract:()=>Ie,collectContract:()=>we,collectDebugContract:()=>Se,collectWidgetContract:()=>ye,getArgsOfFlowApi:()=>ke,isFlowApiProvider:()=>Pe,registerFlowApiProvider:()=>de});var s={};n.r(s),n.d(s,{fetchMenuById:()=>Ke,getMenuById:()=>Ye});var a={};n.r(a),n.d(a,{onRequest:()=>lt,onResponse:()=>pt,onResponseError:()=>dt});var c={};n.r(c),n.d(c,{create:()=>ht});var u={};n.r(u),n.d(u,{http:()=>a,initialize:()=>ct,pageView:()=>c});var l=n(6376),p=n(6330),d=n(1361),f=function(){var e=(0,p.A)((function*(e,t){return(yield d.http.post("api/gateway/micro_app.permission.ValidatePermissions/api/micro_app/v1/permission/validate",e,t)).data}));return function(t,n){return e.apply(this,arguments)}}(),h=n(6201),m=n(1732);const g={};function v(e){Object.assign(g,{org:e.org,username:e.username,userInstanceId:e.userInstanceId,loginFrom:e.loginFrom,accessRule:e.accessRule,isAdmin:e.isAdmin,csrfToken:e.csrfToken,license:e.license,accessToken:e.accessToken,userShowValue:e.userShowValue})}function A(){return{...g}}function w(){for(const e of Object.keys(g))g[e]=void 0;O.clear(),P.length=0,k.clear()}function y(){return void 0!==g.username}function b(e){var t;return!(null===(t=g.license)||void 0===t||null===(t=t.blackList)||void 0===t||!t.some((t=>(0,h.matchPath)(e,{path:t}))))}function S(e){const t=("string"==typeof e?(0,m.createLocation)(e):e).pathname;return"string"==typeof t&&b(t)}function I(e){const t=(0,h.getBasePath)(),n=new URL(e,`${location.origin}${t}`);return!(n.origin!==location.origin||!n.pathname.startsWith(t))&&b(n.pathname.substring(t.length-1))}const O=new Map,P=[],k=new Map;function E(e){if(y()&&!A().isAdmin)return M((0,l.scanPermissionActionsInAny)(e))}async function M(e){const t=e.filter((e=>!P.includes(e)));if(0===t.length)return;const n=[],r=[];for(const e of t){const t=O.get(e);t?n.push(t):r.push(e)}if(r.length>0){const e=(async()=>{try{const e=await f({actions:r},{noAbortOnRouteChange:!0});for(const t of e.actions)k.set(t.action,t.authorizationStatus),"undefined"===t.authorizationStatus&&console.error(`Undefined permission action: "${t.action}"`)}catch(e){console.error("Pre-check permissions failed",e)}finally{P.push(...r)}})();for(const t of r)O.set(t,e);n.push(e)}await Promise.all(n)}var C=n(4635),T=n(918),_=n(5536),j=n(2559),N=n(6121),$=n(829),D=n(1030);const R=1e3,W=5;var L=new WeakMap,B=new WeakMap,x=new WeakMap,U=new WeakMap,F=new WeakMap,q=new WeakMap,z=new WeakMap,H=new WeakSet;class G{constructor(e){(0,C.A)(this,H),(0,T.A)(this,L,void 0),(0,T.A)(this,B,void 0),(0,T.A)(this,x,[]),(0,T.A)(this,U,new Set),(0,T.A)(this,F,new Set),(0,T.A)(this,q,0),(0,T.A)(this,z,!1),(0,N.A)(L,this,e)}send(e){(0,$.A)(B,this)||(0,N.A)(B,this,(0,j.A)(H,this,J).call(this));const t=JSON.stringify(e);(0,$.A)(B,this).readyState===WebSocket.OPEN?(0,$.A)(B,this).send(t):(0,$.A)(x,this).push(t)}onMessage(e){return(0,$.A)(U,this).add(e),()=>{(0,$.A)(U,this).delete(e)}}onClose(e){return(0,$.A)(F,this).add(e),()=>{(0,$.A)(F,this).delete(e)}}reset(){(0,$.A)(x,this).length=0,(0,$.A)(U,this).clear(),(0,$.A)(F,this).clear()}close(){var e;(0,N.A)(z,this,!0),(null===(e=(0,$.A)(B,this))||void 0===e?void 0:e.readyState)===WebSocket.OPEN&&(0,$.A)(B,this).close()}}function J(){console.log("WebSocket connecting ...");const e=new WebSocket((0,$.A)(L,this));let t;return e.addEventListener("open",(n=>{console.log("WebSocket open:",n),t=setTimeout((()=>{t=void 0,(0,N.A)(q,this,0)}),1e3);for(const t of(0,$.A)(x,this))e.send(t);(0,$.A)(x,this).length=0})),e.addEventListener("close",(e=>{(0,$.A)(z,this)||(void 0!==t&&clearTimeout(t),console.log("WebSocket close:",e),1e3!==e.code&&(0,j.A)(H,this,V).call(this))})),e.addEventListener("error",(e=>{console.error("WebSocket error:",e)})),e.addEventListener("message",(e=>{const t=JSON.parse(e.data);for(const e of(0,$.A)(U,this))e(t)})),e}function V(){if((0,$.A)(q,this)>=W){console.error("WebSocket connect retry limit exceeded");for(const e of(0,$.A)(F,this))e();return}const e=Math.pow(2,(0,$.A)(q,this))*R;console.log("WebSocket will reconnect after %d seconds",e/1e3),setTimeout((()=>{var e;(0,N.A)(q,this,(e=(0,$.A)(q,this),++e)),(0,N.A)(B,this,(0,j.A)(H,this,J).call(this))}),e)}var Y=new WeakMap,K=new WeakMap,Q=new WeakMap,X=new WeakSet;function Z(e){if(!(0,$.A)(Y,e)){const t=`${"https:"===location.protocol?"wss:":"ws:"}//${window.location.host}${(0,h.getBasePath)()}api/websocket_service/v1/ws`;(0,N.A)(Y,e,new G(t))}return(0,$.A)(Y,e)}function ee(e,t,n,r){const o=(0,$.A)(K,this)[e].get(r);if(o)return o;const i={event:"sub"===e?"TOPIC.SUB":"TOPIC.UNSUB",payload:n},s=new Promise(((t,r)=>{const o=te(n),s=(0,_.A)(X,this,Z).onMessage((n=>{const i=n.event===("sub"===e?"TOPIC.SUB_SUCCESS":"TOPIC.UNSUB_SUCCESS"),c=n.event===("sub"===e?"TOPIC.SUB_FAILED":"TOPIC.UNSUB_FAILED");(i||c)&&o===te(n.payload)&&((i?t:r)(n),s(),a())})),a=(0,_.A)(X,this,Z).onClose((()=>{r({retryCount:W}),s(),a()}));(0,_.A)(X,this,Z).send(i)}));return"sub"===e&&(0,$.A)(Q,this).set(t,r),(0,$.A)(K,this)[e].set(r,s),s}function te(e){const{system:t,topic:n}=e;return JSON.stringify({system:t,topic:n})}var ne=function(){var e=(0,p.A)((function*(e,t){return(yield d.http.post("api/gateway/micro_app_standalone.runtime.SearchMicroAppStandalone/api/v1/micro_app_standalone/search",e,t)).data}));return function(t,n){return e.apply(this,arguments)}}();const re=new Map,oe=new Map;function ie(e,t){if(window.STANDALONE_MICRO_APPS&&!window.NO_AUTH_GUARD){const n=function(e){var t;const n={usedArgs:new Set},{customTemplates:r,menus:o}=null!==(t=e.meta)&&void 0!==t?t:{};return(0,l.traverseStoryboardExpressions)([e.routes,r,o],((e,t)=>{(0,l.collectInstalledAppsHasUsage)(n,e,t)}),"INSTALLED_APPS"),[...n.usedArgs]}(e),r=[];for(const e of n)re.has(e)||t(e)||r.push(e);if(0===r.length)return;const o=ne({query:{appId:{$in:r}},fields:["appId","currentVersion","installStatus"]}).catch((e=>{console.error("Get off site standalone micro-apps failed",e)}));for(const e of r)re.set(e,o.then((t=>{var n;const r=null==t||null===(n=t.list)||void 0===n?void 0:n.find((t=>t.appId===e)),o=r?{...r,id:e}:void 0;return oe.set(e,o),o})))}}async function se(e){await Promise.all(e.map((e=>re.get(e))))}function ae(e){if(window.STANDALONE_MICRO_APPS)return oe.get(e)}var ce=n(2729);const ue="core.provider-flow-api";function le(e,t){return e.some((e=>e.source===t))}async function pe(e){let{url:t,originalUri:n,method:r="GET",responseWrapper:o=!0,ext_fields:i=[],request:s,isFileType:a,stream:c}=e;const u=["get","delete","head"].includes(r.toLowerCase()),l=a?{responseType:"blob"}:{};let p;for(var f=arguments.length,h=new Array(f>1?f-1:0),m=1;m<f;m++)h[m-1]=arguments[m];if(u){var g,v,A,w;let e,o;var y,b;if(n&&"object"===(null==s?void 0:s.type)&&(null!==(g=null===(v=n.match(/:([^/]+)/g))||void 0===v?void 0:v.length)&&void 0!==g?g:0)===(null!==(A=null===(w=s.fields)||void 0===w?void 0:w.length)&&void 0!==A?A:0)?[o]=h:[e,o]=h,c)return await(0,ce.createSSEStream)(d.http.getUrlWithParams(t,e),{...l,...o,method:r,headers:Object.fromEntries([...new Headers(null!==(y=null===(b=o)||void 0===b?void 0:b.headers)&&void 0!==y?y:{}).entries()])});p=await d.http.simpleRequest(r,t,{params:e,...l,...o})}else{const e=function(e){if("object"!==(null==e?void 0:e.type))return!1;const t=e=>!(0,D.isEmpty)(e)&&e.some((e=>["file","file[]"].includes(e.type)||t(e.fields)));return t(e.fields)}(s),n=function(e){const t=le(e,"query"),n=le(e,"body");for(var r=arguments.length,o=new Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];if(t){if(n){const[e,t,n]=o;return{data:e,options:{params:t,...n}}}const[e,t]=o;return{data:{},options:{params:e,...t}}}const[s,a]=o;return{data:s,options:a}}(i,...h),o=e?function(e){if(e instanceof FormData)return e;const t=new FormData;for(const[n,r]of Object.entries(e))Array.isArray(r)?r.forEach((e=>{t.append(n,e)})):!(0,D.isObject)(r)||r instanceof Blob||r instanceof Date?t.append(n,r):Object.entries(r).forEach((e=>{let[r,o]=e;t.append(`${n}[${r}]`,o)}));return t}(n.data):n.data;if(c){var S;const{body:e,headers:i}=d.http.getBodyAndHeaders(o,null===(S=n.options)||void 0===S?void 0:S.headers);return await(0,ce.createSSEStream)(t,{...l,...n.options,method:r,headers:Object.fromEntries([...new Headers(null!=i?i:{}).entries()]),body:e})}p=await d.http.requestWithBody(r,t,o,{...l,...n.options})}return!a&&o?p.data:p}function de(){customElements.define(ue,(0,ce.createProviderClass)(pe))}var fe=n(5310);const he=async(e,t)=>(await d.http.post("api/contract/single_search",e,t)).data,me=new Map,ge=new Map,ve=new Map,Ae=(e,t)=>{null==e||e.forEach((e=>{t.set(`${e.namespaceId}.${e.name}`,e)}))};function we(e){Ae(e,me)}function ye(e){Ae(e,ge)}function be(){ge.clear()}function Se(e){Ae(e,ve)}function Ie(){ve.clear()}const Oe=new Map;function Pe(e){return e.includes("@")}async function ke(e,t,n,r){if(!e.includes(":"))throw new Error(`You're using legacy Custom API "${e}" which is dropped in v3, please use Flow API instead`);const o=await async function(e){const[t,n]=e.split("@"),[r,o]=n.split(":"),i=function(e){return me.get(e)||ge.get(e)||ve.get(e)}(`${t}.${r}`);if(i)return{name:i.name,namespace:i.namespaceId,serviceName:i.serviceName,version:i.version,contract:{endpoint:i.endpoint,response:i.response,request:i.request}};let s=Oe.get(e);return s||(s=async function(e,t,n){var r;const{contractData:o}=await he({contractName:`${e}.${t}`,version:n});return o?{name:o.name,namespace:null===(r=o.namespace)||void 0===r||null===(r=r[0])||void 0===r?void 0:r.name,serviceName:o.serviceName,version:o.version,contract:{endpoint:o.endpoint,response:o.response,request:o.request}}:null}(t,r,o),Oe.set(e,s)),s}(e);if(!o)throw new Ee(`Flow API not found: "${e}"`);const i=function(e,t){var n,r;const o="string"==typeof t.contract?fe.safeLoad(t.contract,{schema:fe.JSON_SCHEMA,json:!0}):t.contract,{uri:i,method:s="GET",ext_fields:a}=null!==(n=null==o?void 0:o.endpoint)&&void 0!==n?n:{},c=!(null==o||!o.response)&&!1!==o.response.wrapper;if(!i)throw new Error(`Missing endpoint.uri in contract of provider "${e}"`);return{uri:i,method:"list"===s.toLowerCase()?"get":s,ext_fields:a,name:t.name,namespace:t.namespace,serviceName:t.serviceName,version:t.version,isFileType:"file"===(null==o||null===(r=o.response)||void 0===r?void 0:r.type),responseWrapper:c,request:null==o?void 0:o.request}}(e,o);return function(e,t,n,r){let{uri:o,method:i,ext_fields:s,name:a,namespace:c,serviceName:u,responseWrapper:l,version:p,isFileType:d,request:f}=e;const h="saveAs"===n;let m;h&&(m=t.shift());const{url:g,args:v}=function(e,t,n,r,o,i){const s=i?"logic.api.gateway"===o||null!=o&&o.startsWith("logic.api.gateway.")?"":o?`api/gateway/${o}`:`api/gateway/${r}.${n}@${i}`:`api/gateway/api_service.${r}.${n}`,a=t.slice(),c=e.replace(/:([^/]+)/g,(()=>a.shift()));return{url:s?s+c:c.replace(/^\//,""),args:a}}(o,t,a,c,u,p);return[...h?[m]:[],{url:g,originalUri:o,method:i,ext_fields:s,responseWrapper:l,request:f,isFileType:d,stream:r},...v]}(i,t,n,r)}class Ee extends Error{constructor(e){super(e),this.name="FlowApiNotFoundError",Error.captureStackTrace&&Error.captureStackTrace(this,Ee)}}var Me=function(){var e=(0,p.A)((function*(e,t,n){return(yield d.http.post("api/gateway/cmdb.instance.PostSearch/object/".concat(e,"/instance/_search"),t,n)).data}));return function(t,n,r){return e.apply(this,arguments)}}(),Ce=n(9740),Te=function(){var e=(0,p.A)((function*(e,t,n){return(yield d.http.get("api/gateway/micro_app.installed_micro_app.GetMenusInfo/api/v1/micro-app/menus/".concat(e),(0,Ce.A)((0,Ce.A)({},n),{},{params:t}))).data}));return function(t,n,r){return e.apply(this,arguments)}}(),_e=n(3324);const je=Symbol("appId"),Ne=Symbol("menuI18nNamespace"),$e=Symbol("overrideApp");async function De(e,t,n){const r=e.find((e=>"inject"!==e.type));if(!r)return;const o=[],i=new Map,s=new WeakMap;for(const t of e)if(t.i18n){const e=`menu/${t.menuId}~${t.app[0].appId}+${t.instanceId}`;Object.entries(t.i18n).forEach((t=>{let[n,r]=t;_e.i18n.addResourceBundle(n,e,r)})),s.set(t,e)}await Promise.all(e.map((e=>async function(e,t,n,r){if(e.dynamicItems&&e.itemsResolve){const i=e.app[0].appId,s={...t,pendingPermissionsPreCheck:[...t.pendingPermissionsPreCheck,E(e.itemsResolve)]};var o;i!==t.app.id&&(s.overrideApp=window.STANDALONE_MICRO_APPS?e.overrideApp:null===(o=r.getStoryboardByAppId(i))||void 0===o?void 0:o.app,s.appendI18nNamespace=n.get(e));const a=await r.resolveData({transform:"items",...e.itemsResolve},s);e.items=a.items}}(e,t,s,n))));for(const t of e){var a;if(null!==(a=t.items)&&void 0!==a&&a.length)if("inject"===t.type&&t.injectMenuGroupId){let e=i.get(t.injectMenuGroupId);e||(e=[],i.set(t.injectMenuGroupId,e)),e.push(t)}else o.push(t)}return{...r,items:o.flatMap((e=>Re(e.items,e,i,s))),[Ne]:s.get(r),[$e]:r.overrideApp}}function Re(e,t,n,r){return null==e?void 0:e.map((e=>{var o;const i=e.groupId&&n.get(e.groupId);return i&&n.delete(e.groupId),{...e,children:(null!==(o=Re(e.children,t,n,r))&&void 0!==o?o:[]).concat(i?i.flatMap((e=>Re(e.items,e,n,r))):[]),[je]:t.app[0].appId,[Ne]:r.get(t),[$e]:t.overrideApp}}))}function We(e){e.items=Le(e.items)}function Le(e){return function(e){return(0,D.sortBy)(e,(e=>{var t;return null!==(t=e.sort)&&void 0!==t?t:-1/0}))}(e).map((e=>({...e,children:Le(e.children)})))}var Be=n(9933),xe=n(1321);function Ue(e,t,n,r){if("titleDataSource"in e&&(0,ce.isObject)(e.titleDataSource)&&Object.entries(e.titleDataSource).every((e=>{let[,t]=e;return null===t||""===t}))&&delete e.titleDataSource,"if"in e&&null===e.if&&delete e.if,"to"in e&&e.to&&!(0,xe.isEvaluable)(e.to)){const t=Be.pipes.yaml(e.to);(0,ce.isObject)(t)&&["pathname","search","hash"].some((e=>(0,ce.hasOwnProperty)(t,e)))&&(e.to=t)}let o=n;if(t!==n.app.id){var i;const s=window.STANDALONE_MICRO_APPS?e[$e]:null===(i=r.getStoryboardByAppId(t))||void 0===i?void 0:i.app;o={...n,overrideApp:s,appendI18nNamespace:e[Ne]}}return r.asyncComputeRealValue(e,o,{ignoreSymbols:!0})}function Fe(e,t,n){return Promise.all(e.map((async e=>{let{children:r,...o}=e;const[i,s]=await Promise.all([Ue(o,o[je],t,n),r&&await Fe(r,t,n)]);return{...i,children:s}})))}var qe=function(){var e=(0,p.A)((function*(e,t,n,r){return(yield d.http.get("api/gateway/cmdb.instance.GetDetail/object/".concat(e,"/instance/").concat(t),(0,Ce.A)((0,Ce.A)({},r),{},{params:n}))).data}));return function(t,n,r,o){return e.apply(this,arguments)}}();const ze=new Map;async function He(e){if(e.title||(0,D.isEmpty)(e.titleDataSource))return e.title;const t=JSON.stringify(e.titleDataSource),n=ze.get(t);if(void 0!==n)return n;const{objectId:r,instanceId:o,attributeId:i}=e.titleDataSource,s=null!=i?i:"name",a=await qe(r,o,{fields:s});let c;if("#showKey"===i&&Array.isArray(a[s])){const[e,...t]=a[s];c=t.length>0?`${e}(${t.join(",")})`:String(e)}else c=String(a[s]);return ze.set(t,c),c}const Ge=new Map,Je=new Map;function Ve(e){return null==e?void 0:e.filter(h.checkIfOfComputed).map((e=>{const t=Ve(e.children);return"group"===e.type?{type:"group",title:e.text,childLayout:e.childLayout,items:t,groupId:e.groupId,groupFrom:e.groupFrom}:null!=t&&t.length?{type:"subMenu",childLayout:e.childLayout,title:e.text,icon:e.icon,items:t,defaultExpanded:e.defaultExpanded}:function(e){return e.href?I(e.href):!!e.to&&S(e.to)}(e)?null:(0,D.omit)(e,["type","items","children"])})).filter(Boolean)}function Ye(e){return Je.get(e)}function Ke(e,t,n){let r=Ge.get(e);return r||(r=async function(e,t,n){const r=window.STANDALONE_MICRO_APPS?function(e,t,n){var r,o,i,s;const a=n.getStoryboardByAppId(t);return(null!==(r=null!==(o=null===(i=a.meta)||void 0===i?void 0:i.injectMenus)&&void 0!==o?o:null===(s=a.meta)||void 0===s?void 0:s.menus)&&void 0!==r?r:[]).filter((t=>t.menuId===e)).map((e=>{var n;return{...e,...null!==(n=e.app)&&void 0!==n&&null!==(n=n[0])&&void 0!==n&&n.appId?{}:{app:[{appId:t}]}}}))}(e,t.app.id,n):t.flags["three-level-menu-layout"]?(await Te(e,{menuObjectId:"EASYOPS_STORYBOARD_MENU"})).menus:(await Me("EASYOPS_STORYBOARD_MENU",{page:1,page_size:200,fields:{menuId:!0,title:!0,icon:!0,link:!0,titleDataSource:!0,defaultCollapsed:!0,defaultCollapsedBreakpoint:!0,type:!0,injectMenuGroupId:!0,dynamicItems:!0,itemsResolve:!0,items:!0,i18n:!0,"items.children":!0,"app.appId":!0},query:{menuId:{$eq:e},app:{$size:{$gt:0}}}})).list,o=await De(r,t,n);if(!o)throw new Error(`Menu not found: ${e}`);We(o);const{items:i,app:s,...a}=o,c={...t,pendingPermissionsPreCheck:[...t.pendingPermissionsPreCheck,E([i,a])]};delete c.tplStateStoreId,delete c.forEachItem,delete c.forEachIndex,delete c.forEachSize;const u=s[0].appId,[l,p]=await Promise.all([Ue(a,u,c,n),Fe(i,c,n)]),d={title:await He(l),...(0,D.pick)(l,["icon","link","defaultCollapsed","defaultCollapsedBreakpoint"]),menuItems:Ve(p)};Je.set(e,d)}(e,t,n)),r}const Qe=[];let Xe=null;const Ze={maxWaitingTime:5e3,maxLoggedEvents:10};function et(){clearTimeout(Xe),Qe.length>Ze.maxLoggedEvents?tt():Xe=setTimeout(tt,Ze.maxWaitingTime)}function tt(){if(0===Qe.length)return;const e={model:"easyops.FRONTEND_STAT",columns:["_ver","st","et","lt","size","time","traceId","code","duration","page","uid","username","api","type","msg","status","pageId","route","apiCount","maxApiTimeCost","apiSizeCost","pageTitle"],data:Qe.splice(0,Ze.maxLoggedEvents)};var t;!function(e,t){const n=new Blob([JSON.stringify(t)],{type:"application/json"});window.navigator.sendBeacon(e,n)}(Ze.api,e),Qe.length&&(t=tt,(window.requestIdleCallback||window.requestAnimationFrame||(e=>setTimeout(e,17)))(t))}function nt(){window.addEventListener("beforeunload",tt,!1)}let rt,ot=!1,it=null,st=!0;const at=[];function ct(e){ot||(ot=!0,rt||(rt=function(e,t){return Object.assign(Ze,{...t,api:e}),{sendOnExit:nt,emit:et}}(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}),rt.sendOnExit()))}const ut=Symbol("HttpAnalytics");function lt(e){const t=Math.round(performance.now()),n=Date.now();return e[ut]={st:n,time:Math.round(n/1e3),perfStartTime:t},e}function pt(e,t){return ft(!1,e,t)}function dt(e,t){return ft(!0,e,t)}function ft(e,t,n){const r=Math.round(performance.now()),o=Date.now(),{[ut]:i,url:s}=n;if(i&&!(e&&t instanceof d.HttpAbortError)){var a,c,u;delete n[ut];const{st:p,time:f,perfStartTime:h}=i,{userInstanceId:m,username:g}=A();let v,w,y,b,S,I,O;if(e){const e=t instanceof d.HttpResponseError;(e||t instanceof d.HttpParseError)&&(({status:S,headers:I}=t.response),e&&(O=t.responseJson))}else({status:S,data:O,headers:I}=t);(0,ce.isObject)(O)&&({code:v,message:w}=O),I instanceof Headers&&(y=I.get("x-b3-traceid"),b=I.get("content-length")),l={st:p,_ver:p,uid:m,username:g,time:f,et:o,page:location.href,duration:r-h,api:s,type:"api",code:null!==(a=v)&&void 0!==a?a:-1,msg:null!==(c=w)&&void 0!==c?c:"",status:S,traceId:null!==(u=y)&&void 0!==u?u:"",size:b?Number(b):-1},it?Qe.push({...l,type:"apiRequest",...it}):at.push(l)}var l;return e?Promise.reject(t):t}function ht(){const e=Math.round(performance.now()),t=Date.now();return at.length=0,it=null,function(n){let{status:r,path:o,pageTitle:i}=n;if("ok"!==r)return Qe.push(...at),void(at.length=0);const s=Math.round(performance.now())-e,a=Date.now(),{username:c}=A();(function(e){const t=function(){const e=URL.createObjectURL(new Blob([]));let t=e.substring(e.lastIndexOf("/")+1);return URL.revokeObjectURL(e),st&&(t="88-"+t,st=!1),t}(),{lt:n,route:r}=e;it={lt:n,route:r,pageId:t},Qe.push({...e,pageId:t,apiCount:at.length,maxApiTimeCost:Math.max(0,...at.map((e=>e.duration))),size:at.map((e=>e.size)).filter((e=>e>0)).reduce(((e,t)=>e+t),0)});for(const e of at)Qe.push({...e,...it});at.length=0,rt.emit()})({type:"page",page:location.href,_ver:t,time:Math.round(t/1e3),st:t,et:a,lt:s,pageTitle:i,username:c,route:o}),window.dispatchEvent(new CustomEvent("route.render",{detail:{renderTime:s}}))}}const mt=Object.freeze({checkPermissions:function(){if(!y())return!1;if(A().isAdmin)return!0;for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];for(const e of t)switch(k.get(e)){case"unauthorized":case"undefined":return!1;case void 0:return console.error(`Un-checked permission action: "${e}", please make sure the permission to check is defined in permissionsPreCheck.`),!1}return!0},preCheckPermissions:function(e){if(y()&&!A().isAdmin)return M((0,l.scanPermissionActionsInStoryboard)(e))},preCheckPermissionsForBrickOrRoute:async function(e,t){if(y()&&!A().isAdmin&&Array.isArray(e.permissionsPreCheck))return M(await t(e.permissionsPreCheck))}}),gt=new class{constructor(){(0,C.A)(this,X),(0,T.A)(this,Y,void 0),(0,T.A)(this,K,{sub:new Map,unsub:new Map}),(0,T.A)(this,Q,new Map)}subscribe(e,t){const n=JSON.stringify(t);return(0,j.A)(X,this,ee).call(this,"sub",e,t,n)}unsubscribe(e){const t=(0,$.A)(Q,this).get(e);if(!t){const t=`The message channel to unsubscribe "${e}" is not found`;return console.error(t),Promise.reject(new Error(t))}const n=JSON.parse(t),r=(0,j.A)(X,this,ee).call(this,"unsub",e,n,t);return(0,$.A)(K,this).sub.delete(t),r.then((()=>{(0,$.A)(Q,this).delete(e)})),r}onMessage(e,t){let n=(0,$.A)(Q,this).get(e),r=!1;return(0,_.A)(X,this,Z).onMessage((o=>{n||(n=(0,$.A)(Q,this).get(e)),n?"MESSAGE.PUSH"===o.event&&function(e,t){const n=JSON.parse(e);return n.system===t.system&&(n.topic===t.topic||"string"==typeof n.topic&&n.topic.includes("*")&&new RegExp(`^${n.topic.replace(/([^*]*)\*([^*]*)/g,((e,t,n)=>`${(0,D.escapeRegExp)(t)}[^/]*${(0,D.escapeRegExp)(n)}`))}$`).test(t.topic))}(n,o.payload)&&t(o.payload.message):r||(console.error(`Message channel: "${e}" not found`),r=!0)}))}onClose(e){return(0,_.A)(X,this,Z).onClose(e)}reset(){var e;(0,$.A)(K,this).sub.clear(),(0,$.A)(K,this).unsub.clear(),(0,$.A)(Q,this).clear(),null===(e=(0,$.A)(Y,this))||void 0===e||e.reset()}},vt=function(){const e=(0,h.getV2RuntimeFromDll)();if(e)return Object.freeze((0,D.pick)(e,["authenticate","getAuth","isLoggedIn","logout","isBlockedPath","isBlockedUrl","isBlockedHref"]))}()||r}}]);
3
- //# sourceMappingURL=2252.e1ea00e7.js.map