|
7 | 7 | * Copyright (c) 2022 ccagml . All rights reserved.
|
8 | 8 | */
|
9 | 9 |
|
10 |
| -let util = require("util"); |
| 10 | +// let util = require("util"); |
11 | 11 | let childProcess = require("child_process");
|
12 | 12 |
|
13 | 13 | import { storageUtils } from "../../utils/storageUtils";
|
@@ -110,23 +110,23 @@ class ShowApi extends ApiBase {
|
110 | 110 | }
|
111 | 111 |
|
112 | 112 | showProblem(problem, argv) {
|
113 |
| - const taglist = [problem.category] |
114 |
| - .concat(problem.companies || []) |
115 |
| - .concat(problem.tags || []) |
116 |
| - .map((x) => " " + x + " ") |
117 |
| - .join(" "); |
118 |
| - const langlist = problem.templates |
119 |
| - .map((x) => " " + x.value + " ") |
120 |
| - .sort() |
121 |
| - .join(" "); |
| 113 | + // const taglist = [problem.category] |
| 114 | + // .concat(problem.companies || []) |
| 115 | + // .concat(problem.tags || []) |
| 116 | + // .map((x) => " " + x + " ") |
| 117 | + // .join(" "); |
| 118 | + // const langlist = problem.templates |
| 119 | + // .map((x) => " " + x.value + " ") |
| 120 | + // .sort() |
| 121 | + // .join(" "); |
122 | 122 |
|
123 | 123 | let code;
|
124 | 124 | const needcode = argv.gen || argv.codeonly;
|
125 | 125 | if (needcode) {
|
126 | 126 | const template = problem.templates.find((x) => x.value === argv.lang);
|
127 | 127 | if (!template) {
|
128 | 128 | reply.info('Not supported language "' + argv.lang + '"');
|
129 |
| - reply.warn("Supported languages: " + langlist); |
| 129 | + // reply.warn("Supported languages: " + langlist); |
130 | 130 | return;
|
131 | 131 | }
|
132 | 132 |
|
@@ -157,33 +157,42 @@ class ShowApi extends ApiBase {
|
157 | 157 | }
|
158 | 158 | }
|
159 | 159 |
|
160 |
| - reply.info(`[${problem.fid}] ${problem.name}`); |
161 |
| - reply.info(); |
162 |
| - reply.info(problem.link); |
163 |
| - if (argv.extra) { |
164 |
| - reply.info(); |
165 |
| - reply.info("Tags: " + taglist); |
166 |
| - reply.info(); |
167 |
| - reply.info("Langs: " + langlist); |
168 |
| - } |
169 |
| - |
170 |
| - reply.info(); |
171 |
| - reply.info(`* ${problem.category}`); |
172 |
| - reply.info(`* ${problem.level} (${problem.percent.toFixed(2)}%)`); |
173 |
| - |
174 |
| - if (problem.likes) reply.info(`* Likes: ${problem.likes}`); |
175 |
| - if (problem.dislikes) reply.info(`* Dislikes: ${problem.dislikes}`); |
176 |
| - else reply.info(`* Dislikes: -`); |
177 |
| - if (problem.totalAC) reply.info(`* Total Accepted: ${problem.totalAC}`); |
178 |
| - if (problem.totalSubmit) reply.info(`* Total Submissions: ${problem.totalSubmit}`); |
179 |
| - if (problem.testable && problem.testcase) { |
180 |
| - let testcase_value = util.inspect(problem.testcase); |
181 |
| - reply.info(`* Testcase Example: ${testcase_value}`); |
182 |
| - } |
183 |
| - if (filename) reply.info(`* Source Code: ${filename}`); |
184 |
| - |
185 |
| - reply.info(); |
186 |
| - reply.info(problem.desc); |
| 160 | + let preview_data: any = {}; |
| 161 | + preview_data.url = problem.link; |
| 162 | + preview_data.category = `${problem.category}`; |
| 163 | + preview_data.difficulty = `${problem.level} (${problem.percent.toFixed(2)}%)`; |
| 164 | + preview_data.likes = `${problem.likes}`; |
| 165 | + preview_data.dislikes = `${problem.dislikes}`; |
| 166 | + preview_data.desc = problem.desc; |
| 167 | + reply.info(JSON.stringify(preview_data)); |
| 168 | + |
| 169 | + // reply.info(`[${problem.fid}] ${problem.name}`); |
| 170 | + // reply.info(); |
| 171 | + // reply.info(problem.link); |
| 172 | + // if (argv.extra) { |
| 173 | + // reply.info(); |
| 174 | + // reply.info("Tags: " + taglist); |
| 175 | + // reply.info(); |
| 176 | + // reply.info("Langs: " + langlist); |
| 177 | + // } |
| 178 | + |
| 179 | + // reply.info(); |
| 180 | + // reply.info(`* ${problem.category}`); |
| 181 | + // reply.info(`* ${problem.level} (${problem.percent.toFixed(2)}%)`); |
| 182 | + |
| 183 | + // if (problem.likes) reply.info(`* Likes: ${problem.likes}`); |
| 184 | + // if (problem.dislikes) reply.info(`* Dislikes: ${problem.dislikes}`); |
| 185 | + // else reply.info(`* Dislikes: -`); |
| 186 | + // if (problem.totalAC) reply.info(`* Total Accepted: ${problem.totalAC}`); |
| 187 | + // if (problem.totalSubmit) reply.info(`* Total Submissions: ${problem.totalSubmit}`); |
| 188 | + // if (problem.testable && problem.testcase) { |
| 189 | + // let testcase_value = util.inspect(problem.testcase); |
| 190 | + // reply.info(`* Testcase Example: ${testcase_value}`); |
| 191 | + // } |
| 192 | + // if (filename) reply.info(`* Source Code: ${filename}`); |
| 193 | + |
| 194 | + // reply.info(); |
| 195 | + // reply.info(problem.desc); |
187 | 196 | }
|
188 | 197 |
|
189 | 198 | call(argv) {
|
|
0 commit comments