@next-bricks/nav 1.22.9 → 1.23.0

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 (69) hide show
  1. package/dist/bricks.json +26 -26
  2. package/dist/chunks/2133.8c2de8bf.js +2 -0
  3. package/dist/chunks/2133.8c2de8bf.js.map +1 -0
  4. package/dist/chunks/2241.f4e16879.js +3 -0
  5. package/dist/chunks/2241.f4e16879.js.map +1 -0
  6. package/dist/chunks/4433.37b5f4d3.js +2 -0
  7. package/dist/chunks/4433.37b5f4d3.js.map +1 -0
  8. package/dist/chunks/4691.5e4633d7.js +3 -0
  9. package/dist/chunks/4691.5e4633d7.js.map +1 -0
  10. package/dist/chunks/9149.447c2c4f.js +2 -0
  11. package/dist/chunks/9149.447c2c4f.js.map +1 -0
  12. package/dist/chunks/9363.e198a81d.js +3 -0
  13. package/dist/chunks/9363.e198a81d.js.map +1 -0
  14. package/dist/chunks/{eo-launchpad-button-v2.927f72d2.js → eo-launchpad-button-v2.2924d210.js} +3 -3
  15. package/dist/chunks/eo-launchpad-button-v2.2924d210.js.map +1 -0
  16. package/dist/chunks/eo-launchpad-button.ca77a7df.js +3 -0
  17. package/dist/chunks/eo-launchpad-button.ca77a7df.js.map +1 -0
  18. package/dist/chunks/eo-launchpad-quick-access.d6349d06.js +3 -0
  19. package/dist/chunks/eo-launchpad-quick-access.d6349d06.js.map +1 -0
  20. package/dist/chunks/eo-launchpad-recent-visits.49228467.js +3 -0
  21. package/dist/chunks/eo-launchpad-recent-visits.49228467.js.map +1 -0
  22. package/dist/chunks/{eo-search-launchpad.3c5eb6d6.js → eo-search-launchpad.393d7776.js} +2 -2
  23. package/dist/chunks/eo-search-launchpad.393d7776.js.map +1 -0
  24. package/dist/chunks/launchpad-config.b5571d5c.js +3 -0
  25. package/dist/chunks/launchpad-config.b5571d5c.js.map +1 -0
  26. package/dist/chunks/{main.5f7d6c2d.js → main.687699fb.js} +2 -2
  27. package/dist/chunks/{main.5f7d6c2d.js.map → main.687699fb.js.map} +1 -1
  28. package/dist/examples.json +3 -3
  29. package/dist/index.682ed3ce.js +2 -0
  30. package/dist/index.682ed3ce.js.map +1 -0
  31. package/dist/manifest.json +51 -51
  32. package/dist/types.json +161 -161
  33. package/dist-types/launchpad-button-v2/i18n.d.ts +26 -0
  34. package/dist-types/launchpad-button-v2/interfaces.d.ts +12 -9
  35. package/dist-types/launchpad-config/interfaces.d.ts +1 -1
  36. package/dist-types/shared/getLocaleName.d.ts +1 -1
  37. package/package.json +2 -2
  38. package/dist/chunks/2133.a757ee32.js +0 -2
  39. package/dist/chunks/2133.a757ee32.js.map +0 -1
  40. package/dist/chunks/3796.3de4054c.js +0 -3
  41. package/dist/chunks/3796.3de4054c.js.map +0 -1
  42. package/dist/chunks/4433.14cd7c8d.js +0 -2
  43. package/dist/chunks/4433.14cd7c8d.js.map +0 -1
  44. package/dist/chunks/4691.0ea6af77.js +0 -3
  45. package/dist/chunks/4691.0ea6af77.js.map +0 -1
  46. package/dist/chunks/9149.1010c337.js +0 -2
  47. package/dist/chunks/9149.1010c337.js.map +0 -1
  48. package/dist/chunks/9363.ef03e062.js +0 -3
  49. package/dist/chunks/9363.ef03e062.js.map +0 -1
  50. package/dist/chunks/eo-launchpad-button-v2.927f72d2.js.map +0 -1
  51. package/dist/chunks/eo-launchpad-button.350d864f.js +0 -3
  52. package/dist/chunks/eo-launchpad-button.350d864f.js.map +0 -1
  53. package/dist/chunks/eo-launchpad-quick-access.d31fac62.js +0 -3
  54. package/dist/chunks/eo-launchpad-quick-access.d31fac62.js.map +0 -1
  55. package/dist/chunks/eo-launchpad-recent-visits.e9d9813f.js +0 -3
  56. package/dist/chunks/eo-launchpad-recent-visits.e9d9813f.js.map +0 -1
  57. package/dist/chunks/eo-search-launchpad.3c5eb6d6.js.map +0 -1
  58. package/dist/chunks/launchpad-config.48bac834.js +0 -3
  59. package/dist/chunks/launchpad-config.48bac834.js.map +0 -1
  60. package/dist/index.b95ce968.js +0 -2
  61. package/dist/index.b95ce968.js.map +0 -1
  62. /package/dist/chunks/{3796.3de4054c.js.LICENSE.txt → 2241.f4e16879.js.LICENSE.txt} +0 -0
  63. /package/dist/chunks/{4691.0ea6af77.js.LICENSE.txt → 4691.5e4633d7.js.LICENSE.txt} +0 -0
  64. /package/dist/chunks/{9363.ef03e062.js.LICENSE.txt → 9363.e198a81d.js.LICENSE.txt} +0 -0
  65. /package/dist/chunks/{eo-launchpad-button-v2.927f72d2.js.LICENSE.txt → eo-launchpad-button-v2.2924d210.js.LICENSE.txt} +0 -0
  66. /package/dist/chunks/{eo-launchpad-button.350d864f.js.LICENSE.txt → eo-launchpad-button.ca77a7df.js.LICENSE.txt} +0 -0
  67. /package/dist/chunks/{eo-launchpad-quick-access.d31fac62.js.LICENSE.txt → eo-launchpad-quick-access.d6349d06.js.LICENSE.txt} +0 -0
  68. /package/dist/chunks/{eo-launchpad-recent-visits.e9d9813f.js.LICENSE.txt → eo-launchpad-recent-visits.49228467.js.LICENSE.txt} +0 -0
  69. /package/dist/chunks/{launchpad-config.48bac834.js.LICENSE.txt → launchpad-config.b5571d5c.js.LICENSE.txt} +0 -0
package/dist/types.json CHANGED
@@ -1,4 +1,9 @@
1
1
  {
2
+ "nav.easyops-navbar-alerts": {
3
+ "properties": [],
4
+ "events": [],
5
+ "methods": []
6
+ },
2
7
  "eo-app-bar-wrapper": {
3
8
  "properties": [
4
9
  {
@@ -228,8 +233,19 @@
228
233
  "events": [],
229
234
  "methods": []
230
235
  },
231
- "nav.easyops-navbar-alerts": {
232
- "properties": [],
236
+ "eo-sidebar-sub-menu": {
237
+ "properties": [
238
+ {
239
+ "name": "menu",
240
+ "annotation": {
241
+ "type": "reference",
242
+ "typeName": {
243
+ "type": "identifier",
244
+ "name": "SidebarMenu"
245
+ }
246
+ }
247
+ }
248
+ ],
233
249
  "events": [],
234
250
  "methods": []
235
251
  },
@@ -543,22 +559,6 @@
543
559
  }
544
560
  ]
545
561
  },
546
- "eo-sidebar-sub-menu": {
547
- "properties": [
548
- {
549
- "name": "menu",
550
- "annotation": {
551
- "type": "reference",
552
- "typeName": {
553
- "type": "identifier",
554
- "name": "SidebarMenu"
555
- }
556
- }
557
- }
558
- ],
559
- "events": [],
560
- "methods": []
561
- },
562
562
  "nav.nav-logo": {
563
563
  "properties": [],
564
564
  "events": [],
@@ -713,7 +713,7 @@
713
713
  ],
714
714
  "methods": []
715
715
  },
716
- "nav.get-menu-config-options": {
716
+ "nav.get-menu-config-tree": {
717
717
  "type": "provider",
718
718
  "params": [
719
719
  {
@@ -746,7 +746,7 @@
746
746
  "type": "reference",
747
747
  "typeName": {
748
748
  "type": "identifier",
749
- "name": "MenuOption"
749
+ "name": "TreeNode"
750
750
  }
751
751
  }
752
752
  }
@@ -1072,13 +1072,13 @@
1072
1072
  },
1073
1073
  {
1074
1074
  "type": "interface",
1075
- "name": "MenuOption",
1075
+ "name": "TreeNode",
1076
1076
  "body": [
1077
1077
  {
1078
1078
  "type": "propertySignature",
1079
1079
  "key": {
1080
1080
  "type": "identifier",
1081
- "name": "label"
1081
+ "name": "key"
1082
1082
  },
1083
1083
  "annotation": {
1084
1084
  "type": "keyword",
@@ -1090,13 +1090,102 @@
1090
1090
  "type": "propertySignature",
1091
1091
  "key": {
1092
1092
  "type": "identifier",
1093
- "name": "value"
1093
+ "name": "title"
1094
1094
  },
1095
1095
  "annotation": {
1096
1096
  "type": "keyword",
1097
1097
  "value": "string"
1098
1098
  },
1099
1099
  "computed": false
1100
+ },
1101
+ {
1102
+ "type": "propertySignature",
1103
+ "key": {
1104
+ "type": "identifier",
1105
+ "name": "icon"
1106
+ },
1107
+ "annotation": {
1108
+ "type": "keyword",
1109
+ "value": "unknown"
1110
+ },
1111
+ "optional": true,
1112
+ "computed": false
1113
+ },
1114
+ {
1115
+ "type": "propertySignature",
1116
+ "key": {
1117
+ "type": "identifier",
1118
+ "name": "faded"
1119
+ },
1120
+ "annotation": {
1121
+ "type": "keyword",
1122
+ "value": "unknown"
1123
+ },
1124
+ "optional": true,
1125
+ "computed": false
1126
+ },
1127
+ {
1128
+ "type": "propertySignature",
1129
+ "key": {
1130
+ "type": "identifier",
1131
+ "name": "children"
1132
+ },
1133
+ "annotation": {
1134
+ "type": "array",
1135
+ "elementType": {
1136
+ "type": "reference",
1137
+ "typeName": {
1138
+ "type": "identifier",
1139
+ "name": "TreeNode"
1140
+ }
1141
+ }
1142
+ },
1143
+ "optional": true,
1144
+ "computed": false
1145
+ },
1146
+ {
1147
+ "type": "propertySignature",
1148
+ "key": {
1149
+ "type": "identifier",
1150
+ "name": "data"
1151
+ },
1152
+ "annotation": {
1153
+ "type": "union",
1154
+ "types": [
1155
+ {
1156
+ "type": "reference",
1157
+ "typeName": {
1158
+ "type": "identifier",
1159
+ "name": "MenuRawData"
1160
+ }
1161
+ },
1162
+ {
1163
+ "type": "reference",
1164
+ "typeName": {
1165
+ "type": "identifier",
1166
+ "name": "MenuItemRawData"
1167
+ }
1168
+ }
1169
+ ]
1170
+ },
1171
+ "computed": false
1172
+ },
1173
+ {
1174
+ "type": "propertySignature",
1175
+ "key": {
1176
+ "type": "identifier",
1177
+ "name": "__keys"
1178
+ },
1179
+ "annotation": {
1180
+ "type": "array",
1181
+ "elementType": {
1182
+ "type": "keyword",
1183
+ "value": "string"
1184
+ }
1185
+ },
1186
+ "optional": true,
1187
+ "computed": false,
1188
+ "description": "第一个节点额外返回 __keys,包含所有节点的 key"
1100
1189
  }
1101
1190
  ]
1102
1191
  }
@@ -1381,12 +1470,7 @@
1381
1470
  }
1382
1471
  ]
1383
1472
  },
