@@ -6,7 +6,7 @@ import { EventEmitter } from "events";
6
6
import * as vscode from "vscode" ;
7
7
import { leetCodeChannel } from "./leetCodeChannel" ;
8
8
import { leetCodeExecutor } from "./leetCodeExecutor" ;
9
- import { loginCommand , UserStatus } from "./shared" ;
9
+ import { IQuickItemEx , loginCommand , UserStatus } from "./shared" ;
10
10
import { createEnvOption } from "./utils/cpUtils" ;
11
11
import { DialogType , promptForOpenOutputChannel } from "./utils/uiUtils" ;
12
12
import * as wsl from "./utils/wslUtils" ;
@@ -34,13 +34,50 @@ class LeetCodeManager extends EventEmitter {
34
34
}
35
35
}
36
36
37
- public async signIn ( isByCookie : boolean = false , thirdParty : string = "Default" ) : Promise < void > {
38
- const loginArg : string | undefined = loginCommand . get ( thirdParty ) ;
39
- if ( ! loginArg ) {
40
- throw new Error ( `The third party "${ thirdParty } " is not supported.` ) ;
37
+ public async signIn ( ) : Promise < void > {
38
+ /*
39
+ LeetCode Account
40
+ LeetCode Cookie
41
+ Third-Party: GitHub
42
+ Third-Party: LinkedIn
43
+ */
44
+ const picks : Array < IQuickItemEx < string > > = [ ] ;
45
+ picks . push (
46
+ {
47
+ label : "LeetCode Account" ,
48
+ description : "" ,
49
+ detail : "Use LeetCode account to login" ,
50
+ value : "LeetCode" ,
51
+ } ,
52
+ {
53
+ label : "LeetCode Cookie" ,
54
+ description : "" ,
55
+ detail : "Use LeetCode cookie that copy from browser to login" ,
56
+ value : "Cookie" ,
57
+ } ,
58
+ {
59
+ label : "Third-Party: GitHub" ,
60
+ description : "" ,
61
+ detail : "Use third party GitHub account to login" ,
62
+ value : "GitHub" ,
63
+ } ,
64
+ {
65
+ label : "Third-Party: LinkedIn" ,
66
+ description : "" ,
67
+ detail : "Use third party LinkedIn account to login" ,
68
+ value : "LinkedIn" ,
69
+ } ,
70
+ ) ;
71
+ const choice : IQuickItemEx < string > | undefined = await vscode . window . showQuickPick ( picks ) ;
72
+ if ( ! choice ) {
73
+ return ;
41
74
}
42
- const cookieArg : string = "-c" ;
43
- const commandArg : string = isByCookie ? cookieArg : loginArg ;
75
+ const loginMethod : string = choice . value ;
76
+ const commandArg : string | undefined = loginCommand . get ( loginMethod ) ;
77
+ if ( ! commandArg ) {
78
+ throw new Error ( `The login method "${ loginMethod } " is not supported.` ) ;
79
+ }
80
+ const isByCookie : boolean = loginMethod === "Cookie" ;
44
81
const inMessage : string = isByCookie ? "sign in by cookie" : "sign in" ;
45
82
try {
46
83
const userName : string | undefined = await new Promise ( async ( resolve : ( res : string | undefined ) => void , reject : ( e : Error ) => void ) : Promise < void > => {
0 commit comments