Skip to content

Commit ab84338

Browse files
committed
update
1 parent 8056dea commit ab84338

File tree

7 files changed

+201
-77
lines changed

7 files changed

+201
-77
lines changed

package.json

Lines changed: 111 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,43 @@
9494
"category": "LeetCode"
9595
},
9696
{
97-
"command": "lcpr.setBricksType",
98-
"title": "设置提交几天后出现在工地",
97+
"command": "lcpr.setBricksType0",
98+
"title": "设置不出现在工地",
99+
"category": "LeetCode"
100+
},
101+
{
102+
"command": "lcpr.setBricksType1",
103+
"title": "设置14天后出现在工地",
104+
"category": "LeetCode"
105+
},
106+
{
107+
"command": "lcpr.setBricksType2",
108+
"title": "设置7天后出现在工地",
109+
"category": "LeetCode"
110+
},
111+
{
112+
"command": "lcpr.setBricksType3",
113+
"title": "设置5天后出现在工地",
114+
"category": "LeetCode"
115+
},
116+
{
117+
"command": "lcpr.setBricksType4",
118+
"title": "设置3天后出现在工地",
119+
"category": "LeetCode"
120+
},
121+
{
122+
"command": "lcpr.setBricksType5",
123+
"title": "设置2天后出现在工地",
124+
"category": "LeetCode"
125+
},
126+
{
127+
"command": "lcpr.setBricksType6",
128+
"title": "设置1天后出现在工地",
129+
"category": "LeetCode"
130+
},
131+
{
132+
"command": "lcpr.setBricksType7",
133+
"title": "设置1天后出现在工地",
99134
"category": "LeetCode"
100135
},
101136
{
@@ -106,7 +141,7 @@
106141
},
107142
{
108143
"command": "lcpr.showSolution",
109-
"title": "Show Top Voted Solution",
144+
"title": "获取题解",
110145
"category": "LeetCode"
111146
},
112147
{
@@ -225,7 +260,7 @@
225260
"group": "leetcode@3"
226261
},
227262
{
228-
"command": "lcpr.setBricksType",
263+
"submenu": "lcpr.setBricksType_sub",
229264
"when": "view == QuestionExplorer && viewItem =~ /problem*/",
230265
"group": "leetcode@4"
231266
},
@@ -255,7 +290,7 @@
255290
"group": "leetcode@3"
256291
},
257292
{
258-
"command": "lcpr.setBricksType",
293+
"submenu": "lcpr.setBricksType_sub1",
259294
"when": "view == BricksExplorer && viewItem == bricks",
260295
"group": "leetcode@4"
261296
}
@@ -296,10 +331,10 @@
296331
],
297332
"editor/context": [
298333
{
299-
"submenu": "leetcode.editorAction"
334+
"submenu": "lcpr.editorAction"
300335
}
301336
],
302-
"leetcode.editorAction": [
337+
"lcpr.editorAction": [
303338
{
304339
"command": "lcpr.testSolution",
305340
"group": "leetcode@1"
@@ -316,12 +351,80 @@
316351
"command": "lcpr.previewProblem",
317352
"group": "leetcode@4"
318353
}
354+
],
355+
"lcpr.setBricksType_sub": [
356+
{
357+
"command": "lcpr.setBricksType0",
358+
"group": "leetcode@1"
359+
},
360+
{
361+
"command": "lcpr.setBricksType6",
362+
"group": "leetcode@2"
363+
},
364+
{
365+
"command": "lcpr.setBricksType5",
366+
"group": "leetcode@3"
367+
},
368+
{
369+
"command": "lcpr.setBricksType4",
370+
"group": "leetcode@4"
371+
},
372+
{
373+
"command": "lcpr.setBricksType3",
374+
"group": "leetcode@5"
375+
},
376+
{
377+
"command": "lcpr.setBricksType2",
378+
"group": "leetcode@6"
379+
},
380+
{
381+
"command": "lcpr.setBricksType1",
382+
"group": "leetcode@7"
383+
}
384+
],
385+
"lcpr.setBricksType_sub1": [
386+
{
387+
"command": "lcpr.setBricksType0",
388+
"group": "leetcode@1"
389+
},
390+
{
391+
"command": "lcpr.setBricksType6",
392+
"group": "leetcode@2"
393+
},
394+
{
395+
"command": "lcpr.setBricksType5",
396+
"group": "leetcode@3"
397+
},
398+
{
399+
"command": "lcpr.setBricksType4",
400+
"group": "leetcode@4"
401+
},
402+
{
403+
"command": "lcpr.setBricksType3",
404+
"group": "leetcode@5"
405+
},
406+
{
407+
"command": "lcpr.setBricksType2",
408+
"group": "leetcode@6"
409+
},
410+
{
411+
"command": "lcpr.setBricksType1",
412+
"group": "leetcode@7"
413+
}
319414
]
320415
},
321416
"submenus": [
322417
{
323-
"id": "leetcode.editorAction",
418+
"id": "lcpr.editorAction",
324419
"label": "LCPR菜单"
420+
},
421+
{
422+
"id": "lcpr.setBricksType_sub",
423+
"label": "设置砖头类型"
424+
},
425+
{
426+
"id": "lcpr.setBricksType_sub1",
427+
"label": "设置砖头类型"
325428
}
326429
],
327430
"configuration": [

src/controller/BricksViewController.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,12 @@ class BricksViewController implements Disposable {
5555
has_qid ? TreeItemCollapsibleState.Collapsed : TreeItemCollapsibleState.None
5656
)
5757
);
58-
59-
// baseNode.push(
60-
// new BricksNode(
61-
// Object.assign({}, defaultProblem, {
62-
// id: BricksNormalId.Today,
63-
// name: BricksNormalId.TodayDesc,
64-
// }),
65-
// false,
66-
// 0,
67-
// TreeItemCollapsibleState.Collapsed
68-
// )
69-
// );
70-
7158
return baseNode;
7259
}
60+
61+
public async setBricksType(node: BricksNode, type) {
62+
await bricksDataService.setBricksType(node, type);
63+
}
7364
public dispose(): void {}
7465
}
7566

src/dao/bricksDao.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,10 @@ class BricksDao {
119119
const value = all_bricks[qid];
120120
const submit_time = value.submit_time || [];
121121
const submit_size = submit_time.length;
122-
if (submit_size < 1 || submit_time[submit_size - 1] < this.getTimeByType(value.type, today_time)) {
123-
all_qid.push(qid);
122+
if (value.type > BricksType.TYPE_0) {
123+
if (submit_size < 1 || submit_time[submit_size - 1] < this.getTimeByType(value.type, today_time)) {
124+
all_qid.push(qid);
125+
}
124126
}
125127
}
126128
return all_qid;
@@ -148,6 +150,11 @@ class BricksDao {
148150
}
149151
await this.setInfoByQid(qid, temp_data);
150152
}
153+
public async setTypeByQid(qid: string, type) {
154+
let temp_data = await this.getInfoByQid(qid);
155+
temp_data.type = type;
156+
await this.setInfoByQid(qid, temp_data);
157+
}
151158
}
152159

153160
export const bricksDao: BricksDao = new BricksDao();

src/extension.ts

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { markdownService } from "./service/MarkdownService";
2424
import { mainContorller } from "./controller/MainController";
2525
import { loginContorller } from "./controller/LoginController";
2626
import { getLeetCodeEndpoint } from "./utils/ConfigUtils";
27-
import { OutPutType } from "./model/Model";
27+
import { BricksType, OutPutType } from "./model/Model";
2828
import { bricksDataService } from "./service/BricksDataService";
2929
import { bricksViewController } from "./controller/BricksViewController";
3030

@@ -75,7 +75,28 @@ export async function activate(context: ExtensionContext): Promise<void> {
7575
commands.registerCommand("lcpr.setDefaultLanguage", () => treeViewController.setDefaultLanguage()),
7676
commands.registerCommand("lcpr.addFavorite", (node: NodeModel) => treeViewController.addFavorite(node)),
7777
commands.registerCommand("lcpr.removeFavorite", (node: NodeModel) => treeViewController.removeFavorite(node)),
78-
commands.registerCommand("lcpr.problems.sort", () => treeViewController.switchSortingStrategy())
78+
commands.registerCommand("lcpr.problems.sort", () => treeViewController.switchSortingStrategy()),
79+
commands.registerCommand("lcpr.setBricksType0", (node: NodeModel) =>
80+
bricksViewController.setBricksType(node, BricksType.TYPE_0)
81+
),
82+
commands.registerCommand("lcpr.setBricksType1", (node: NodeModel) =>
83+
bricksViewController.setBricksType(node, BricksType.TYPE_1)
84+
),
85+
commands.registerCommand("lcpr.setBricksType2", (node: NodeModel) =>
86+
bricksViewController.setBricksType(node, BricksType.TYPE_2)
87+
),
88+
commands.registerCommand("lcpr.setBricksType3", (node: NodeModel) =>
89+
bricksViewController.setBricksType(node, BricksType.TYPE_3)
90+
),
91+
commands.registerCommand("lcpr.setBricksType4", (node: NodeModel) =>
92+
bricksViewController.setBricksType(node, BricksType.TYPE_4)
93+
),
94+
commands.registerCommand("lcpr.setBricksType5", (node: NodeModel) =>
95+
bricksViewController.setBricksType(node, BricksType.TYPE_5)
96+
),
97+
commands.registerCommand("lcpr.setBricksType6", (node: NodeModel) =>
98+
bricksViewController.setBricksType(node, BricksType.TYPE_6)
99+
)
79100
);
80101

81102
// 设置站点

src/service/BricksDataService.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,20 @@ export class BricksDataService implements TreeDataProvider<BricksNode> {
9696
}
9797
}
9898

99-
public checkSubmit(e: ISubmitEvent) {
99+
public async checkSubmit(e: ISubmitEvent) {
100100
if (e.sub_type == "submit" && e.accepted) {
101101
let qid: string = e.qid.toString();
102102
bricksDao.addSubmitTimeByQid(qid);
103+
await bricksDataService.refresh();
103104
}
104105
}
105106

107+
public async setBricksType(node: BricksNode, type) {
108+
let qid: string = node.id.toString();
109+
bricksDao.setTypeByQid(qid, type);
110+
await bricksDataService.refresh();
111+
}
112+
106113
private parseIconPathFromProblemState(element: BricksNode): string {
107114
switch (element.state) {
108115
default:

0 commit comments

Comments
 (0)