1384
- "nav.query-search": {
1385
- "properties": [],
1386
- "events": [],
1387
- "methods": []
1388
- },
1389
- "nav.get-menu-config-tree": {
1473
+ "nav.get-menu-config-options": {
1390
1474
  "type": "provider",
1391
1475
  "params": [
1392
1476
  {
@@ -1419,7 +1503,7 @@
1419
1503
  "type": "reference",
1420
1504
  "typeName": {
1421
1505
  "type": "identifier",
1422
- "name": "TreeNode"
1506
+ "name": "MenuOption"
1423
1507
  }
1424
1508
  }
1425
1509
  }
@@ -1745,13 +1829,13 @@
1745
1829
  },
1746
1830
  {
1747
1831
  "type": "interface",
1748
- "name": "TreeNode",
1832
+ "name": "MenuOption",
1749
1833
  "body": [
1750
1834
  {
1751
1835
  "type": "propertySignature",
1752
1836
  "key": {
1753
1837
  "type": "identifier",
1754
- "name": "key"
1838
+ "name": "label"
1755
1839
  },
1756
1840
  "annotation": {
1757
1841
  "type": "keyword",
@@ -1763,107 +1847,46 @@
1763
1847
  "type": "propertySignature",
1764
1848
  "key": {
1765
1849
  "type": "identifier",
1766
- "name": "title"
1850
+ "name": "value"
1767
1851
  },
1768
1852
  "annotation": {
1769
1853
  "type": "keyword",
1770
1854
  "value": "string"
1771
1855
  },
1772
1856
  "computed": false
1773
- },
1774
- {
1775
- "type": "propertySignature",
1776
- "key": {
1777
- "type": "identifier",
1778
- "name": "icon"
1779
- },
1780
- "annotation": {
1781
- "type": "keyword",
1782
- "value": "unknown"
1783
- },
1784
- "optional": true,
1785
- "computed": false
1786
- },
1787
- {
1788
- "type": "propertySignature",
1789
- "key": {
1790
- "type": "identifier",
1791
- "name": "faded"
1792
- },
1793
- "annotation": {
1794
- "type": "keyword",
1795
- "value": "unknown"
1796
- },
1797
- "optional": true,
1798
- "computed": false
1799
- },
1800
- {
1801
- "type": "propertySignature",
1802
- "key": {
1803
- "type": "identifier",
1804
- "name": "children"
1805
- },
1806
- "annotation": {
1807
- "type": "array",
1808
- "elementType": {
1809
- "type": "reference",
1810
- "typeName": {
1811
- "type": "identifier",
1812
- "name": "TreeNode"
1813
- }
1814
- }
1815
- },
1816
- "optional": true,
1817
- "computed": false
1818
- },
1819
- {
1820
- "type": "propertySignature",
1821
- "key": {
1822
- "type": "identifier",
1823
- "name": "data"
1824
- },
1825
- "annotation": {
1826
- "type": "union",
1827
- "types": [
1828
- {
1829
- "type": "reference",
1830
- "typeName": {
1831
- "type": "identifier",
1832
- "name": "MenuRawData"
1833
- }
1834
- },
1835
- {
1836
- "type": "reference",
1837
- "typeName": {
1838
- "type": "identifier",
1839
- "name": "MenuItemRawData"
1840
- }
1841
- }
1842
- ]
1843
- },
1844
- "computed": false
1845
- },
1846
- {
1847
- "type": "propertySignature",
1848
- "key": {
1849
- "type": "identifier",
1850
- "name": "__keys"
1851
- },
1852
- "annotation": {
1853
- "type": "array",
1854
- "elementType": {
1855
- "type": "keyword",
1856
- "value": "string"
1857
- }
1858
- },
1859
- "optional": true,
1860
- "computed": false,
1861
- "description": "第一个节点额外返回 __keys,包含所有节点的 key"
1862
1857
  }
1863
1858
  ]
1864
1859
  }
1865
1860
  ]
1866
1861
  },
1862
+ "nav.query-search": {
1863
+ "properties": [],
1864
+ "events": [],
1865
+ "methods": []
1866
+ },
1867
+ "eo-launchpad-quick-access": {
1868
+ "properties": [
1869
+ {
1870
+ "name": "readonly",
1871
+ "annotation": {
1872
+ "type": "keyword",
1873
+ "value": "boolean"
1874
+ }
1875
+ },
1876
+ {
1877
+ "name": "target",
1878
+ "annotation": {
1879
+ "type": "reference",
1880
+ "typeName": {
1881
+ "type": "identifier",
1882
+ "name": "Target"
1883
+ }
1884
+ }
1885
+ }
1886
+ ],
1887
+ "events": [],
1888
+ "methods": []
1889
+ },
1867
1890
  "eo-directory-tree": {
1868
1891
  "properties": [
1869
1892
  {
@@ -2487,22 +2510,6 @@
2487
2510
  "value": "string"
2488
2511
  },
2489
2512
  "computed": false
2490
- },
2491
- {
2492
- "type": "propertySignature",
2493
- "key": {
2494
- "type": "identifier",
2495
- "name": "locales"
2496
- },
2497
- "annotation": {
2498
- "type": "reference",
2499
- "typeName": {
2500
- "type": "identifier",
2501
- "name": "AppLocales"
2502
- }
2503
- },
2504
- "optional": true,
2505
- "computed": false
2506
2513
  }
2507
2514
  ],
2508
2515
  "extends": [
@@ -2631,6 +2638,22 @@
2631
2638
  },
2632
2639
  "computed": false
2633
2640
  },
