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

Commit5ab223b

Browse files
author
xusupeng
committed
feat(explorer): 添加英文题目名称支持
在问题列表和展示功能中增加英文题目名称字段,用于生成不同格式的路径名称修改相关接口和逻辑以支持中英文题目名称切换
1 parent3f83267 commit5ab223b

File tree

7 files changed

+48
-4
lines changed

7 files changed

+48
-4
lines changed

‎.idea/.gitignore

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

‎.idea/indexLayout.xml

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

‎.idea/vcs.xml

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

‎src/commands/list.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ export async function listProblems(): Promise<IProblem[]> {
1616

1717
constuseEndpointTranslation:boolean=settingUtils.shouldUseEndpointTranslation();
1818
letresult=awaitleetCodeExecutor.listProblems(true,useEndpointTranslation);
19+
letresultEn=awaitleetCodeExecutor.listProblems(true,false);
20+
constreg:RegExp=/^(.)\s(.{1,2})\s(.)\s\[\s*(\d*)\s*\]\s*(.*)\s*(Easy|Medium|Hard)\s*\((\s*\d+\.\d+%)\)/;
1921
letclassic150Problems=[
2022
88,
2123
27,
@@ -271,8 +273,17 @@ export async function listProblems(): Promise<IProblem[]> {
271273
287
272274
]
273275
constproblems:IProblem[]=[];
276+
constlinesEn:string[]=resultEn.split("\n");
277+
constenNameMap:{[key:string]:string}={};
278+
for(constlineEnoflinesEn){
279+
constmatchEn:RegExpMatchArray|null=lineEn.match(reg);
280+
if(matchEn&&matchEn.length===8){
281+
constidEn:string=matchEn[4].trim();
282+
enNameMap[idEn]=matchEn[5].trim();
283+
}
284+
}
274285
constlines:string[]=result.split("\n");
275-
constreg:RegExp=/^(.)\s(.{1,2})\s(.)\s\[\s*(\d*)\s*\]\s*(.*)\s*(Easy|Medium|Hard)\s*\((\s*\d+\.\d+%)\)/;
286+
276287
const{ companies, tags}=awaitleetCodeExecutor.getCompaniesAndTags();
277288
for(constlineoflines){
278289
constmatch:RegExpMatchArray|null=line.match(reg);
@@ -286,6 +297,7 @@ export async function listProblems(): Promise<IProblem[]> {
286297
isHot100:hot100Problems.includes(Number(id)),
287298
isClassic150:classic150Problems.includes(Number(id)),
288299
name:match[5].trim(),
300+
nameEn:enNameMap[id],
289301
difficulty:match[6].trim(),
290302
passRate:match[7].trim(),
291303
companies:companies[id]||["Unknown"],

‎src/commands/show.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,12 +263,12 @@ async function resolveRelativePath(relativePath: string, node: IProblem, selecte
263263
case"name":
264264
returnnode.name;
265265
case"camelcasename":
266-
return_.camelCase(node.name);
266+
return_.camelCase(node.nameEn);
267267
case"pascalcasename":
268-
return_.upperFirst(_.camelCase(node.name));
268+
return_.upperFirst(_.camelCase(node.nameEn));
269269
case"kebabcasename":
270270
case"kebab-case-name":
271-
return_.kebabCase(node.name);
271+
return_.kebabCase(node.nameEn);
272272
case"snakecasename":
273273
case"snake_case_name":
274274
return_.snakeCase(node.name);

‎src/explorer/LeetCodeNode.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ export class LeetCodeNode {
3434
publicgettags():string[]{
3535
returnthis.data.tags;
3636
}
37+
publicgetnameEn():string{
38+
returnthis.data.nameEn;
39+
}
3740

3841
publicgetcompanies():string[]{
3942
returnthis.data.companies;

‎src/shared.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export interface IProblem {
7979
state:ProblemState;
8080
id:string;
8181
name:string;
82+
nameEn:string;
8283
difficulty:string;
8384
passRate:string;
8485
companies:string[];
@@ -93,6 +94,7 @@ export const defaultProblem: IProblem = {
9394
isClassic150:false,
9495
id:"",
9596
name:"",
97+
nameEn:"",
9698
difficulty:"",
9799
passRate:"",
98100
companies:[]asstring[],

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp