Skip to content

增加周赛场次信息展示 #201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
},
"files.associations": {
"*.gafq": "lua",
"functional": "cpp"
"functional": "cpp",
"iostream": "cpp"
},
"leetcode-problem-rating.filePath": {
"default": {
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## version 2.18.1

- 增加周赛场次信息展示

## version 2.17.8

- 替换中文题解中的 textit
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vscode-leetcode-problem-rating",
"displayName": "LeetCode",
"description": "%main.description%",
"version": "2.17.8",
"version": "2.18.1",
"author": "ccagml",
"publisher": "ccagml",
"license": "MIT",
Expand Down
23 changes: 3 additions & 20 deletions resources/debug/entry/cpp/entry.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <vector>

#include "cJSON.h"

Expand All @@ -14,27 +14,10 @@ int main(int argc, char **argv)
{
for (int i = 0; i < argc; i++)
{
cout << "Argument " << i << " is " << argv[i] << endl;
cout << "arg " << i << " is " << argv[i] << endl;
}

// @@stub-for-body-code@@

// for (int i = 0; i < params.size(); i++)
// {
// string param = params[i];
// string paramType = paramsType[i];
// cJSON *item = cJSON_Parse(param.c_str());
// if (paramType == "number")
// {
// int num = parseNumber(item);
// res.push_back(&num);
// }
// else if (paramType == "number[]")
// {
// vector<int> vint = parseNumberArray(item);
// res.push_back(&vint);
// }
// }

return 0;
}
3 changes: 2 additions & 1 deletion src/debugex/debugCpp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,9 @@ class DebugCpp extends DebugBase {
Object.assign({}, debugConfig, {
request: "launch",
name: debugSessionName,
logging: { engineLogging: true, trace: true, traceResponse: true },
// logging: { engineLogging: true, trace: true, traceResponse: true },
args,

})
);

Expand Down
85 changes: 47 additions & 38 deletions src/rpc/factory/api/showApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* Copyright (c) 2022 ccagml . All rights reserved.
*/

let util = require("util");
// let util = require("util");
let childProcess = require("child_process");

import { storageUtils } from "../../utils/storageUtils";
Expand Down Expand Up @@ -110,23 +110,23 @@ class ShowApi extends ApiBase {
}

showProblem(problem, argv) {
const taglist = [problem.category]
.concat(problem.companies || [])
.concat(problem.tags || [])
.map((x) => " " + x + " ")
.join(" ");
const langlist = problem.templates
.map((x) => " " + x.value + " ")
.sort()
.join(" ");
// const taglist = [problem.category]
// .concat(problem.companies || [])
// .concat(problem.tags || [])
// .map((x) => " " + x + " ")
// .join(" ");
// const langlist = problem.templates
// .map((x) => " " + x.value + " ")
// .sort()
// .join(" ");

let code;
const needcode = argv.gen || argv.codeonly;
if (needcode) {
const template = problem.templates.find((x) => x.value === argv.lang);
if (!template) {
reply.info('Not supported language "' + argv.lang + '"');
reply.warn("Supported languages: " + langlist);
// reply.warn("Supported languages: " + langlist);
return;
}

Expand Down Expand Up @@ -157,33 +157,42 @@ class ShowApi extends ApiBase {
}
}

reply.info(`[${problem.fid}] ${problem.name}`);
reply.info();
reply.info(problem.link);
if (argv.extra) {
reply.info();
reply.info("Tags: " + taglist);
reply.info();
reply.info("Langs: " + langlist);
}

reply.info();
reply.info(`* ${problem.category}`);
reply.info(`* ${problem.level} (${problem.percent.toFixed(2)}%)`);

if (problem.likes) reply.info(`* Likes: ${problem.likes}`);
if (problem.dislikes) reply.info(`* Dislikes: ${problem.dislikes}`);
else reply.info(`* Dislikes: -`);
if (problem.totalAC) reply.info(`* Total Accepted: ${problem.totalAC}`);
if (problem.totalSubmit) reply.info(`* Total Submissions: ${problem.totalSubmit}`);
if (problem.testable && problem.testcase) {
let testcase_value = util.inspect(problem.testcase);
reply.info(`* Testcase Example: ${testcase_value}`);
}
if (filename) reply.info(`* Source Code: ${filename}`);

reply.info();
reply.info(problem.desc);
let preview_data: any = {};
preview_data.url = problem.link;
preview_data.category = `${problem.category}`;
preview_data.difficulty = `${problem.level} (${problem.percent.toFixed(2)}%)`;
preview_data.likes = `${problem.likes}`;
preview_data.dislikes = `${problem.dislikes}`;
preview_data.desc = problem.desc;
reply.info(JSON.stringify(preview_data));

// reply.info(`[${problem.fid}] ${problem.name}`);
// reply.info();
// reply.info(problem.link);
// if (argv.extra) {
// reply.info();
// reply.info("Tags: " + taglist);
// reply.info();
// reply.info("Langs: " + langlist);
// }

// reply.info();
// reply.info(`* ${problem.category}`);
// reply.info(`* ${problem.level} (${problem.percent.toFixed(2)}%)`);

// if (problem.likes) reply.info(`* Likes: ${problem.likes}`);
// if (problem.dislikes) reply.info(`* Dislikes: ${problem.dislikes}`);
// else reply.info(`* Dislikes: -`);
// if (problem.totalAC) reply.info(`* Total Accepted: ${problem.totalAC}`);
// if (problem.totalSubmit) reply.info(`* Total Submissions: ${problem.totalSubmit}`);
// if (problem.testable && problem.testcase) {
// let testcase_value = util.inspect(problem.testcase);
// reply.info(`* Testcase Example: ${testcase_value}`);
// }
// if (filename) reply.info(`* Source Code: ${filename}`);

// reply.info();
// reply.info(problem.desc);
}

call(argv) {
Expand Down
72 changes: 38 additions & 34 deletions src/service/PreviewService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,14 @@ class PreviewService extends BaseWebViewService {
}
</style>`,
};
const { title, url, category, difficulty, likes, dislikes, body } = this.description;
const { title, url, category, difficulty, likes, dislikes, body, contest_slug, problem_index, problem_score } =
this.description;
const head: string = markdownService.render(`# [${title}](${url})`);
const info: string = markdownService.render(
[
`| Category | Difficulty | Likes | Dislikes |`,
`| :------: | :--------: | :---: | :------: |`,
`| ${category} | ${difficulty} | ${likes} | ${dislikes} |`,
`| Category | Difficulty | Likes | Dislikes | ContestSlug | ProblemIndex | Score |`,
`| :------: | :--------: | :---: | :------: | :---------: | :----------: | :---: |`,
`| ${category} | ${difficulty} | ${likes} | ${dislikes} | ${contest_slug} | ${problem_index} | ${problem_score} | `,
].join("\n")
);
const tags: string = [
Expand Down Expand Up @@ -145,41 +146,41 @@ class PreviewService extends BaseWebViewService {
}
}

// private async hideSideBar(): Promise<void> {
// await commands.executeCommand("workbench.action.focusSideBar");
// await commands.executeCommand("workbench.action.toggleSidebarVisibility");
// }

private parseDescription(descString: string, problem: IProblem): IDescription {
const [
,
,
/* title */ url,
,
,
,
,
,
/* tags */ /* langs */ category,
difficulty,
likes,
dislikes,
,
,
,
,
/* accepted */ /* submissions */ /* testcase */ ...body
] = descString.split("\n");
// const [
// ,
// ,
// /* title */ url,
// ,
// ,
// ,
// ,
// ,
// /* tags */ /* langs */ category,
// difficulty,
// likes,
// dislikes,
// ,
// ,
// ,
// ,
// /* accepted */ /* submissions */ /* testcase */ ...body
// ] = descString.split("\n");

let preview_data = JSON.parse(descString);
return {
title: problem.name,
url,
url: preview_data.url,
tags: problem.tags,
companies: problem.companies,
category: category.slice(2),
difficulty: difficulty.slice(2),
likes: likes.split(": ")[1].trim(),
dislikes: dislikes.split(": ")[1].trim(),
body: body.join("\n").replace(/<pre>[\r\n]*([^]+?)[\r\n]*<\/pre>/g, "<pre><code>$1</code></pre>"),
category: preview_data.category,
difficulty: preview_data.difficulty,
likes: preview_data.likes,
dislikes: preview_data.dislikes,
body: preview_data.desc.replace(/<pre>[\r\n]*([^]+?)[\r\n]*<\/pre>/g, "<pre><code>$1</code></pre>"),
contest_slug: problem?.scoreData?.ContestSlug || "-",
problem_index: problem?.scoreData?.ProblemIndex || "-",
problem_score: problem?.scoreData?.score || "0",
};
}

Expand Down Expand Up @@ -209,6 +210,9 @@ interface IDescription {
likes: string;
dislikes: string;
body: string;
contest_slug: string;
problem_index: string;
problem_score: string;
}

interface IWebViewMessage {
Expand Down