diff --git a/.vscode/settings.json b/.vscode/settings.json index 80c0026..c42e5f3 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -11,7 +11,8 @@ }, "files.associations": { "*.gafq": "lua", - "functional": "cpp" + "functional": "cpp", + "iostream": "cpp" }, "leetcode-problem-rating.filePath": { "default": { diff --git a/CHANGELOG.md b/CHANGELOG.md index 597afd8..f062c17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## version 2.18.1 + +- 增加周赛场次信息展示 + ## version 2.17.8 - 替换中文题解中的 textit diff --git a/package.json b/package.json index ea81049..fd17b0d 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/resources/debug/entry/cpp/entry.cpp b/resources/debug/entry/cpp/entry.cpp index 9dd4dbf..604dc73 100644 --- a/resources/debug/entry/cpp/entry.cpp +++ b/resources/debug/entry/cpp/entry.cpp @@ -1,8 +1,8 @@ +#include #include -#include #include #include -#include +#include #include "cJSON.h" @@ -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 vint = parseNumberArray(item); - // res.push_back(&vint); - // } - // } - return 0; } diff --git a/src/debugex/debugCpp.ts b/src/debugex/debugCpp.ts index 816c133..c468b18 100644 --- a/src/debugex/debugCpp.ts +++ b/src/debugex/debugCpp.ts @@ -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, + }) ); diff --git a/src/rpc/factory/api/showApi.ts b/src/rpc/factory/api/showApi.ts index 9a22297..8ee34a1 100644 --- a/src/rpc/factory/api/showApi.ts +++ b/src/rpc/factory/api/showApi.ts @@ -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"; @@ -110,15 +110,15 @@ 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; @@ -126,7 +126,7 @@ class ShowApi extends ApiBase { 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; } @@ -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) { diff --git a/src/service/PreviewService.ts b/src/service/PreviewService.ts index 9ac1915..f0795a7 100644 --- a/src/service/PreviewService.ts +++ b/src/service/PreviewService.ts @@ -76,13 +76,14 @@ class PreviewService extends BaseWebViewService { } `, }; - 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 = [ @@ -145,41 +146,41 @@ class PreviewService extends BaseWebViewService { } } - // private async hideSideBar(): Promise { - // 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(/
[\r\n]*([^]+?)[\r\n]*<\/pre>/g, "
$1
"), + category: preview_data.category, + difficulty: preview_data.difficulty, + likes: preview_data.likes, + dislikes: preview_data.dislikes, + body: preview_data.desc.replace(/
[\r\n]*([^]+?)[\r\n]*<\/pre>/g, "
$1
"), + contest_slug: problem?.scoreData?.ContestSlug || "-", + problem_index: problem?.scoreData?.ProblemIndex || "-", + problem_score: problem?.scoreData?.score || "0", }; } @@ -209,6 +210,9 @@ interface IDescription { likes: string; dislikes: string; body: string; + contest_slug: string; + problem_index: string; + problem_score: string; } interface IWebViewMessage {