2641
+ {
2642
+ "type": "propertySignature",
2643
+ "key": {
2644
+ "type": "identifier",
2645
+ "name": "locales"
2646
+ },
2647
+ "annotation": {
2648
+ "type": "reference",
2649
+ "typeName": {
2650
+ "type": "identifier",
2651
+ "name": "AppLocales"
2652
+ }
2653
+ },
2654
+ "optional": true,
2655
+ "computed": false
2656
+ },
2634
2657
  {
2635
2658
  "type": "propertySignature",
2636
2659
  "key": {
@@ -2956,29 +2979,6 @@
2956
2979
  "events": [],
2957
2980
  "methods": []
2958
2981
  },
2959
- "eo-launchpad-quick-access": {
2960
- "properties": [
2961
- {
2962
- "name": "readonly",
2963
- "annotation": {
2964
- "type": "keyword",
2965
- "value": "boolean"
2966
- }
2967
- },
2968
- {
2969
- "name": "target",
2970
- "annotation": {
2971
- "type": "reference",
2972
- "typeName": {
2973
- "type": "identifier",
2974
- "name": "Target"
2975
- }
2976
- }
2977
- }
2978
- ],
2979
- "events": [],
2980
- "methods": []
2981
- },
2982
2982
  "eo-launchpad-button-v2": {
2983
2983
  "properties": [],
2984
2984
  "events": [],
@@ -0,0 +1,26 @@
1
+ export declare enum K {
2
+ ALL = "ALL",
3
+ QUICK_ACCESS = "QUICK_ACCESS",
4
+ PLATFORM_BASE = "PLATFORM_BASE",
5
+ SCENARIO_CENTER = "SCENARIO_CENTER",
6
+ SOLUTIONS = "SOLUTIONS",
7
+ OPEN_PLATFORM = "OPEN_PLATFORM",
8
+ SEARCH_PLACEHOLDER = "SEARCH_PLACEHOLDER",
9
+ RECENT_VISITS = "RECENT_VISITS",
10
+ FAVORITE = "FAVORITE",
11
+ UNFAVORITE = "UNFAVORITE",
12
+ FAVORITES_LIMIT_REACHED = "FAVORITES_LIMIT_REACHED",
13
+ FAVORITES_LIMIT_MESSAGE = "FAVORITES_LIMIT_MESSAGE"
14
+ }
15
+ export declare const NS = "bricks/nav/launchpad-button-v2";
16
+ export declare const locales: {
17
+ en: Locale;
18
+ zh: Locale;
19
+ };
20
+ export declare const t: any;
21
+ type Locale = {
22
+ [k in K]: string;
23
+ } & {
24
+ [k in K as `${k}_plural`]?: string;
25
+ };
26
+ export {};
@@ -1,7 +1,9 @@
1
- import type { MicroApp } from "@next-core/types";
1
+ import type { AppLocales, MicroApp } from "@next-core/types";
2
2
  import type { LegacyAntdIcon, MenuIcon } from "@next-shared/general/types";
3
3
  export interface MenuGroupData {
4
4
  name: string;
5
+ localeName?: string;
6
+ locales?: AppLocales;
5
7
  instanceId: string;
6
8
  items: MenuItemData[];
7
9
  }
@@ -11,28 +13,29 @@ export type SidebarMenuItemData = MenuItemDataNormal | MenuItemDataLink;
11
13
  export interface MicroAppWithInstanceId extends MicroApp {
12
14
  instanceId: string;
13
15
  }
14
- export interface MenuItemDataApp {
15
- type: "app";
16
+ export interface MenuItemDataBase {
17
+ type: string;
16
18
  name: string;
19
+ localeName?: string;
20
+ locales?: AppLocales;
17
21
  id: string;
22
+ }
23
+ export interface MenuItemDataApp extends MenuItemDataBase {
24
+ type: "app";
18
25
  instanceId: string;
19
26
  url: string;
20
27
  description?: string;
21
28
  menuIcon?: Exclude<MenuIcon, LegacyAntdIcon>;
22
29
  }
23
- export interface MenuItemDataCustom {
30
+ export interface MenuItemDataCustom extends MenuItemDataBase {
24
31
  type: "custom";
25
- name: string;
26
- id: string;
27
32
  instanceId: string;
28
33
  url: string;
29
34
  description?: string;
30
35
  menuIcon?: Exclude<MenuIcon, LegacyAntdIcon>;
31
36
  }
32
- export interface MenuItemDataDir {
37
+ export interface MenuItemDataDir extends MenuItemDataBase {
33
38
  type: "dir";
34
- name: string;
35
- id: string;
36
39
  items: MenuItemDataNormal[];
37
40
  }
38
41
  export interface MenuItemDataLink {
@@ -12,7 +12,6 @@ export type ConfigMenuItemNormal = ConfigMenuItemApp | ConfigMenuItemCustom;
12
12
  export interface ConfigMenuItemApp extends ConfigMenuItemBase {
13
13
  type: "app";
14
14
  url: string;
15
- locales?: AppLocales;
16
15
  }
17
16
  export interface ConfigMenuItemCustom extends ConfigMenuItemBase {
18
17
  type: "custom";
@@ -32,6 +31,7 @@ interface ConfigMenuItemBase extends ConfigMenuBase {
32
31
  interface ConfigMenuBase {
33
32
  id: string;
34
33
  name: string;
34
+ locales?: AppLocales;
35
35
  instanceId: string;
36
36
  /** 有可屏蔽的 */
37
37
  blockable?: boolean;
@@ -1,2 +1,2 @@
1
1
  import type { AppLocales } from "@next-core/types";
2
- export declare function getAppLocaleName(locales: AppLocales | undefined, name: string): string;
2
+ export declare function getLocaleName(locales?: AppLocales | undefined, name?: string): string | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@next-bricks/nav",
3
- "version": "1.22.9",
3
+ "version": "1.23.0",
4
4
  "homepage": "https://github.com/easyops-cn/next-advanced-bricks/tree/master/bricks/nav",
5
5
  "repository": {
6
6
  "type": "git",
@@ -43,5 +43,5 @@
43
43
  "@next-bricks/form": "*",
44
44
  "@next-bricks/icons": "*"
45
45
  },
46
- "gitHead": "7a72596d49dd941b023d6733e8587c9608b8f14b"
46
+ "gitHead": "7f651595b06b4901476f656db5227dfe2ec0aba2"
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(3081),s=n(9384),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}},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(79);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}},9393:(e,t,n)=>{n.d(t,{Bj:()=>s,Ds:()=>c,EM:()=>i,ui:()=>r});var a=n(1280),o=n(7732);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")}}]);
2
- //# sourceMappingURL=2133.a757ee32.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"chunks/2133.a757ee32.js","mappings":"ySAAO,MAAMA,EAAkB,GAClBC,EAAsB,G,gBCyGnCC,eAAeC,IACb,aACQC,EAAAA,EAAAA,GACJ,CAAEC,KAAM,EAAGC,SAAUN,GACrB,CACEO,kBAAmB,CAAEC,kBAAkB,GACvCC,sBAAsB,KAG1BC,IACJ,CCpCA,SAASC,EAAiBC,EAAuBC,GAC/C,OAAOD,EAAKE,GAAGC,cAAcC,SAASH,IACpCD,EAAKK,KAAKF,cAAcC,SAASH,IAChCD,EAAKM,aAAeN,EAAKM,YAAYH,cAAcC,SAASH,GAC3DD,EACA,IACN,CAEA,SAASO,EAAoBP,EAA0BC,GACrD,OAAOD,EAAKE,GAAGC,cAAcC,SAASH,IACpCD,EAAKK,KAAKF,cAAcC,SAASH,IAChCD,EAAKM,aAAeN,EAAKM,YAAYH,cAAcC,SAASH,GAC3DD,EACA,IACN,CChEA,MAAMQ,EAAa,2BACH,QADGC,EACjBC,EAAAA,KAAKC,iBAAS,IAAAF,OAAA,EAD8BA,EAE3CG,MACGC,EAAU,IAAIC,EAAAA,EAAYC,cAEhC,IAAIC,EAAqC,GACrCC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EAAAA,EAAAA,gBAC9B,0B","sources":["webpack:///./src/launchpad-button-v2/constants.ts","webpack:///./src/launchpad-button-v2/api.ts","webpack:///./src/launchpad-button-v2/search.ts","webpack:///./src/launchpad-button-v2/useLaunchpadInfo.ts","webpack:///./src/shared/DeferredService.ts","webpack:///./src/shared/getLocaleName.ts","webpack:///./src/launchpad-button-v2/wrapped-bricks.ts"],"sourcesContent":["export const FAVORITES_LIMIT = 10;\nexport const RECENT_VISITS_LIMIT = 10;\n","import type { Storyboard } from \"@next-core/types\";\nimport { LaunchpadApi_getLaunchpadInfo } from \"@next-api-sdk/micro-app-standalone-sdk\";\nimport {\n LaunchpadApi_createCollectionV2,\n LaunchpadApi_deleteCollectionV2,\n LaunchpadApi_listCollectionV2,\n} from \"@next-api-sdk/user-service-sdk\";\nimport { InstanceApi_postSearchV3 } from \"@next-api-sdk/cmdb-sdk\";\nimport { sortBy } from \"lodash\";\nimport { auth } from \"@next-core/easyops-runtime\";\nimport type {\n FavMenuItem,\n MenuGroupData,\n MenuItemData,\n MenuItemDataApp,\n MenuItemDataCustom,\n MenuItemDataDir,\n MenuItemDataNormal,\n MicroAppWithInstanceId,\n PlatformCategoryItem,\n} from \"./interfaces\";\nimport { FAVORITES_LIMIT } from \"./constants\";\nimport { getAppLocaleName } from \"../shared/getLocaleName\";\n\nexport async function fetchLaunchpadInfo() {\n const launchpadInfo = await LaunchpadApi_getLaunchpadInfo(\n {},\n {\n interceptorParams: { ignoreLoadingBar: true },\n noAbortOnRouteChange: true,\n }\n );\n\n const microAppsById = new Map<string, MicroAppWithInstanceId>();\n for (const storyboard of launchpadInfo.storyboards as Storyboard[]) {\n const app = storyboard.app as unknown as MicroAppWithInstanceId;\n app.localeName = getAppLocaleName(app.locales, app.name);\n if (!auth.isBlockedPath?.(app.homepage)) {\n microAppsById.set(app.id, app);\n }\n }\n\n const menuGroups: MenuGroupData[] = [];\n const customLinksById = new Map<string, MenuItemDataCustom>();\n\n for (const group of launchpadInfo.desktops as unknown as MenuGroupData[]) {\n const items: MenuItemData[] = [];\n for (const item of group.items) {\n switch (item.type) {\n case \"app\": {\n const app = microAppsById.get(item.id);\n if (app) {\n items.push({\n ...item,\n name: app.localeName,\n url: app.homepage,\n menuIcon: app.menuIcon,\n } as MenuItemDataApp);\n }\n break;\n }\n case \"custom\":\n if (!auth.isBlockedHref?.(item.url)) {\n items.push(item);\n customLinksById.set(item.id, item);\n }\n break;\n case \"dir\": {\n const subItems: MenuItemDataNormal[] = [];\n for (const subItem of item.items) {\n if (subItem.type === \"app\") {\n const app = microAppsById.get(subItem.id);\n if (app) {\n subItems.push({\n ...subItem,\n name: app.localeName,\n url: app.homepage,\n menuIcon: app.menuIcon,\n } as MenuItemDataApp);\n }\n } else if (\n subItem.type === \"custom\" &&\n !auth.isBlockedHref?.(subItem.url)\n ) {\n subItems.push(subItem as MenuItemDataCustom);\n customLinksById.set(subItem.id, subItem);\n }\n }\n if (subItems.length > 0) {\n items.push({\n ...item,\n items: subItems,\n } as MenuItemDataDir);\n }\n break;\n }\n }\n }\n if (items.length > 0) {\n menuGroups.push({ ...group, items });\n }\n }\n\n return { menuGroups, microAppsById, customLinksById };\n}\n\nasync function fetchRawFavorites() {\n return (\n await LaunchpadApi_listCollectionV2(\n { page: 1, pageSize: FAVORITES_LIMIT },\n {\n interceptorParams: { ignoreLoadingBar: true },\n noAbortOnRouteChange: true,\n }\n )\n ).list;\n}\n\nexport async function fetchFavorites() {\n const list = await fetchRawFavorites();\n const stored: FavMenuItem[] = [];\n // 不屏蔽收藏夹中的任何项,否则无法取消收藏\n for (const fav of list) {\n if (fav.type === \"microApp\") {\n const app = fav.relatedApp as Omit<MicroAppWithInstanceId, \"id\"> & {\n appId: string;\n };\n app.localeName = getAppLocaleName(app.locales, app.name);\n stored.push({\n favoriteId: fav.instanceId,\n type: \"app\",\n name: app.localeName,\n id: app.appId,\n url: app.homepage,\n instanceId: app.instanceId,\n menuIcon: app.menuIcon,\n } as FavMenuItem);\n } else if (fav.type === \"customItem\") {\n const customItem = fav.relatedCustomItem!;\n stored.push({\n favoriteId: fav.instanceId,\n type: \"custom\",\n name: customItem.name,\n id: customItem.id,\n url: customItem.url,\n menuIcon: customItem.menuIcon,\n } as FavMenuItem);\n } else if (fav.type === \"link\") {\n stored.push({\n favoriteId: fav.instanceId,\n type: \"link\",\n name: fav.name,\n // id: fav.id,\n url: fav.link,\n menuIcon: fav.icon,\n } as FavMenuItem);\n }\n }\n return stored;\n}\n\nexport async function favorite(\n item: MenuItemDataNormal\n): Promise<{ instanceId?: string }> {\n return LaunchpadApi_createCollectionV2(\n {\n type: item.type === \"app\" ? \"microApp\" : \"customItem\",\n relatedInstanceId: item.instanceId,\n },\n {\n interceptorParams: { ignoreLoadingBar: true },\n }\n );\n}\n\nexport async function undoFavorite(item: FavMenuItem) {\n if (item.favoriteId) {\n return LaunchpadApi_deleteCollectionV2(item.favoriteId);\n }\n\n return fetchRawFavorites().then((list) => {\n const foundId = list.find((fav) =>\n item.type === \"app\"\n ? fav.type === \"microApp\" && fav.relatedApp?.appId === item.id\n : item.type === \"custom\" && fav.relatedCustomItem?.id === item.id\n )?.instanceId;\n\n if (foundId) {\n return LaunchpadApi_deleteCollectionV2(foundId);\n }\n // eslint-disable-next-line no-console\n console.error(\"Menu item to unstar not found:\", item);\n });\n}\n\nexport async function fetchPlatformCategories(): Promise<\n PlatformCategoryItem[]\n> {\n const categories = (\n await InstanceApi_postSearchV3(\"MICRO_APP_CATEGORY@EASYOPS\", {\n fields: [\n \"id\",\n \"type\",\n \"name\",\n \"icon\",\n \"order\",\n \"platformApps.appId\",\n \"platformApps.name\",\n \"platformApps.homepage\",\n \"platformApps.description\",\n \"platformApps.menuIcon\",\n \"platformApps.locales\",\n \"platformApps._object_id\",\n \"platformApps.@.order\",\n \"platformItems.id\",\n \"platformItems.name\",\n \"platformItems.url\",\n \"platformItems.description\",\n \"platformItems.menuIcon\",\n \"platformItems._object_id\",\n \"platformItems.@.order\",\n ],\n page: 1,\n page_size: 300,\n query: {\n type: \"platform\",\n },\n })\n ).list;\n\n const _categories = categories?.map((category) => {\n const apps = category.platformApps\n .map((app: Record<string, any>) => {\n if (auth.isBlockedPath?.(app.homepage)) {\n return null;\n }\n return {\n type: \"app\",\n name: getAppLocaleName(app.locales, app.name),\n id: app.appId,\n url: app.homepage,\n menuIcon: app.menuIcon,\n description: app.description,\n instanceId: app.instanceId,\n order: app[\"@\"]?.order,\n };\n })\n .filter(Boolean) as MenuItemDataApp[];\n const customItems = category.platformItems\n .map((item: Record<string, any>) => {\n if (auth.isBlockedHref?.(item.url)) {\n return null;\n }\n return {\n type: \"custom\",\n name: item.name,\n id: item.id,\n url: item.url,\n menuIcon: item.menuIcon,\n description: item.description,\n instanceId: item.instanceId,\n order: item[\"@\"]?.order,\n };\n })\n .filter(Boolean) as MenuItemDataCustom[];\n\n const items = sortBy([...apps, ...customItems], \"order\");\n return {\n instanceId: category.instanceId,\n id: category.id,\n name: category.name,\n icon: category.icon,\n order: category.order,\n items,\n } as PlatformCategoryItem;\n });\n\n return [\n {\n id: \"#all\",\n name: \"全部\",\n icon: {\n lib: \"easyops\",\n category: \"second-menu\",\n icon: \"sprint-planning-second-menu\",\n },\n items: [],\n },\n ...sortBy(_categories, \"order\"),\n ];\n}\n","import type {\n MenuGroupData,\n MenuItemData,\n MenuItemDataApp,\n MenuItemDataCustom,\n MenuItemDataNormal,\n PlatformCategoryItem,\n} from \"./interfaces\";\n\nexport function search(\n allMenuGroups: MenuGroupData[],\n q: string\n): MenuGroupData[] {\n if (!q) {\n return allMenuGroups;\n }\n const lowerQ = q.toLowerCase();\n const groups: MenuGroupData[] = allMenuGroups\n .map((group) => ({\n ...group,\n items: group.items\n .map((item) => {\n switch (item.type) {\n case \"app\":\n return matchMenuItemApp(item, lowerQ);\n case \"custom\":\n return matchMenuItemCustom(item, lowerQ);\n case \"dir\": {\n const filteredSubItems = item.items\n .map((sub) =>\n sub.type === \"app\"\n ? matchMenuItemApp(sub, lowerQ)\n : sub.type === \"custom\"\n ? matchMenuItemCustom(sub, lowerQ)\n : null\n )\n .filter(Boolean) as MenuItemData[];\n return filteredSubItems.length > 0\n ? {\n ...item,\n items: filteredSubItems,\n }\n : null;\n }\n }\n })\n // Ignore not matched items\n .filter(Boolean) as MenuItemData[],\n }))\n // ignore empty desktops\n .filter((group) => group.items.length > 0);\n return groups;\n}\n\nexport function searchCategories(\n categories: PlatformCategoryItem[],\n q: string\n): PlatformCategoryItem[] {\n if (!q) {\n return categories;\n }\n\n const lowerQ = q.toLowerCase();\n const _categories = categories.map((category) => ({\n ...category,\n items: category.items\n .map((item) => {\n switch (item.type) {\n case \"app\":\n return matchMenuItemApp(item, lowerQ);\n case \"custom\":\n return matchMenuItemCustom(item, lowerQ);\n }\n })\n // Ignore not matched items\n .filter(Boolean) as MenuItemDataNormal[],\n }));\n return _categories;\n}\n\nfunction matchMenuItemApp(item: MenuItemDataApp, lowerQ: string) {\n return item.id.toLowerCase().includes(lowerQ) ||\n item.name.toLowerCase().includes(lowerQ) ||\n (item.description && item.description.toLowerCase().includes(lowerQ))\n ? item\n : null;\n}\n\nfunction matchMenuItemCustom(item: MenuItemDataCustom, lowerQ: string) {\n return item.id.toLowerCase().includes(lowerQ) ||\n item.name.toLowerCase().includes(lowerQ) ||\n (item.description && item.description.toLowerCase().includes(lowerQ))\n ? item\n : null;\n}\n","import { useCallback, useEffect, useMemo, useState } from \"react\";\nimport {\n getRuntime,\n handleHttpError,\n httpErrorToString,\n} from \"@next-core/runtime\";\nimport { auth } from \"@next-core/easyops-runtime\";\nimport { JsonStorage } from \"@next-shared/general/JsonStorage\";\nimport { DeferredService } from \"../shared/DeferredService\";\nimport { showDialog, showNotification } from \"./wrapped-bricks\";\nimport type {\n FavMenuItem,\n MenuGroupData,\n MenuItemDataCustom,\n MenuItemDataLink,\n MenuItemDataNormal,\n MicroAppWithInstanceId,\n PlatformCategoryItem,\n StoredMenuItem,\n} from \"./interfaces\";\nimport {\n favorite,\n fetchFavorites,\n fetchLaunchpadInfo,\n fetchPlatformCategories,\n undoFavorite,\n} from \"./api\";\nimport { search, searchCategories } from \"./search\";\nimport { FAVORITES_LIMIT, RECENT_VISITS_LIMIT } from \"./constants\";\n\nconst storageKey = `launchpad-recent-visits:${(\n auth.getAuth() as Record<string, string>\n)?.org}`;\nconst storage = new JsonStorage(localStorage);\n\nlet candidateDesktops: MenuGroupData[] = [];\nlet candidateMicroAppsById = new Map<string, MicroAppWithInstanceId>();\nlet candidateCustomLinksById = new Map<string, MenuItemDataCustom>();\nlet preLoaded = false;\n\nlet candidateFavorites: FavMenuItem[] = [];\nlet preLoadedFavorites = false;\n\nlet candidatePlatformCategories: PlatformCategoryItem[] = [];\nlet preLoadedPlatformCategories = false;\n\nexport const deferredLaunchpadInfo = new DeferredService(async () => {\n ({\n menuGroups: candidateDesktops,\n microAppsById: candidateMicroAppsById,\n customLinksById: candidateCustomLinksById,\n } = await fetchLaunchpadInfo());\n preLoaded = true;\n});\n\nexport const deferredFavorites = new DeferredService(async () => {\n candidateFavorites = await fetchFavorites();\n preLoadedFavorites = true;\n});\n\nexport const deferredPlatformCategories = new DeferredService(async () => {\n candidatePlatformCategories = await fetchPlatformCategories();\n preLoadedPlatformCategories = true;\n});\n\nconst showErrorAsNotification = (error: unknown) =>\n showNotification({\n type: \"error\",\n message: httpErrorToString(error),\n });\n\n/**\n * - 页面初始化时预加载 launchpad 信息。\n * - 每次打开 launchpad 都发起请求,但该请求的数据只在下次打开 launchpad 时使用。\n * 即每次打开 launchpad 使用的都是上一次获取的数据,以便达到两个效果:\n * - 每次打开 launchpad 都能立即显示菜单列表;\n * - 同时当用户在 launchpad 上操作时,不会出现数据突然更新(新数据请求完成)。\n */\nexport function useLaunchpadInfo(active?: boolean) {\n const [desktops, setDesktops] = useState(candidateDesktops);\n const [microAppsById, setMicroAppsById] = useState(candidateMicroAppsById);\n const [customLinksById, setCustomLinksById] = useState(\n candidateCustomLinksById\n );\n\n const [q, setQ] = useState(\"\");\n\n const [loading, setLoading] = useState(!preLoaded);\n const [loadingFavorites, setLoadingFavorites] = useState(!preLoadedFavorites);\n const [loadingPlatformCategories, setLoadingPlatformCategories] = useState(\n !preLoadedPlatformCategories\n );\n\n const [storedRecentVisits, setStoredRecentVisits] = useState<\n StoredMenuItem[]\n >([]);\n\n const [recentVisits, setRecentVisits] = useState<MenuItemDataNormal[]>([]);\n\n const [favorites, setFavorites] = useState<FavMenuItem[]>(candidateFavorites);\n const [platformCategories, setPlatformCategories] = useState<\n PlatformCategoryItem[]\n >(candidatePlatformCategories);\n\n useEffect(() => {\n // 仅当首次加载完成或重新打开 launchpad 时更新一次数据。\n if (active && !loading) {\n setDesktops(candidateDesktops);\n setMicroAppsById(candidateMicroAppsById);\n setCustomLinksById(candidateCustomLinksById);\n }\n }, [active, loading]);\n\n useEffect(() => {\n if (active && !loadingFavorites) {\n setFavorites(candidateFavorites);\n }\n }, [active, loadingFavorites]);\n\n useEffect(() => {\n if (active && !loadingPlatformCategories) {\n setPlatformCategories(candidatePlatformCategories);\n }\n }, [active, loadingPlatformCategories]);\n\n useEffect(() => {\n if (active) {\n setStoredRecentVisits(storage.getItem(storageKey) ?? []);\n }\n }, [active]);\n\n useEffect(() => {\n if (active) {\n const startFetchLaunchpadInfo = async (): Promise<void> => {\n try {\n await deferredLaunchpadInfo.fetch();\n setLoading(false);\n } catch (error) {\n handleHttpError(error);\n }\n };\n startFetchLaunchpadInfo();\n }\n }, [active]);\n\n useEffect(() => {\n if (active) {\n const startFetchFavorites = async (): Promise<void> => {\n try {\n await deferredFavorites.fetch();\n setLoadingFavorites(false);\n } catch (error) {\n setLoadingFavorites(false);\n showErrorAsNotification(error);\n }\n };\n startFetchFavorites();\n }\n }, [active]);\n\n useEffect(() => {\n if (\n active &&\n getRuntime()?.getFeatureFlags()[\"launchpad-show-platform-category\"]\n ) {\n const startFetchPlatformCategories = async (): Promise<void> => {\n try {\n await deferredPlatformCategories.fetch();\n setLoadingPlatformCategories(false);\n } catch (error) {\n setLoadingPlatformCategories(false);\n showErrorAsNotification(error);\n }\n };\n startFetchPlatformCategories();\n }\n }, [active]);\n\n useEffect(() => {\n if (loading) {\n return;\n }\n const visits = storedRecentVisits\n .map((item) => {\n // Remembered recent visits maybe no longer existed in launchpad\n if (item.type === \"app\") {\n const app = microAppsById.get(item.id);\n return app\n ? {\n type: \"app\",\n name: app.localeName,\n id: app.id,\n url: app.homepage,\n instanceId: app.instanceId,\n menuIcon: app.menuIcon,\n }\n : null;\n }\n return customLinksById.get(item.id);\n })\n .filter(Boolean) as MenuItemDataNormal[];\n setRecentVisits(visits);\n }, [customLinksById, loading, microAppsById, storedRecentVisits]);\n\n const pushRecentVisit = useCallback(({ type, id }: StoredMenuItem) => {\n const visits: StoredMenuItem[] = storage.getItem(storageKey) ?? [];\n const index = visits.findIndex(\n (visit) => visit.type === type && visit.id === id\n );\n if (index > -1) {\n visits.splice(index, 1);\n }\n visits.unshift({ type, id });\n if (visits.length > RECENT_VISITS_LIMIT) {\n visits.pop();\n }\n // setStoredRecentVisits(visits);\n storage.setItem(storageKey, visits);\n }, []);\n\n const isStarred = useCallback(\n (item: MenuItemDataNormal) =>\n favorites.some((fav) => matchFavorite(item, fav)),\n [favorites]\n );\n\n const toggleStar = useCallback(\n (item: MenuItemDataNormal | MenuItemDataLink) => {\n const index = favorites.findIndex((fav) =>\n item.type === \"link\"\n ? fav.favoriteId === item.favoriteId\n : matchFavorite(item, fav)\n );\n let newFavorites: FavMenuItem[];\n if (index > -1) {\n const removed = favorites[index];\n newFavorites = favorites\n .slice(0, index)\n .concat(favorites.slice(index + 1));\n undoFavorite(removed).catch(showErrorAsNotification);\n } else {\n if (favorites.length >= FAVORITES_LIMIT) {\n showDialog({\n type: \"warn\",\n title: \"收藏数量已达上限\",\n content: `当前收藏链接数量已达上限(${FAVORITES_LIMIT}个),请删除部分收藏后再添加。`,\n });\n return;\n }\n // Assert: no link item\n const fav: FavMenuItem = { ...(item as MenuItemDataNormal) };\n newFavorites = favorites.concat(fav);\n favorite(item as MenuItemDataNormal).then((result) => {\n if (result) {\n fav.favoriteId = result.instanceId;\n }\n }, showErrorAsNotification);\n }\n setFavorites(newFavorites);\n candidateFavorites = newFavorites;\n },\n [favorites]\n );\n\n const menuGroups: MenuGroupData[] = useMemo(\n () => search(desktops, q),\n [desktops, q]\n );\n\n const filteredPlatformCategories: PlatformCategoryItem[] = useMemo(\n () => searchCategories(platformCategories, q),\n [platformCategories, q]\n );\n\n return {\n loading,\n q,\n setQ,\n menuGroups,\n loadingFavorites,\n loadingPlatformCategories,\n favorites,\n recentVisits,\n pushRecentVisit,\n isStarred,\n toggleStar,\n platformCategories: filteredPlatformCategories,\n };\n}\n\nexport function matchFavorite(item: MenuItemDataNormal, fav: FavMenuItem) {\n return item.instanceId && fav.instanceId\n ? fav.instanceId === item.instanceId\n : fav.type === item.type && fav.id === item.id;\n}\n","export class DeferredService {\n private preFetchId: number | null = null;\n private preFetchScheduled = false;\n private firstFetchPromise: Promise<unknown> | null = null;\n private isFetching = false;\n private readonly task: () => Promise<unknown>;\n\n constructor(task: () => Promise<unknown>) {\n this.task = task;\n }\n\n schedulePrefetch(): void {\n if (!this.preFetchScheduled) {\n this.preFetchScheduled = true;\n const preFetchLaunchpadInfo = async (): Promise<void> => {\n this.preFetchId = null;\n this.fetch();\n };\n // istanbul ignore if\n if (typeof window.requestIdleCallback === \"function\") {\n this.preFetchId = window.requestIdleCallback(preFetchLaunchpadInfo);\n } else {\n this.preFetchId = setTimeout(\n preFetchLaunchpadInfo\n ) as unknown as number;\n }\n }\n }\n\n fetch(eager?: boolean): Promise<unknown> {\n if (this.preFetchId) {\n // istanbul ignore if\n if (typeof window.cancelIdleCallback === \"function\") {\n cancelIdleCallback(this.preFetchId);\n } else {\n clearTimeout(this.preFetchId);\n }\n this.preFetchId = null;\n }\n\n let promise: Promise<unknown>;\n if (!this.isFetching || eager) {\n this.isFetching = true;\n promise = this.task();\n promise\n .catch((error) => {\n // eslint-disable-next-line no-console\n console.error(error);\n this.firstFetchPromise = null;\n })\n .finally(() => {\n this.isFetching = false;\n });\n if (!this.firstFetchPromise) {\n this.firstFetchPromise = promise;\n }\n if (eager) {\n return promise;\n }\n }\n return this.firstFetchPromise!;\n }\n}\n","import { i18nText } from \"@next-core/i18n\";\nimport type { AppLocales, I18nData } from \"@next-core/types\";\n\nexport function getAppLocaleName(\n locales: AppLocales | undefined,\n name: string\n) {\n if (!locales) {\n return name;\n }\n const i18nData = Object.fromEntries(\n Object.entries(locales)\n .filter(([_lang, resources]) => resources.name)\n .map(([lang, resources]) => [lang, resources.name])\n ) as I18nData;\n return i18nText(i18nData) ?? name;\n}\n","import { wrapBrick } from \"@next-core/react-element\";\nimport { unwrapProvider } from \"@next-core/utils/general\";\nimport type {\n GeneralIcon,\n GeneralIconProps,\n} from \"@next-bricks/icons/general-icon\";\nimport type { Link, LinkProps } from \"@next-bricks/basic/link\";\nimport type { showDialog as _showDialog } from \"@next-bricks/basic/data-providers/show-dialog/show-dialog\";\nimport type { showNotification as _showNotification } from \"@next-bricks/basic/data-providers/show-notification/show-notification\";\n\nexport const WrappedIcon = wrapBrick<GeneralIcon, GeneralIconProps>(\"eo-icon\");\nexport const WrappedLink = wrapBrick<Link, LinkProps>(\"eo-link\");\n\n// Use `unwrapProvider` to get the original function of a provider\nexport const showDialog =\n unwrapProvider<typeof _showDialog>(\"basic.show-dialog\");\n\nexport const showNotification = unwrapProvider<typeof _showNotification>(\n \"basic.show-notification\"\n);\n"],"names":["FAVORITES_LIMIT","RECENT_VISITS_LIMIT","async","fetchRawFavorites","LaunchpadApi_listCollectionV2","page","pageSize","interceptorParams","ignoreLoadingBar","noAbortOnRouteChange","list","matchMenuItemApp","item","lowerQ","id","toLowerCase","includes","name","description","matchMenuItemCustom","storageKey","_auth$getAuth","auth","getAuth","org","storage","JsonStorage","localStorage","candidateDesktops","candidateMicroAppsById","Map","candidateCustomLinksById","preLoaded","candidateFavorites","preLoadedFavorites","candidatePlatformCategories","preLoadedPlatformCategories","deferredLaunchpadInfo","DeferredService","menuGroups","microAppsById","customLinksById","_auth$isBlockedHref","launchpadInfo","LaunchpadApi_getLaunchpadInfo","storyboard","storyboards","_auth$isBlockedPath","app","localeName","getAppLocaleName","locales","isBlockedPath","call","homepage","set","group","desktops","items","type","get","push","url","menuIcon","isBlockedHref","subItems","subItem","_auth$isBlockedHref2","length","fetchLaunchpadInfo","deferredFavorites","stored","fav","relatedApp","favoriteId","instanceId","appId","customItem","relatedCustomItem","link","icon","fetchFavorites","deferredPlatformCategories","categories","InstanceApi_postSearchV3","fields","page_size","query","_categories","map","category","apps","platformApps","_auth$isBlockedPath2","_app$","order","filter","Boolean","customItems","platformItems","_auth$isBlockedHref3","_item$","sortBy","lib","fetchPlatformCategories","showErrorAsNotification","error","showNotification","message","httpErrorToString","useLaunchpadInfo","active","setDesktops","useState","setMicroAppsById","setCustomLinksById","q","setQ","loading","setLoading","loadingFavorites","setLoadingFavorites","loadingPlatformCategories","setLoadingPlatformCategories","storedRecentVisits","setStoredRecentVisits","recentVisits","setRecentVisits","favorites","setFavorites","platformCategories","setPlatformCategories","useEffect","_storage$getItem","getItem","fetch","handleHttpError","startFetchLaunchpadInfo","startFetchFavorites","_getRuntime","getRuntime","getFeatureFlags","startFetchPlatformCategories","visits","pushRecentVisit","useCallback","_ref","_storage$getItem2","index","findIndex","visit","splice","unshift","pop","setItem","isStarred","some","matchFavorite","toggleStar","newFavorites","removed","slice","concat","LaunchpadApi_deleteCollectionV2","then","_list$find","foundId","find","_fav$relatedApp","_fav$relatedCustomIte","console","undoFavorite","catch","showDialog","title","content","LaunchpadApi_createCollectionV2","relatedInstanceId","favorite","result","useMemo","allMenuGroups","filteredSubItems","sub","search","filteredPlatformCategories","searchCategories","constructor","task","_defineProperty","this","schedulePrefetch","preFetchScheduled","preFetchLaunchpadInfo","preFetchId","window","requestIdleCallback","setTimeout","eager","promise","cancelIdleCallback","clearTimeout","isFetching","firstFetchPromise","finally","_i18nText","i18nData","Object","fromEntries","entries","_lang","resources","_ref2","lang","i18nText","WrappedIcon","wrapBrick","WrappedLink","unwrapProvider"],"sourceRoot":""}