@@ -21,8 +21,8 @@ export class PontAPITreeItem extends vscode.TreeItem {
21
21
}
22
22
23
23
export class PontAPIExplorer {
24
- static getProductItems ( products :Array < Product > , element :PontAPITreeItem = null ) {
25
- return products ?. map ( product => {
24
+ static getProductItems ( products : Array < Product > , element : PontAPITreeItem = null ) {
25
+ return products ?. map ( ( product ) => {
26
26
return {
27
27
specName : product . code ,
28
28
modName : "" ,
@@ -38,12 +38,12 @@ export class PontAPIExplorer {
38
38
{
39
39
specName : product . code ,
40
40
modName : "clickItem" ,
41
- label : product . name
41
+ label : product . name ,
42
42
} ,
43
43
] ,
44
44
} ,
45
45
} ;
46
- } )
46
+ } ) ;
47
47
}
48
48
static getDirItems ( spec : PontSpec , element = null ) {
49
49
const dirs = element ?. children || spec ?. ext ?. directories || [ ] ;
@@ -230,19 +230,19 @@ export class AlicloudApiExplorer implements vscode.TreeDataProvider<PontChangeTr
230
230
stagedDiffs : any [ ] = [ ] ;
231
231
allDiffs : any [ ] = [ ] ;
232
232
233
- getCNNameOfProduct ( products : Array < Product > , code :string ) {
233
+ getCNNameOfProduct ( products : Array < Product > , code : string ) {
234
234
const findProduct = products ?. find ( ( product ) => product . code === code ) ;
235
235
return `${ findProduct ?. name ? findProduct ?. name : findProduct ?. code } ` ;
236
236
}
237
237
238
238
getAPIManagerChildren ( element ?: PontAPITreeItem ) : vscode . ProviderResult < PontAPITreeItem [ ] > {
239
- if ( element . contextValue === "alicloudProducts" ) {
239
+ if ( element . contextValue === "alicloudProducts" ) {
240
240
const productExplorer = getProductRequestInstance ( ) ;
241
- const productGroups = _ . groupBy ( productExplorer ?. products , ( product ) => product . group )
242
- return ( Object . keys ( productGroups || { } ) ) ?. map ( ( group ) => {
241
+ const productGroups = _ . groupBy ( productExplorer ?. products , ( product ) => product . group ) ;
242
+ return Object . keys ( productGroups || { } ) ?. map ( ( group ) => {
243
243
return {
244
244
specName : group ,
245
- contextValue : ' productGroup' ,
245
+ contextValue : " productGroup" ,
246
246
label : `${ group } ` ,
247
247
modName : group ,
248
248
collapsibleState : vscode . TreeItemCollapsibleState . Collapsed ,
@@ -258,8 +258,8 @@ export class AlicloudApiExplorer implements vscode.TreeDataProvider<PontChangeTr
258
258
const productExplorer = getProductRequestInstance ( ) ;
259
259
260
260
return this . pontManager . localPontSpecs . map ( ( spec ) => {
261
- const [ specName , version ] = spec . name . split ( "::" )
262
-
261
+ const [ specName , version ] = spec . name . split ( "::" ) ;
262
+
263
263
return {
264
264
specName : spec . name ,
265
265
contextValue : "Spec" ,
@@ -306,12 +306,11 @@ export class AlicloudApiExplorer implements vscode.TreeDataProvider<PontChangeTr
306
306
} ) ;
307
307
} else if ( element . contextValue === "Dir" && spec ) {
308
308
return PontAPIExplorer . getDirItems ( spec , element ) ;
309
- } else if ( element . contextValue === "productGroup" ) {
309
+ } else if ( element . contextValue === "productGroup" ) {
310
310
const productExplorer = getProductRequestInstance ( ) ;
311
- const productGroups = _ . groupBy ( productExplorer ?. products , ( product ) => product . group )
312
- return PontAPIExplorer . getProductItems ( productGroups [ element ?. modName ?. toString ( ) ] , element )
313
- }
314
- else {
311
+ const productGroups = _ . groupBy ( productExplorer ?. products , ( product ) => product . group ) ;
312
+ return PontAPIExplorer . getProductItems ( productGroups [ element ?. modName ?. toString ( ) ] , element ) ;
313
+ } else {
315
314
return PontAPIExplorer . getDirItems ( spec ) ;
316
315
}
317
316
}
@@ -364,10 +363,42 @@ export class AlicloudApiExplorer implements vscode.TreeDataProvider<PontChangeTr
364
363
this . updatePontManager ( newManager ) ;
365
364
this . updateDiffs ( ) ;
366
365
vscode . window . showInformationMessage ( "订阅成功" ) ;
366
+ this . launchExperienceQuestionnaire ( ) ;
367
367
}
368
368
}
369
369
}
370
370
371
+ async launchExperienceQuestionnaire ( ) {
372
+ const globalState = this . context . globalState ;
373
+ const lastPromptKey = "lastPromptTime" ;
374
+ const experienceQuestionnaireKey = "questionnaireExpiration" ;
375
+ const questionnaireExpiration = globalState . get ( experienceQuestionnaireKey ) as any ;
376
+ // 检查上次提示的时间
377
+ const lastPromptTime = globalState . get ( lastPromptKey ) as any ;
378
+ // 选择关闭 1天 后执行订阅相关操作会再次触发,选择去反馈或30天内不再弹出则 30 天后才会再次触发
379
+ if ( ! lastPromptTime || Date . now ( ) - lastPromptTime > ( questionnaireExpiration || 0 ) * 24 * 60 * 60 * 1000 ) {
380
+ // 显示信息弹窗
381
+ let result = await vscode . window . showInformationMessage (
382
+ "您在使用插件期间是否遇到问题?欢迎吐槽或点赞,您的反馈对我们十分重要!" ,
383
+ "去反馈" ,
384
+ "关闭" ,
385
+ "30天内不再弹出" ,
386
+ ) ;
387
+ if ( result === "去反馈" ) {
388
+ vscode . env . openExternal (
389
+ vscode . Uri . parse ( "https://g.alicdn.com/aes/tracker-survey-preview/0.0.13/survey.html?pid=fePxMy&id=3486" ) ,
390
+ ) ;
391
+ globalState . update ( experienceQuestionnaireKey , 30 ) ;
392
+ }
393
+ else if ( result === "30天内不再弹出" ) {
394
+ globalState . update ( experienceQuestionnaireKey , 30 ) ;
395
+ } else {
396
+ globalState . update ( experienceQuestionnaireKey , 1 ) ;
397
+ }
398
+ globalState . update ( lastPromptKey , Date . now ( ) ) ;
399
+ }
400
+ }
401
+
371
402
async removeSubscriptions ( specName : string ) {
372
403
const pontxConfig = await findAlicloudAPIConfig ( this . context ) ;
373
404
const newOrigins = pontxConfig ?. origins ?. filter ( ( item ) => item . name !== specName ) || [ ] ;
@@ -388,6 +419,7 @@ export class AlicloudApiExplorer implements vscode.TreeDataProvider<PontChangeTr
388
419
389
420
await this . updatePontManager ( newManager ) ;
390
421
vscode . window . showInformationMessage ( "取消订阅成功" ) ;
422
+ this . launchExperienceQuestionnaire ( ) ;
391
423
}
392
424
}
393
425
@@ -409,17 +441,17 @@ export class AlicloudApiExplorer implements vscode.TreeDataProvider<PontChangeTr
409
441
this . updateDiffs ( ) ;
410
442
}
411
443
const service = alicloudAPIMessageService ;
412
- vscode . commands . registerCommand ( "alicloud.api.addSubscription" , async ( element ) => {
413
- if ( element . modName === ' clickItem' ) {
444
+ vscode . commands . registerCommand ( "alicloud.api.addSubscription" , async ( element ) => {
445
+ if ( element . modName === " clickItem" ) {
414
446
// 取消订阅
415
447
let result = await vscode . window . showInformationMessage ( `是否订阅${ element . label } ?` , "Yes" , "No" ) ;
416
448
if ( result === "No" ) {
417
- return
449
+ return ;
418
450
}
419
451
}
420
- const productExplorer = getProductRequestInstance ( )
452
+ const productExplorer = getProductRequestInstance ( ) ;
421
453
const selectedProduct = productExplorer ?. products ?. find ( ( item ) => item ?. code === element ?. specName ) ;
422
- const pickItem = AlicloudApiCommands . getPickProductItems ( selectedProduct )
454
+ const pickItem = AlicloudApiCommands . getPickProductItems ( selectedProduct ) ;
423
455
if ( pickItem . versions ?. length > 1 ) {
424
456
vscode . window
425
457
. showQuickPick ( pickItem . versions , {
@@ -432,11 +464,12 @@ export class AlicloudApiExplorer implements vscode.TreeDataProvider<PontChangeTr
432
464
} else {
433
465
this . subscribeProduct ( pickItem . code , ( pickItem . versions [ 0 ] as any ) . key ) ;
434
466
}
435
- } )
467
+ } ) ;
436
468
vscode . commands . registerCommand ( "alicloud.api.addSubscriptions" , async ( ) => {
437
469
// 搜索+订阅功能
438
- const productExplorer = getProductRequestInstance ( )
439
- const items = productExplorer ?. products ?. map ( ( item ) => {
470
+ const productExplorer = getProductRequestInstance ( ) ;
471
+ const items = productExplorer ?. products
472
+ ?. map ( ( item ) => {
440
473
return AlicloudApiCommands . getPickProductItems ( item ) ;
441
474
} )
442
475
. reduce ( ( pre , next ) => pre . concat ( next ) , [ ] ) ;
@@ -467,8 +500,9 @@ export class AlicloudApiExplorer implements vscode.TreeDataProvider<PontChangeTr
467
500
468
501
vscode . commands . registerCommand ( "alicloud.api.searchProducts" , async ( ) => {
469
502
// 搜索+订阅功能
470
- const productExplorer = getProductRequestInstance ( )
471
- const items = productExplorer ?. products ?. map ( ( item ) => {
503
+ const productExplorer = getProductRequestInstance ( ) ;
504
+ const items = productExplorer ?. products
505
+ ?. map ( ( item ) => {
472
506
return AlicloudApiCommands . getPickProductItems ( item ) ;
473
507
} )
474
508
. reduce ( ( pre , next ) => pre . concat ( next ) , [ ] ) ;
@@ -496,7 +530,7 @@ export class AlicloudApiExplorer implements vscode.TreeDataProvider<PontChangeTr
496
530
}
497
531
} ) ;
498
532
} ) ;
499
-
533
+
500
534
vscode . commands . registerCommand ( "alicloud.api.removeSubscriptions" , async ( meta ) => {
501
535
if ( meta . specName ) {
502
536
// 取消订阅
0 commit comments