@next-bricks/nav 1.24.7 → 1.24.8

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.
@@ -41,14 +41,87 @@
41
41
  "insider": true
42
42
  },
43
43
  {
44
- "name": "eo-launchpad-quick-access",
44
+ "name": "nav.launchpad-config",
45
45
  "properties": [
46
46
  {
47
- "name": "readonly",
48
- "type": "boolean"
47
+ "name": "menuGroups",
48
+ "attribute": false,
49
+ "type": "ConfigMenuGroup[]"
50
+ },
51
+ {
52
+ "name": "actions",
53
+ "attribute": false,
54
+ "type": "MenuAction[]"
55
+ },
56
+ {
57
+ "name": "variant",
58
+ "description": "",
59
+ "default": "\"launchpad-config\"",
60
+ "type": "ConfigVariant"
61
+ },
62
+ {
63
+ "name": "urlTemplate",
64
+ "description": "菜单项 APP 类型的链接模板,例如可配置为 `/app/{{ id }}`。\n\n注:仅用于 variant: \"menu-config\"。",
65
+ "type": "string"
66
+ },
67
+ {
68
+ "name": "customUrlTemplate",
69
+ "description": "菜单项自定义类型的链接模板,例如可配置为 `/custom?url={{ __pathname }}`。\n\n注:仅用于 variant: \"menu-config\"。\n 外链菜单链接会设置为禁用。\n `__pathname` 是运行时变量,表示 url 解析后的 pathname。",
70
+ "type": "string"
49
71
  },
72
+ {
73
+ "name": "blacklist",
74
+ "description": "屏蔽的 URL 列表,例如可配置为 `[\"/app/1\", \"/app/2\"]`。\n\n注:仅用于 variant: \"blacklist-config\"。",
75
+ "attribute": false,
76
+ "type": "string[]"
77
+ }
78
+ ],
79
+ "events": [
80
+ {
81
+ "name": "menu-item.click",
82
+ "detail": {
83
+ "type": "ConfigMenuItemNormal"
84
+ }
85
+ },
86
+ {
87
+ "name": "action.click",
88
+ "detail": {
89
+ "type": "MenuActionEventDetail"
90
+ }
91
+ }
92
+ ],
93
+ "slots": [],
94
+ "methods": [],
95
+ "parts": [],
96
+ "description": "进行 Launchpad 配置。\n\n也可用于菜单自定义显示产品功能清单。",
97
+ "insider": true
98
+ },
99
+ {
100
+ "name": "eo-launchpad-button",
101
+ "properties": [],
102
+ "events": [],
103
+ "slots": [],
104
+ "methods": [],
105
+ "parts": [],
106
+ "description": "Launchpad 按钮构件",
107
+ "insider": true
108
+ },
109
+ {
110
+ "name": "nav.easyops-navbar-alerts",
111
+ "properties": [],
112
+ "events": [],
113
+ "slots": [],
114
+ "methods": [],
115
+ "parts": [],
116
+ "description": "构件 `nav.easyops-navbar-alerts`",
117
+ "insider": true
118
+ },
119
+ {
120
+ "name": "eo-launchpad-recent-visits",
121
+ "properties": [
50
122
  {
51
123
  "name": "target",
124
+ "attribute": false,
52
125
  "type": "Target"
53
126
  }
54
127
  ],
@@ -56,7 +129,7 @@
56
129
  "slots": [],
57
130
  "methods": [],
58
131
  "parts": [],
59
- "description": "快捷访问",
132
+ "description": "launchpad 最近访问",
60
133
  "insider": true
61
134
  },
62
135
  {
@@ -76,11 +149,14 @@
76
149
  "insider": true
77
150
  },
78
151
  {
79
- "name": "eo-launchpad-recent-visits",
152
+ "name": "eo-launchpad-quick-access",
80
153
  "properties": [
154
+ {
155
+ "name": "readonly",
156
+ "type": "boolean"
157
+ },
81
158
  {
82
159
  "name": "target",
83
- "attribute": false,
84
160
  "type": "Target"
85
161
  }
86
162
  ],
@@ -88,7 +164,7 @@
88
164
  "slots": [],
89
165
  "methods": [],
90
166
  "parts": [],
91
- "description": "launchpad 最近访问",
167
+ "description": "快捷访问",
92
168
  "insider": true
93
169
  },
94
170
  {
@@ -214,21 +290,22 @@
214
290
  "category": "navigation"
215
291
  },
216
292
  {
217
- "name": "eo-sidebar-menu-group",
293
+ "name": "eo-sidebar-menu-submenu",
218
294
  "properties": [
219
295
  {
220
- "name": "collapsable",
221
- "description": "是否允许折叠",
222
- "type": "boolean"
296
+ "name": "icon",
297
+ "description": "菜单的图标",
298
+ "attribute": false,
299
+ "type": "GeneralIconProps"
223
300
  },
224
301
  {
225
- "name": "collapsed",
226
- "description": "是否折叠",
302
+ "name": "selected",
303
+ "description": "是否选中",
227
304
  "type": "boolean"
228
305
  },
229
306
  {
230
- "name": "selected",
231
- "description": "是否选中",
307
+ "name": "collapsed",
308
+ "description": "是否折叠",
232
309
  "type": "boolean"
233
310
  },
234
311
  {
@@ -241,82 +318,36 @@
241
318
  "slots": [
242
319
  {
243
320
  "name": "title",
244
- "description": "分组标题"
321
+ "description": "子菜单标题"
245
322
  }
246
323
  ],
247
324
  "methods": [],
248
325
  "parts": [],
249
- "description": "侧栏菜单分组",
326
+ "description": "侧栏菜单子菜单",
250
327
  "category": "navigation"
251
328
  },
252
329
  {
253
- "name": "nav.launchpad-config",
330
+ "name": "eo-sidebar-menu",
254
331
  "properties": [
255
332
  {
256
- "name": "menuGroups",
257
- "attribute": false,
258
- "type": "ConfigMenuGroup[]"
259
- },
260
- {
261
- "name": "actions",
262
- "attribute": false,
263
- "type": "MenuAction[]"
264
- },
265
- {
266
- "name": "variant",
267
- "description": "",
268
- "default": "\"launchpad-config\"",
269
- "type": "ConfigVariant"
270
- },
271
- {
272
- "name": "urlTemplate",
273
- "description": "菜单项 APP 类型的链接模板,例如可配置为 `/app/{{ id }}`。\n\n注:仅用于 variant: \"menu-config\"。",
274
- "type": "string"
275
- },
276
- {
277
- "name": "customUrlTemplate",
278
- "description": "菜单项自定义类型的链接模板,例如可配置为 `/custom?url={{ __pathname }}`。\n\n注:仅用于 variant: \"menu-config\"。\n 外链菜单链接会设置为禁用。\n `__pathname` 是运行时变量,表示 url 解析后的 pathname。",
279
- "type": "string"
280
- },
281
- {
282
- "name": "blacklist",
283
- "description": "屏蔽的 URL 列表,例如可配置为 `[\"/app/1\", \"/app/2\"]`。\n\n注:仅用于 variant: \"blacklist-config\"。",
284
- "attribute": false,
285
- "type": "string[]"
286
- }
287
- ],
288
- "events": [
289
- {
290
- "name": "menu-item.click",
291
- "detail": {
292
- "type": "ConfigMenuItemNormal"
293
- }
294
- },
295
- {
296
- "name": "action.click",
297
- "detail": {
298
- "type": "MenuActionEventDetail"
299
- }
333
+ "name": "menuCollapsed",
334
+ "description": "菜单整体是否收起状态",
335
+ "type": "boolean"
300
336
  }
301
337
  ],
338
+ "events": [],
302
339
  "slots": [],
303
340
  "methods": [],
304
341
  "parts": [],
305
- "description": "进行 Launchpad 配置。\n\n也可用于菜单自定义显示产品功能清单。",
306
- "insider": true
342
+ "description": "侧栏菜单",
343
+ "category": "navigation"
307
344
  },
308
345
  {
309
- "name": "eo-sidebar-menu-submenu",
346
+ "name": "eo-sidebar-menu-group",
310
347
  "properties": [
311
348
  {
312
- "name": "icon",
313
- "description": "菜单的图标",
314
- "attribute": false,
315
- "type": "GeneralIconProps"
316
- },
317
- {
318
- "name": "selected",
319
- "description": "是否选中",
349
+ "name": "collapsable",
350
+ "description": "是否允许折叠",
320
351
  "type": "boolean"
321
352
  },
322
353
  {
@@ -324,6 +355,11 @@
324
355
  "description": "是否折叠",
325
356
  "type": "boolean"
326
357
  },
358
+ {
359
+ "name": "selected",
360
+ "description": "是否选中",
361
+ "type": "boolean"
362
+ },
327
363
  {
328
364
  "name": "menuCollapsed",
329
365
  "description": "菜单整体是否收起状态",
@@ -334,38 +370,12 @@
334
370
  "slots": [
335
371
  {
336
372
  "name": "title",
337
- "description": "子菜单标题"
338
- }
339
- ],
340
- "methods": [],
341
- "parts": [],
342
- "description": "侧栏菜单子菜单",
343
- "category": "navigation"
344
- },
345
- {
346
- "name": "nav.easyops-navbar-alerts",
347
- "properties": [],
348
- "events": [],
349
- "slots": [],
350
- "methods": [],
351
- "parts": [],
352
- "description": "构件 `nav.easyops-navbar-alerts`",
353
- "insider": true
354
- },
355
- {
356
- "name": "eo-sidebar-menu",
357
- "properties": [
358
- {
359
- "name": "menuCollapsed",
360
- "description": "菜单整体是否收起状态",
361
- "type": "boolean"
373
+ "description": "分组标题"
362
374
  }
363
375
  ],
364
- "events": [],
365
- "slots": [],
366
376
  "methods": [],
367
377
  "parts": [],
368
- "description": "侧栏菜单",
378
+ "description": "侧栏菜单分组",
369
379
  "category": "navigation"
370
380
  },
371
381
  {
@@ -418,16 +428,6 @@
418
428
  "description": "侧边栏",
419
429
  "category": "navigation"
420
430
  },
421
- {
422
- "name": "eo-launchpad-button",
423
- "properties": [],
424
- "events": [],
425
- "slots": [],
426
- "methods": [],
427
- "parts": [],
428
- "description": "Launchpad 按钮构件",
429
- "insider": true
430
- },
431
431
  {
432
432
  "name": "eo-sidebar-sub-menu",
433
433
  "properties": [
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,11 +233,6 @@
228
233
  "events": [],
229
234
  "methods": []
230
235
  },
231
- "nav.easyops-navbar-alerts": {
232
- "properties": [],
233
- "events": [],
234
- "methods": []
235
- },
236
236
  "eo-sidebar-sub-menu": {
237
237
  "properties": [
238
238
  {
@@ -564,19 +564,6 @@
564
564
  "events": [],
565
565
  "methods": []
566
566
  },
567
- "eo-search-launchpad": {
568
- "properties": [
569
- {
570
- "name": "readonly",
571
- "annotation": {
572
- "type": "keyword",
573
- "value": "boolean"
574
- }
575
- }
576
- ],
577
- "events": [],
578
- "methods": []
579
- },
580
567
  "eo-launchpad-recent-visits": {
581
568
  "properties": [
582
569
  {
@@ -593,20 +580,23 @@
593
580
  "events": [],
594
581
  "methods": []
595
582
  },
596
- "eo-sidebar-menu-submenu": {
583
+ "eo-sidebar-menu": {
597
584
  "properties": [
598
585
  {
599
- "name": "icon",
586
+ "name": "menuCollapsed",
600
587
  "annotation": {
601
- "type": "reference",
602
- "typeName": {
603
- "type": "identifier",
604
- "name": "GeneralIconProps"
605
- }
588
+ "type": "keyword",
589
+ "value": "boolean"
606
590
  }
607
- },
591
+ }
592
+ ],
593
+ "events": [],
594
+ "methods": []
595
+ },
596
+ "eo-sidebar-menu-group": {
597
+ "properties": [
608
598
  {
609
- "name": "selected",
599
+ "name": "collapsable",
610
600
  "annotation": {
611
601
  "type": "keyword",
612
602
  "value": "boolean"
@@ -620,18 +610,12 @@
620
610
  }
621
611
  },
622
612
  {
623
- "name": "menuCollapsed",
613
+ "name": "selected",
624
614
  "annotation": {
625
615
  "type": "keyword",
626
616
  "value": "boolean"
627
617
  }
628
- }
629
- ],
630
- "events": [],
631
- "methods": []
632
- },
633
- "eo-sidebar-menu": {
634
- "properties": [
618
+ },
635
619
  {
636
620
  "name": "menuCollapsed",
637
621
  "annotation": {
@@ -1191,24 +1175,50 @@
1191
1175
  }
1192
1176
  ]
1193
1177
  },
1194
- "eo-sidebar-menu-group": {
1178
+ "eo-launchpad-quick-access": {
1195
1179
  "properties": [
1196
1180
  {
1197
- "name": "collapsable",
1181
+ "name": "readonly",
1198
1182
  "annotation": {
1199
1183
  "type": "keyword",
1200
1184
  "value": "boolean"
1201
1185
  }
1202
1186
  },
1203
1187
  {
1204
- "name": "collapsed",
1188
+ "name": "target",
1189
+ "annotation": {
1190
+ "type": "reference",
1191
+ "typeName": {
1192
+ "type": "identifier",
1193
+ "name": "Target"
1194
+ }
1195
+ }
1196
+ }
1197
+ ],
1198
+ "events": [],
1199
+ "methods": []
1200
+ },
1201
+ "eo-sidebar-menu-submenu": {
1202
+ "properties": [
1203
+ {
1204
+ "name": "icon",
1205
+ "annotation": {
1206
+ "type": "reference",
1207
+ "typeName": {
1208
+ "type": "identifier",
1209
+ "name": "GeneralIconProps"
1210
+ }
1211
+ }
1212
+ },
1213
+ {
1214
+ "name": "selected",
1205
1215
  "annotation": {
1206
1216
  "type": "keyword",
1207
1217
  "value": "boolean"
1208
1218
  }
1209
1219
  },
1210
1220
  {
1211
- "name": "selected",
1221
+ "name": "collapsed",
1212
1222
  "annotation": {
1213
1223
  "type": "keyword",
1214
1224
  "value": "boolean"
@@ -1859,7 +1869,12 @@
1859
1869
  }
1860
1870
  ]
1861
1871
  },
1862
- "eo-launchpad-quick-access": {
1872
+ "nav.query-search": {
1873
+ "properties": [],
1874
+ "events": [],
1875
+ "methods": []
1876
+ },
1877
+ "eo-search-launchpad": {
1863
1878
  "properties": [
1864
1879
  {
1865
1880
  "name": "readonly",
@@ -1867,26 +1882,11 @@
1867
1882
  "type": "keyword",
1868
1883
  "value": "boolean"
1869
1884
  }
1870
- },
1871
- {
1872
- "name": "target",
1873
- "annotation": {
1874
- "type": "reference",
1875
- "typeName": {
1876
- "type": "identifier",
1877
- "name": "Target"
1878
- }
1879
- }
1880
1885
  }
1881
1886
  ],
1882
1887
  "events": [],
1883
1888
  "methods": []
1884
1889
  },
1885
- "nav.query-search": {
1886
- "properties": [],
1887
- "events": [],
1888
- "methods": []
1889
- },
1890
1890
  "eo-directory-tree": {
1891
1891
  "properties": [
1892
1892
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@next-bricks/nav",
3
- "version": "1.24.7",
3
+ "version": "1.24.8",
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": "2332fda0d51aafd84d08144f3659fc01cff28412"
46
+ "gitHead": "716b449480d80b9122daf320927e864b44aa8060"
47
47
  }
@@ -1,2 +0,0 @@
1
- "use strict";(globalThis.webpackChunk_next_bricks_nav=globalThis.webpackChunk_next_bricks_nav||[]).push([[2133],{403:(e,t,n)=>{n.d(t,{I:()=>i,K:()=>o,NS:()=>s,t:()=>r});var a=n(7117);let o=function(e){return e.ALL="ALL",e.QUICK_ACCESS="QUICK_ACCESS",e.PLATFORM_BASE="PLATFORM_BASE",e.SCENARIO_CENTER="SCENARIO_CENTER",e.SOLUTIONS="SOLUTIONS",e.OPEN_PLATFORM="OPEN_PLATFORM",e.SEARCH_PLACEHOLDER="SEARCH_PLACEHOLDER",e.RECENT_VISITS="RECENT_VISITS",e.FAVORITE="FAVORITE",e.UNFAVORITE="UNFAVORITE",e.FAVORITES_LIMIT_REACHED="FAVORITES_LIMIT_REACHED",e.FAVORITES_LIMIT_MESSAGE="FAVORITES_LIMIT_MESSAGE",e}({});const s="bricks/nav/launchpad-button-v2",i={en:{ALL:"All",QUICK_ACCESS:"Quick Access",PLATFORM_BASE:"Platform Base",SCENARIO_CENTER:"Scenario Center",SOLUTIONS:"Solutions",OPEN_PLATFORM:"Open Platform",SEARCH_PLACEHOLDER:"Search by keyword",RECENT_VISITS:"Recent Visits",FAVORITE:"Favorite",UNFAVORITE:"Unfavorite",FAVORITES_LIMIT_REACHED:"Favorites Limit Reached",FAVORITES_LIMIT_MESSAGE:"Current favorites count has reached the limit ({{count}} items). Please remove some favorites before adding new ones."},zh:{ALL:"全部",QUICK_ACCESS:"快捷访问",PLATFORM_BASE:"平台底座",SCENARIO_CENTER:"场景中心",SOLUTIONS:"解决方案",OPEN_PLATFORM:"开放平台",SEARCH_PLACEHOLDER:"通过关键字搜索",RECENT_VISITS:"最近访问",FAVORITE:"收藏",UNFAVORITE:"取消收藏",FAVORITES_LIMIT_REACHED:"收藏数量已达上限",FAVORITES_LIMIT_MESSAGE:"当前收藏链接数量已达上限({{count}}个),请删除部分收藏后再添加。"}},r=a.i18n.getFixedT(null,s)},2133:(e,t,n)=>{n.d(t,{fm:()=>b,ir:()=>M,pU:()=>B,sZ:()=>H});var a=n(8769),o=n(9475),s=n(2775),i=n(7137),r=n(7448),c=n(4864),l=n(9393),u=n(403),p=n(3346),d=n(7296),m=n(2824),I=n(2887),f=n(8406),h=n(1030);const E=10,A=10;var S,y=n(6659);async function v(){return(await(0,d.K)({page:1,pageSize:E},{interceptorParams:{ignoreLoadingBar:!0},noAbortOnRouteChange:!0})).list}function C(e,t){return e.id.toLowerCase().includes(t)||e.name.toLowerCase().includes(t)||e.description&&e.description.toLowerCase().includes(t)?e:null}function R(e,t){return e.id.toLowerCase().includes(t)||e.name.toLowerCase().includes(t)||e.description&&e.description.toLowerCase().includes(t)?e:null}(0,r.initializeReactI18n)(u.NS,u.I),(0,r.initializeReactI18n)(u.NS,u.I);const T=`launchpad-recent-visits:${null===(S=s.auth.getAuth())||void 0===S?void 0:S.org}`,g=new i.G(localStorage);let _=[],L=new Map,O=new Map,F=!1,w=[],k=!1,P=[],N=!1;const M=new c.x((async()=>{({menuGroups:_,microAppsById:L,customLinksById:O}=await async function(){var e;const t=await(0,p.i)({},{interceptorParams:{ignoreLoadingBar:!0},noAbortOnRouteChange:!0}),n=new Map;for(const e of t.storyboards){var a;const t=e.app;t.localeName=(0,y.y)(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.localeName=(0,y.y)(o.locales,o.name),o.type){case"app":{const e=n.get(o.id);e&&t.push({...o,url:e.homepage});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(t.localeName=(0,y.y)(t.locales,t.name),"app"===t.type){const a=n.get(t.id);a&&e.push({...t,url:a.homepage})}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&&(a.localeName=(0,y.y)(a.locales,a.name),o.push({...a,items:t}))}return{menuGroups:o,microAppsById:n,customLinksById:i}}()),F=!0})),b=new c.x((async()=>{w=await async function(){const e=await v(),t=[];for(const n of e)if("microApp"===n.type){const e=n.relatedApp,a=(0,y.y)(e.locales,e.name);t.push({favoriteId:n.instanceId,type:"app",name:a,id:e.appId,url:e.homepage,instanceId:e.instanceId,menuIcon:e.menuIcon})}else if("customItem"===n.type){const e=n.relatedCustomItem,a=(0,y.y)(e.locales,e.name);t.push({favoriteId:n.instanceId,type:"custom",name:a,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}(),k=!0})),B=new c.x((async()=>{P=await async function(){const e=(await(0,f.y)("MICRO_APP_CATEGORY@EASYOPS",{fields:["id","type","name","locales","icon","order","platformApps.appId","platformApps.name","platformApps.locales","platformApps.homepage","platformApps.description","platformApps.menuIcon","platformApps._object_id","platformApps.@.order","platformItems.id","platformItems.name","platformItems.locales","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,y.y)(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:(0,y.y)(e.locales,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,h.sortBy)([...t,...n],"order");return{instanceId:e.instanceId,id:e.id,name:(0,y.y)(e.locales,e.name),icon:e.icon,order:e.order,items:a}}));return[{id:"#all",name:(0,u.t)(u.K.ALL),icon:{lib:"easyops",category:"second-menu",icon:"sprint-planning-second-menu"},items:[]},...(0,h.sortBy)(t,"order")]}(),N=!0})),V=e=>(0,l.Ds)({type:"error",message:(0,o.httpErrorToString)(e)});function H(e){const{t}=(0,r.useTranslation)(u.NS),[n,s]=(0,a.useState)(_),[i,c]=(0,a.useState)(L),[p,d]=(0,a.useState)(O),[f,h]=(0,a.useState)(""),[S,y]=(0,a.useState)(!F),[H,D]=(0,a.useState)(!k),[x,G]=(0,a.useState)(!N),[K,Q]=(0,a.useState)([]),[j,z]=(0,a.useState)([]),[q,Y]=(0,a.useState)(w),[Z,$]=(0,a.useState)(P);(0,a.useEffect)((()=>{e&&!S&&(s(_),c(L),d(O))}),[e,S]),(0,a.useEffect)((()=>{e&&!H&&Y(w)}),[e,H]),(0,a.useEffect)((()=>{e&&!x&&$(P)}),[e,x]),(0,a.useEffect)((()=>{var t;e&&Q(null!==(t=g.getItem(T))&&void 0!==t?t:[])}),[e]),(0,a.useEffect)((()=>{e&&(async()=>{try{await M.fetch(),y(!1)}catch(e){(0,o.handleHttpError)(e)}})()}),[e]),(0,a.useEffect)((()=>{e&&(async()=>{try{await b.fetch(),D(!1)}catch(e){D(!1),V(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 B.fetch(),G(!1)}catch(e){G(!1),V(e)}})()}),[e]),(0,a.useEffect)((()=>{if(S)return;const e=K.map((e=>{if("app"===e.type){const t=i.get(e.id);return t?{type:"app",name:t.localeName,id:t.id,url:t.homepage,instanceId:t.instanceId,menuIcon:t.menuIcon}:null}const t=p.get(e.id);return t?{...t,name:t.localeName}:null})).filter(Boolean);z(e)}),[p,S,i,K]);const J=(0,a.useCallback)((e=>{var t;let{type:n,id:a}=e;const o=null!==(t=g.getItem(T))&&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>A&&o.pop(),g.setItem(T,o)}),[]),W=(0,a.useCallback)((e=>q.some((t=>U(e,t)))),[q]),X=(0,a.useCallback)((e=>{const n=q.findIndex((t=>"link"===e.type?t.favoriteId===e.favoriteId:U(e,t)));let a;if(n>-1){const e=q[n];a=q.slice(0,n).concat(q.slice(n+1)),async function(e){return e.favoriteId?(0,I.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,I.r)(a);console.error("Menu item to unstar not found:",e)}))}(e).catch(V)}else{if(q.length>=E)return void(0,l.ui)({type:"warn",title:t(u.K.FAVORITES_LIMIT_REACHED),content:t(u.K.FAVORITES_LIMIT_MESSAGE,{count:E})});const n={...e};a=q.concat(n),async function(e){return(0,m.k)({type:"app"===e.type?"microApp":"customItem",relatedInstanceId:e.instanceId},{interceptorParams:{ignoreLoadingBar:!0}})}(e).then((e=>{e&&(n.favoriteId=e.instanceId)}),V)}Y(a),w=a}),[q]),ee=(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 C(e,n);case"custom":return R(e,n);case"dir":{const t=e.items.map((e=>"app"===e.type?C(e,n):"custom"===e.type?R(e,n):null)).filter(Boolean);return t.length>0?{...e,items:t}:null}}})).filter(Boolean)}))).filter((e=>e.items.length>0))}(n,f)),[n,f]),te=(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 C(e,n);case"custom":return R(e,n)}})).filter(Boolean)})))}(Z,f)),[Z,f]);return{loading:S,q:f,setQ:h,menuGroups:ee,loadingFavorites:H,loadingPlatformCategories:x,favorites:q,recentVisits:j,pushRecentVisit:J,isStarred:W,toggleStar:X,platformCategories:te}}function U(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,{y:()=>o});var a=n(7117);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(4558);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.4907bccc.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"chunks/2133.4907bccc.js","mappings":"uLAEO,IAAKA,EAAC,SAADA,GAAC,OAADA,EAAC,UAADA,EAAC,4BAADA,EAAC,8BAADA,EAAC,kCAADA,EAAC,sBAADA,EAAC,8BAADA,EAAC,wCAADA,EAAC,8BAADA,EAAC,oBAADA,EAAC,wBAADA,EAAC,kDAADA,EAAC,kDAADA,CAAC,MAeb,MAgCaC,EAAK,iCAELC,EAAU,CAAEC,GAlCN,CACjBC,IAAK,MACLC,aAAc,eACdC,cAAe,gBACfC,gBAAiB,kBACjBC,UAAW,YACXC,cAAe,gBACfC,mBAAoB,oBACpBC,cAAe,gBACfC,SA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KAAI6H,IAAA,IAAEC,EAAMF,GAAUC,EAAA,MAAK,CAACC,EAAMF,EAAUpM,KAAK,KAEtD,OAAyB,QAAzB8L,GAAOS,EAAAA,EAAAA,UAASR,UAAS,IAAAD,EAAAA,EAAI9L,CAC/B,C,sFCHO,MAAMwM,GAAcC,EAAAA,EAAAA,WAAyC,WACvDC,GAAcD,EAAAA,EAAAA,WAA2B,WAGzC5C,GACX8C,EAAAA,EAAAA,gBAAmC,qBAExBjH,GAAmBiH,EAAAA,EAAAA,gBAC9B,0B","sources":["webpack:///./src/launchpad-button-v2/i18n.ts","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":["import { i18n } from \"@next-core/i18n\";\n\nexport enum K {\n ALL = \"ALL\",\n QUICK_ACCESS = \"QUICK_ACCESS\",\n PLATFORM_BASE = \"PLATFORM_BASE\",\n SCENARIO_CENTER = \"SCENARIO_CENTER\",\n SOLUTIONS = \"SOLUTIONS\",\n OPEN_PLATFORM = \"OPEN_PLATFORM\",\n SEARCH_PLACEHOLDER = \"SEARCH_PLACEHOLDER\",\n RECENT_VISITS = \"RECENT_VISITS\",\n FAVORITE = \"FAVORITE\",\n UNFAVORITE = \"UNFAVORITE\",\n FAVORITES_LIMIT_REACHED = \"FAVORITES_LIMIT_REACHED\",\n FAVORITES_LIMIT_MESSAGE = \"FAVORITES_LIMIT_MESSAGE\",\n}\n\nconst en: Locale = {\n ALL: \"All\",\n QUICK_ACCESS: \"Quick Access\",\n PLATFORM_BASE: \"Platform Base\",\n SCENARIO_CENTER: \"Scenario Center\",\n SOLUTIONS: \"Solutions\",\n OPEN_PLATFORM: \"Open Platform\",\n SEARCH_PLACEHOLDER: \"Search by keyword\",\n RECENT_VISITS: \"Recent Visits\",\n FAVORITE: \"Favorite\",\n UNFAVORITE: \"Unfavorite\",\n FAVORITES_LIMIT_REACHED: \"Favorites Limit Reached\",\n FAVORITES_LIMIT_MESSAGE:\n \"Current favorites count has reached the limit ({{count}} items). Please remove some favorites before adding new ones.\",\n};\n\nconst zh: Locale = {\n ALL: \"全部\",\n QUICK_ACCESS: \"快捷访问\",\n PLATFORM_BASE: \"平台底座\",\n SCENARIO_CENTER: \"场景中心\",\n SOLUTIONS: \"解决方案\",\n OPEN_PLATFORM: \"开放平台\",\n SEARCH_PLACEHOLDER: \"通过关键字搜索\",\n RECENT_VISITS: \"最近访问\",\n FAVORITE: \"收藏\",\n UNFAVORITE: \"取消收藏\",\n FAVORITES_LIMIT_REACHED: \"收藏数量已达上限\",\n FAVORITES_LIMIT_MESSAGE:\n \"当前收藏链接数量已达上限({{count}}个),请删除部分收藏后再添加。\",\n};\n\nexport const NS = \"bricks/nav/launchpad-button-v2\";\n\nexport const locales = { en, zh };\n\nexport const t = i18n.getFixedT(null, NS);\n\ntype Locale = { [k in K]: string } & {\n [k in K as `${k}_plural`]?: string;\n};\n","export const FAVORITES_LIMIT = 10;\nexport const RECENT_VISITS_LIMIT = 10;\n","import type { AppLocales, 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 UserServiceModels,\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 { initializeReactI18n } from \"@next-core/i18n/react\";\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 { getLocaleName } from \"../shared/getLocaleName\";\nimport { K, NS, t, locales } from \"./i18n\";\n\ninitializeReactI18n(NS, locales);\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 = getLocaleName(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 item.localeName = getLocaleName(item.locales, item.name);\n switch (item.type) {\n case \"app\": {\n const app = microAppsById.get(item.id);\n if (app) {\n items.push({\n ...item,\n url: app.homepage,\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 subItem.localeName = getLocaleName(subItem.locales, subItem.name);\n if (subItem.type === \"app\") {\n const app = microAppsById.get(subItem.id);\n if (app) {\n subItems.push({\n ...subItem,\n url: app.homepage,\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 group.localeName = getLocaleName(group.locales, group.name);\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 const localeName = getLocaleName(app.locales, app.name);\n stored.push({\n favoriteId: fav.instanceId,\n type: \"app\",\n name: 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 const localeName = getLocaleName(\n (\n customItem as UserServiceModels.ModelLaunchpadCollectionV2_relatedCustomItem & {\n locales?: AppLocales;\n }\n ).locales,\n customItem.name\n );\n stored.push({\n favoriteId: fav.instanceId,\n type: \"custom\",\n name: localeName,\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 \"locales\",\n \"icon\",\n \"order\",\n \"platformApps.appId\",\n \"platformApps.name\",\n \"platformApps.locales\",\n \"platformApps.homepage\",\n \"platformApps.description\",\n \"platformApps.menuIcon\",\n \"platformApps._object_id\",\n \"platformApps.@.order\",\n \"platformItems.id\",\n \"platformItems.name\",\n \"platformItems.locales\",\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: getLocaleName(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: getLocaleName(item.locales, 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: getLocaleName(category.locales, 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: t(K.ALL),\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 { initializeReactI18n, useTranslation } from \"@next-core/i18n/react\";\nimport { DeferredService } from \"../shared/DeferredService\";\nimport { showDialog, showNotification } from \"./wrapped-bricks\";\nimport { K, NS, locales } from \"./i18n\";\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\ninitializeReactI18n(NS, locales);\n\nconst storageKey = `launchpad-recent-visits:${\n (auth.getAuth() as Record<string, string>)?.org\n}`;\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 { t } = useTranslation(NS);\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\n const link = customLinksById.get(item.id);\n return link\n ? {\n ...link,\n name: link.localeName,\n }\n : null;\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: t(K.FAVORITES_LIMIT_REACHED) as string,\n content: t(K.FAVORITES_LIMIT_MESSAGE, { count: 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 getLocaleName(locales?: AppLocales | undefined, name?: string) {\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":["K","NS","locales","en","ALL","QUICK_ACCESS","PLATFORM_BASE","SCENARIO_CENTER","SOLUTIONS","OPEN_PLATFORM","SEARCH_PLACEHOLDER","RECENT_VISITS","FAVORITE","UNFAVORITE","FAVORITES_LIMIT_REACHED","FAVORITES_LIMIT_MESSAGE","zh","t","i18n","getFixedT","FAVORITES_LIMIT","RECENT_VISITS_LIMIT","async","fetchRawFavorites","LaunchpadApi_listCollectionV2","page","pageSize","interceptorParams","ignoreLoadingBar","noAbortOnRouteChange","list","matchMenuItemApp","item","lowerQ","id","toLowerCase","includes","name","description","matchMenuItemCustom","initializeReactI18n","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","getLocaleName","isBlockedPath","call","homepage","set","group","desktops","items","type","get","push","url","isBlockedHref","subItems","subItem","_auth$isBlockedHref2","length","fetchLaunchpadInfo","deferredFavorites","stored","fav","relatedApp","favoriteId","instanceId","appId","menuIcon","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","useTranslation","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","count","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":""}