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

Commit43feaa3

Browse files
authored
revert the change of result page (LeetCode-OpenSource#254)
1 parentd935977 commit43feaa3

File tree

2 files changed

+12
-65
lines changed

2 files changed

+12
-65
lines changed

‎CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
99
- Add a setting`leetcode.nodePath` to specify the`Node.js` executable path[#227](https://github.com/jdneo/vscode-leetcode/issues/227)
1010

1111
##Changed
12-
- Improve the submission result page
1312
- Update the activity bar icon, See:[#225](https://github.com/jdneo/vscode-leetcode/pull/225)
1413

1514
##Fixed

‎src/webview/leetCodeResultProvider.ts

Lines changed: 12 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
// Copyright (c) jdneo. All rights reserved.
22
// Licensed under the MIT license.
33

4-
import*as_from"lodash";
54
import{Disposable,ExtensionContext,ViewColumn,WebviewPanel,window}from"vscode";
6-
import{markdownEngine}from"./markdownEngine";
75

86
classLeetCodeResultProviderimplementsDisposable{
97

@@ -14,21 +12,19 @@ class LeetCodeResultProvider implements Disposable {
1412
this.context=context;
1513
}
1614

17-
publicasyncshow(resultString:string):Promise<void>{
15+
publicasyncshow(result:string):Promise<void>{
1816
if(!this.panel){
19-
this.panel=window.createWebviewPanel("leetcode.result","Submission Result",ViewColumn.Two,{
17+
this.panel=window.createWebviewPanel("leetcode.result","LeetCode Results",ViewColumn.Two,{
2018
retainContextWhenHidden:true,
2119
enableFindWidget:true,
22-
localResourceRoots:markdownEngine.localResourceRoots,
2320
});
2421

2522
this.panel.onDidDispose(()=>{
2623
this.panel=undefined;
2724
},null,this.context.subscriptions);
2825
}
2926

30-
constresult:IResult=this.parseResult(resultString);
31-
this.panel.webview.html=this.getWebViewContent(result);
27+
this.panel.webview.html=awaitthis.provideHtmlContent(result);
3228
this.panel.reveal(ViewColumn.Two);
3329
}
3430

@@ -38,67 +34,19 @@ class LeetCodeResultProvider implements Disposable {
3834
}
3935
}
4036

41-
privateparseResult(raw:string):IResult{
42-
raw=raw.concat(" √ ");// Append a dummy sentinel to the end of raw string
43-
constregSplit:RegExp=/[×vx]([^]+?)\n(?=[×vx])/g;
44-
constregKeyVal:RegExp=/(.+?):([^]*)/;
45-
constresult:IResult={messages:[]};
46-
letentry:RegExpExecArray|null;
47-
do{
48-
entry=regSplit.exec(raw);
49-
if(!entry){
50-
continue;
51-
}
52-
constkvMatch:RegExpExecArray|null=regKeyVal.exec(entry[1]);
53-
if(kvMatch){
54-
constkey:string=_.startCase(kvMatch[1]);
55-
letvalue:string=kvMatch[2];
56-
if(!result[key]){
57-
result[key]=[];
58-
}
59-
if(key==="Testcase"){
60-
value=value.slice(1,-1).replace("\\n","\n");
61-
}
62-
result[key].push(value);
63-
}else{
64-
result.messages.push(entry[1]);
65-
}
66-
}while(entry);
67-
returnresult;
68-
}
69-
70-
privategetWebViewContent(result:IResult):string{
71-
conststyles:string=markdownEngine.getStylesHTML();
72-
consttitle:string=`##${result.messages[0]}`;
73-
constmessages:string[]=result.messages.slice(1).map((m:string)=>`*${m}`);
74-
constsections:string[]=Object.keys(result).filter((k:string)=>k!=="messages").map((key:string)=>[
75-
`###${key}`,
76-
"```",
77-
result[key].join("\n\n"),
78-
"```",
79-
].join("\n"));
80-
constbody:string=markdownEngine.render([
81-
title,
82-
...messages,
83-
...sections,
84-
].join("\n"));
85-
return`
86-
<!DOCTYPE html>
87-
<html>
37+
privateasyncprovideHtmlContent(result:string):Promise<string>{
38+
return`<!DOCTYPE html>
39+
<html lang="en">
8840
<head>
89-
${styles}
41+
<meta charset="UTF-8">
42+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
43+
<title>LeetCode Results</title>
9044
</head>
91-
<body>
92-
${body}
45+
<body>
46+
<pre>${result.trim()}</pre>
9347
</body>
94-
</html>
95-
`;
48+
</html>`;
9649
}
9750
}
9851

99-
interfaceIResult{
100-
[key:string]:string[];
101-
messages:string[];
102-
}
103-
10452
exportconstleetCodeResultProvider:LeetCodeResultProvider=newLeetCodeResultProvider();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp