Skip to content

Commit 42b52d6

Browse files
committed
update
1 parent cd4b4c1 commit 42b52d6

File tree

4 files changed

+8
-16
lines changed

4 files changed

+8
-16
lines changed

src/rpc/actionChain/chainNode/leetcode.cn.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ function getSolutionBySlug(question_slug: string, articles_slug: string, lang: s
272272
solution_result.author = solution.author.username;
273273
solution_result.votes = solution.voteCount;
274274
solution_result.body = content;
275+
solution_result.is_cn = true;
275276
reply.info(JSON.stringify({ code: 100, solution: solution_result }));
276277
});
277278
}

src/rpc/actionChain/chainNode/leetcode.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ and csrf token to the user object and saves the user object to the session. */
674674
getHelpOnline = (problem, _, lang) => {
675675
getHelpEn(problem, lang, function (e, solution) {
676676
if (e) return;
677-
if (!solution) return reply.error("Solution not found for " + lang);
677+
if (!solution) return reply.info(JSON.stringify({ code: -1, msg: `Solution not found for ${lang}` }));
678678
let URL_DISCUSS = "https://leetcode.com/problems/$slug/discuss/$id";
679679
let link = URL_DISCUSS.replace("$slug", problem.slug).replace("$id", solution.id);
680680
let content = solution.post.content.replace(/\\n/g, "\n").replace(/\\t/g, "\t");
@@ -687,6 +687,7 @@ and csrf token to the user object and saves the user object to the session. */
687687
solution_result.author = solution.post.author.username;
688688
solution_result.votes = solution.post.voteCount;
689689
solution_result.body = content;
690+
solution_result.is_cn = false;
690691
reply.info(JSON.stringify({ code: 100, solution: solution_result }));
691692
});
692693
};

src/rpc/actionChain/chainNode/solution.discuss.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/service/SolutionService.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ class SolutionService extends BaseWebViewService {
4242
const styles: string = markdownService.getStyles();
4343
const { title, url, lang, author, votes } = this.solution;
4444
const head: string = markdownService.render(`# [${title}](${url})`);
45-
const auth: string = `[${author}](https://leetcode.com/${author}/)`;
45+
const auth: string = this.solution.is_cn
46+
? `[${author}](https://leetcode.cn/u/${author}/)`
47+
: `[${author}](https://leetcode.com/${author}/)`;
4648
const info: string = markdownService.render(
4749
[
4850
`| Language | Author | Votes |`,
@@ -95,6 +97,7 @@ class SolutionService extends BaseWebViewService {
9597
solution.author = obj.solution.author;
9698
solution.votes = obj.solution.votes || 0;
9799
solution.body = obj.solution.body;
100+
solution.is_cn = obj.solution.is_cn;
98101
}
99102
return solution;
100103
}
@@ -108,6 +111,7 @@ class Solution {
108111
public author: string = "";
109112
public votes: string = "";
110113
public body: string = ""; // Markdown supported
114+
public is_cn?: boolean = false;
111115
}
112116

113117
export const solutionService: SolutionService = new SolutionService();

0 commit comments

Comments
 (0)