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

Commitffdccec

Browse files
iFunjdneo
authored andcommitted
feat: added solution link (LeetCode-OpenSource#441)
1 parent01f5a28 commitffdccec

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

‎ACKNOWLEDGEMENTS.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
A big thanks to the following individuals for contributing:
44

5+
-[@JIEJIAN21](https://github.com/JIEJIAN21) - thanks for logo and icon design
56
-[@TsFreddie](https://github.com/TsFreddie)[contributions](https://github.com/jdneo/vscode-leetcode/commits?author=TsFreddie)
67
-[@ntt2k](https://github.com/ntt2k)[contributions](https://github.com/jdneo/vscode-leetcode/commits?author=ntt2k)
78
-[@purocean](https://github.com/purocean)[contributions](https://github.com/jdneo/vscode-leetcode/commits?author=purocean)
@@ -17,4 +18,5 @@ A big thanks to the following individuals for contributing:
1718
-[@houtianze](https://github.com/houtianze)[contributions](https://github.com/jdneo/vscode-leetcode/commits?author=houtianze)
1819
-[@magic-akari](https://github.com/magic-akari) -[contributions](https://github.com/jdneo/vscode-leetcode/commits?author=magic-akari)
1920
-[@SF-Zhou](https://github.com/SF-Zhou) -[contributions](https://github.com/jdneo/vscode-leetcode/commits?author=SF-Zhou)
20-
-[@JIEJIAN21](https://github.com/JIEJIAN21) - thanks for logo and icon design
21+
-[@fuafa](https://github.com/fuafa) -[contributions](https://github.com/jdneo/vscode-leetcode/commits?author=fuafa)
22+
-[@iFun](https://github.com/iFun) -[contributions](https://github.com/jdneo/vscode-leetcode/commits?author=iFun)

‎src/webview/leetCodePreviewProvider.ts

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
// Licensed under the MIT license.
33

44
import{commands,ViewColumn}from"vscode";
5-
import{IProblem}from"../shared";
5+
import{getLeetCodeEndpoint}from"../commands/plugin";
6+
import{Endpoint,IProblem}from"../shared";
67
import{ILeetCodeWebviewOption,LeetCodeWebview}from"./LeetCodeWebview";
78
import{markdownEngine}from"./markdownEngine";
89

@@ -73,9 +74,9 @@ class LeetCodePreviewProvider extends LeetCodeWebview {
7374
const{ title, url, category, difficulty, likes, dislikes, body}=this.description;
7475
consthead:string=markdownEngine.render(`# [${title}](${url})`);
7576
constinfo:string=markdownEngine.render([
76-
`| Category | Difficulty | Likes | Dislikes | [Discuss](${url.replace("/description/","/discuss/?currentPage=1&orderBy=most_votes&query=")}) |`,
77-
`| :------: | :--------: | :---: | :------: | :-----: |`,
78-
`|${category} |${difficulty} |${likes} |${dislikes} | -- |`,
77+
`| Category | Difficulty | Likes | Dislikes |`,
78+
`| :------: | :--------: | :---: | :------: |`,
79+
`|${category} |${difficulty} |${likes} |${dislikes} |`,
7980
].join("\n"));
8081
consttags:string=[
8182
`<details>`,
@@ -97,6 +98,7 @@ class LeetCodePreviewProvider extends LeetCodeWebview {
9798
),
9899
`</details>`,
99100
].join("\n");
101+
constlinks:string=markdownEngine.render(`[Discussion](${this.getDiscussionLink(url)}) | [Solution](${this.getSolutionLink(url)})`);
100102
return`
101103
<!DOCTYPE html>
102104
<html>
@@ -114,6 +116,8 @@ class LeetCodePreviewProvider extends LeetCodeWebview {
114116
${tags}
115117
${companies}
116118
${body}
119+
<hr />
120+
${links}
117121
${!this.sideMode ?button.element :""}
118122
<script>
119123
const vscode = acquireVsCodeApi();
@@ -172,6 +176,21 @@ class LeetCodePreviewProvider extends LeetCodeWebview {
172176
body:body.join("\n").replace(/<pre>[\r\n]*([^]+?)[\r\n]*<\/pre>/g,"<pre><code>$1</code></pre>"),
173177
};
174178
}
179+
180+
privategetDiscussionLink(url:string):string{
181+
constendPoint:string=getLeetCodeEndpoint();
182+
if(endPoint===Endpoint.LeetCodeCN){
183+
returnurl.replace("/description/","/comments/");
184+
}elseif(endPoint===Endpoint.LeetCode){
185+
returnurl.replace("/description/","/discuss/?currentPage=1&orderBy=most_votes&query=");
186+
}
187+
188+
return"https://leetcode.com";
189+
}
190+
191+
privategetSolutionLink(url:string):string{
192+
returnurl.replace("/description/","/solution/");
193+
}
175194
}
176195

177196
interfaceIDescription{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp