Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit24a59a3

Browse files
Vigilansjdneo
authored andcommitted
Support categorize the problem according to: Company, Difficulty, Tag & Favorite (LeetCode-OpenSource#94)
1 parent19fe753 commit24a59a3

11 files changed

+411
-233
lines changed

‎package-lock.json

Lines changed: 33 additions & 22 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎package.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,12 @@
193193
{
194194
"title":"LeetCode",
195195
"properties": {
196+
"leetcode.hideSolved": {
197+
"type":"boolean",
198+
"default":false,
199+
"scope":"application",
200+
"description":"Hide solved problems."
201+
},
196202
"leetcode.showLocked": {
197203
"type":"boolean",
198204
"default":false,
@@ -258,12 +264,14 @@
258264
"@types/fs-extra":"5.0.0",
259265
"@types/mocha":"^2.2.42",
260266
"@types/node":"^7.0.43",
267+
"@types/require-from-string":"^1.2.0",
261268
"tslint":"^5.9.1",
262269
"typescript":"^2.6.1",
263270
"vscode":"^1.1.22"
264271
},
265272
"dependencies": {
266273
"fs-extra":"^6.0.1",
267-
"leetcode-cli":"2.6.1"
274+
"leetcode-cli":"2.6.1",
275+
"require-from-string":"^2.0.2"
268276
}
269277
}

‎src/commands/list.ts

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,9 @@
44
import*asvscodefrom"vscode";
55
import{leetCodeExecutor}from"../leetCodeExecutor";
66
import{leetCodeManager}from"../leetCodeManager";
7-
import{ProblemState,UserStatus}from"../shared";
7+
import{IProblem,ProblemState,UserStatus}from"../shared";
88
import{DialogType,promptForOpenOutputChannel}from"../utils/uiUtils";
99

10-
exportinterfaceIProblem{
11-
favorite:boolean;
12-
locked:boolean;
13-
state:ProblemState;
14-
id:string;
15-
name:string;
16-
difficulty:string;
17-
passRate:string;
18-
}
19-
2010
exportasyncfunctionlistProblems():Promise<IProblem[]>{
2111
try{
2212
if(leetCodeManager.getStatus()===UserStatus.SignedOut){
@@ -28,17 +18,21 @@ export async function listProblems(): Promise<IProblem[]> {
2818
constproblems:IProblem[]=[];
2919
constlines:string[]=result.split("\n");
3020
constreg:RegExp=/^(.)\s(.{1,2})\s(.)\s\[\s*(\d*)\s*\]\s*(.*)\s*(Easy|Medium|Hard)\s*\((\s*\d+\.\d+%)\)/;
21+
const{ companies, tags}=awaitleetCodeExecutor.getCompaniesAndTags();
3122
for(constlineoflines){
3223
constmatch:RegExpMatchArray|null=line.match(reg);
3324
if(match&&match.length===8){
25+
constid:string=match[4].trim();
3426
problems.push({
35-
favorite:match[1].trim().length>0,
27+
id,
28+
isFavorite:match[1].trim().length>0,
3629
locked:match[2].trim().length>0,
3730
state:parseProblemState(match[3]),
38-
id:match[4].trim(),
3931
name:match[5].trim(),
4032
difficulty:match[6].trim(),
4133
passRate:match[7].trim(),
34+
companies:companies[id]||["Unknown"],
35+
tags:tags[id]||["Unknown"],
4236
});
4337
}
4438
}

‎src/commands/show.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
import*asfsefrom"fs-extra";
55
import*asvscodefrom"vscode";
6+
import{LeetCodeNode}from"../explorer/LeetCodeNode";
67
import{leetCodeExecutor}from"../leetCodeExecutor";
7-
import{LeetCodeNode}from"../leetCodeExplorer";
88
import{leetCodeManager}from"../leetCodeManager";
9-
import{IQuickItemEx,languages,ProblemState}from"../shared";
9+
import{IProblem,IQuickItemEx,languages,ProblemState}from"../shared";
1010
import{DialogOptions,DialogType,promptForOpenOutputChannel,promptForSignIn}from"../utils/uiUtils";
1111
import{selectWorkspaceFolder}from"../utils/workspaceUtils";
1212
import*aswslfrom"../utils/wslUtils";
@@ -80,9 +80,9 @@ async function showProblemInternal(id: string): Promise<void> {
8080
}
8181
}
8282

83-
asyncfunctionparseProblemsToPicks(p:Promise<list.IProblem[]>):Promise<Array<IQuickItemEx<string>>>{
83+
asyncfunctionparseProblemsToPicks(p:Promise<IProblem[]>):Promise<Array<IQuickItemEx<string>>>{
8484
returnnewPromise(async(resolve:(res:Array<IQuickItemEx<string>>)=>void):Promise<void>=>{
85-
constpicks:Array<IQuickItemEx<string>>=(awaitp).map((problem:list.IProblem)=>Object.assign({},{
85+
constpicks:Array<IQuickItemEx<string>>=(awaitp).map((problem:IProblem)=>Object.assign({},{
8686
label:`${parseProblemDecorator(problem.state,problem.locked)}${problem.id}.${problem.name}`,
8787
description:"",
8888
detail:`AC rate:${problem.passRate}, Difficulty:${problem.difficulty}`,

‎src/explorer/LeetCodeNode.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Copyright (c) jdneo. All rights reserved.
2+
// Licensed under the MIT license.
3+
4+
import{IProblem,ProblemState}from"../shared";
5+
6+
exportclassLeetCodeNode{
7+
constructor(privatedata:IProblem,privateparentNodeName:string,privateisProblemNode:boolean=true){}
8+
9+
publicgetlocked():boolean{
10+
returnthis.data.locked;
11+
}
12+
publicgetname():string{
13+
returnthis.data.name;
14+
}
15+
16+
publicgetstate():ProblemState{
17+
returnthis.data.state;
18+
}
19+
20+
publicgetid():string{
21+
returnthis.data.id;
22+
}
23+
24+
publicgetpassRate():string{
25+
returnthis.data.passRate;
26+
}
27+
28+
publicgetdifficulty():string{
29+
returnthis.data.difficulty;
30+
}
31+
32+
publicgettags():string[]{
33+
returnthis.data.tags;
34+
}
35+
36+
publicgetcompanies():string[]{
37+
returnthis.data.companies;
38+
}
39+
40+
publicgetisFavorite():boolean{
41+
returnthis.data.isFavorite;
42+
}
43+
44+
publicgetisProblem():boolean{
45+
returnthis.isProblemNode;
46+
}
47+
48+
publicgetparentName():string{
49+
returnthis.parentNodeName;
50+
}
51+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp