Skip to content

Commit e3ed624

Browse files
authored
Merge pull request #325 from ccagml/main
3.2.2
2 parents c5c64b6 + 6698512 commit e3ed624

File tree

7 files changed

+91
-37
lines changed

7 files changed

+91
-37
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
# version 3.2.2
2+
3+
- 手气一下显示分数范围
4+
- 工地过期上红色
5+
16
# version 3.2.1
27

3-
- 搬砖工地修改题目AC后在对应 1,4,7,14,28,60 天数后需要复习
8+
- 搬砖工地修改题目 AC 后在对应 1,4,7,14,28,60 天数后需要复习
49
- 通过配置 bricksReviewDay 可以设置需要复习的天数
510
- 一些按钮选项是否显示相关判断的上下文修改
611

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vscode-leetcode-problem-rating",
33
"displayName": "LeetCode",
44
"description": "%main.description%",
5-
"version": "3.2.1",
5+
"version": "3.2.2",
66
"author": "ccagml",
77
"publisher": "ccagml",
88
"license": "MIT",

src/bricksData/BricksDataService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export class BricksDataService implements TreeDataProvider<TreeNodeModel> {
5252
collapsibleState: element.collapsibleState || TreeItemCollapsibleState.None,
5353
iconPath: this.parseIconPathFromProblemState(element),
5454
command: element.isProblem ? element.previewCommand : undefined,
55-
resourceUri: element.uri,
55+
resourceUri: element.TNMUri,
5656
contextValue: element.viewItem,
5757
};
5858
return result;

src/controller/TreeViewController.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -616,8 +616,14 @@ class TreeViewController implements Disposable {
616616
picks.push(pick_item);
617617
}
618618

619+
const user_score = BABA.getProxy(BabaStr.StatusBarProxy).getUserContestScore() || 0;
620+
let min_score: number = getPickOneByRankRangeMin();
621+
let max_score: number = getPickOneByRankRangeMax();
622+
const need_min = user_score + min_score;
623+
const need_max = user_score + max_score;
624+
619625
const choice: Array<IQuickItemEx<string>> | undefined = await window.showQuickPick(picks, {
620-
title: "指定Tag类型",
626+
title: user_score > 0 ? `手气一下,score:[${Math.ceil(need_min)} - ${Math.floor(need_max)}]` : "手气一下",
621627
matchOnDescription: false,
622628
matchOnDetail: false,
623629
placeHolder: "指定Tag类型",
@@ -636,13 +642,9 @@ class TreeViewController implements Disposable {
636642
const problems: TreeNodeModel[] = await BABA.getProxy(BabaStr.QuestionDataProxy).getfidMapQuestionData();
637643
let randomProblem: TreeNodeModel;
638644

639-
const user_score = BABA.getProxy(BabaStr.StatusBarProxy).getUserContestScore();
645+
640646
if (user_score > 0) {
641-
let min_score: number = getPickOneByRankRangeMin();
642-
let max_score: number = getPickOneByRankRangeMax();
643647
let temp_problems: TreeNodeModel[] = [];
644-
const need_min = user_score + min_score;
645-
const need_max = user_score + max_score;
646648
problems.forEach((element) => {
647649
if (BABA.getProxy(BabaStr.RankScoreDataProxy).getDataByFid(element.id)?.Rating) {
648650
if (

src/model/TreeNodeModel.ts

Lines changed: 42 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,32 @@ export enum TreeNodeType {
146146

147147
}
148148

149+
150+
export function is_problem_by_nodeType(nt) {
151+
let nodeType = Number(nt)
152+
return (
153+
nodeType == TreeNodeType.Tree_search_score_leaf ||
154+
nodeType == TreeNodeType.Tree_search_contest_leaf ||
155+
nodeType == TreeNodeType.Tree_day_leaf ||
156+
nodeType == TreeNodeType.Tree_All_leaf ||
157+
nodeType == TreeNodeType.Tree_difficulty_easy_leaf ||
158+
nodeType == TreeNodeType.Tree_difficulty_mid_leaf ||
159+
nodeType == TreeNodeType.Tree_difficulty_hard_leaf ||
160+
nodeType == TreeNodeType.Tree_tag_fenlei_leaf ||
161+
nodeType == TreeNodeType.Tree_favorite_leaf ||
162+
nodeType == TreeNodeType.Tree_choice_fenlei_leaf ||
163+
nodeType == TreeNodeType.Tree_score_fen_leaf ||
164+
nodeType == TreeNodeType.Tree_contest_Q1_leaf ||
165+
nodeType == TreeNodeType.Tree_contest_Q2_leaf ||
166+
nodeType == TreeNodeType.Tree_contest_Q3_leaf ||
167+
nodeType == TreeNodeType.Tree_contest_Q4_leaf ||
168+
nodeType == TreeNodeType.Bricks_NeedReview_Day_leaf ||
169+
nodeType == TreeNodeType.Bricks_TodaySubmit_leaf ||
170+
nodeType == TreeNodeType.Bricks_Diy_leaf
171+
);
172+
173+
}
174+
149175
export function CreateTreeNodeModel(data: ITreeDataNormal | ITreeDataSearch | ITreeDataDay | IQuestionData | IBricksToday, nodeType: TreeNodeType): TreeNodeModel {
150176
return new TreeNodeModel(data, nodeType);
151177
}
@@ -235,27 +261,7 @@ export class TreeNodeModel {
235261
}
236262

237263
public get isProblem(): boolean {
238-
return (
239-
this.nodeType == TreeNodeType.Tree_search_score_leaf ||
240-
this.nodeType == TreeNodeType.Tree_search_contest_leaf ||
241-
this.nodeType == TreeNodeType.Tree_day_leaf ||
242-
this.nodeType == TreeNodeType.Tree_All_leaf ||
243-
this.nodeType == TreeNodeType.Tree_difficulty_easy_leaf ||
244-
this.nodeType == TreeNodeType.Tree_difficulty_mid_leaf ||
245-
this.nodeType == TreeNodeType.Tree_difficulty_hard_leaf ||
246-
this.nodeType == TreeNodeType.Tree_tag_fenlei_leaf ||
247-
this.nodeType == TreeNodeType.Tree_favorite_leaf ||
248-
this.nodeType == TreeNodeType.Tree_choice_fenlei_leaf ||
249-
this.nodeType == TreeNodeType.Tree_score_fen_leaf ||
250-
this.nodeType == TreeNodeType.Tree_contest_Q1_leaf ||
251-
this.nodeType == TreeNodeType.Tree_contest_Q2_leaf ||
252-
this.nodeType == TreeNodeType.Tree_contest_Q3_leaf ||
253-
this.nodeType == TreeNodeType.Tree_contest_Q4_leaf ||
254-
this.nodeType == TreeNodeType.Bricks_NeedReview_Day_leaf ||
255-
this.nodeType == TreeNodeType.Bricks_TodaySubmit_leaf ||
256-
this.nodeType == TreeNodeType.Bricks_Diy_leaf
257-
258-
);
264+
return is_problem_by_nodeType(this.nodeType)
259265
}
260266

261267
public get viewItem(): string {
@@ -310,12 +316,23 @@ export class TreeNodeModel {
310316
};
311317
}
312318

313-
public get uri(): Uri {
319+
public nodeUri_Query() {
320+
if (this.isProblem) {
321+
return `nodeType=${this.nodeType}&difficulty=${this.difficulty}&score=${this.score}`
322+
}
323+
return `nodeType=${this.nodeType}&groupTime=${this.groupTime || 0}`;
324+
}
325+
326+
public get TNMUri(): Uri {
327+
328+
// scheme://authority/path?query#fragment
329+
314330
return Uri.from({
315-
scheme: "leetcode",
316-
authority: this.isProblem ? "problems" : "tree-node",
331+
scheme: "lcpr",
332+
authority: `${this.nodeType}`,
317333
path: `/${this.id}`, // path must begin with slash /
318-
query: `difficulty=${this.difficulty}&score=${this.score}&user_score=0`,
334+
query: this.nodeUri_Query(),
335+
fragment: this.viewItem
319336
});
320337
}
321338
}

src/treeColor/TreeColorModule.ts

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import {
1818
WorkspaceConfiguration,
1919
} from "vscode";
2020
import { BABA, BabaStr } from "../BABA";
21+
import { is_problem_by_nodeType, TreeNodeType } from "../model/TreeNodeModel";
22+
import { getDayNow, getYMD } from "../utils/SystemUtils";
2123

2224
export class TreeColor implements FileDecorationProvider {
2325
private readonly ITEM_COLOR: { [key: string]: ThemeColor } = {
@@ -37,10 +39,38 @@ export class TreeColor implements FileDecorationProvider {
3739
return;
3840
}
3941

40-
if (uri.authority !== "problems") {
41-
return;
42+
// 不是插件的上色点
43+
if (uri.scheme !== "lcpr") {
44+
return
45+
}
46+
if (is_problem_by_nodeType(uri.authority)) {
47+
return this.leafColor(uri);
48+
}
49+
50+
// 看是不是日期节点
51+
if (Number(uri.authority) == TreeNodeType.Bricks_NeedReview_Day) {
52+
return this.NeedReview_Day_Color(uri)
4253
}
54+
return;
55+
}
56+
// 复习过期颜色
57+
private NeedReview_Day_Color(uri: Uri): ProviderResult<FileDecoration> {
58+
const params: URLSearchParams = new URLSearchParams(uri.query);
59+
const groupTimeStr: string = params.get("groupTime") || "0";
60+
const groupTime = Number(groupTimeStr)
4361

62+
const file_color: FileDecoration = {};
63+
if (groupTime > 0) {
64+
let cur_time = getDayNow()
65+
if (cur_time > (groupTime + 86400)) {
66+
file_color.color = this.ITEM_COLOR.red;
67+
file_color.tooltip = `已过期${getYMD(groupTime)}`;
68+
}
69+
}
70+
return file_color;
71+
}
72+
// 叶子的颜色既问题难度分的颜色
73+
private leafColor(uri: Uri): ProviderResult<FileDecoration> {
4474
const params: URLSearchParams = new URLSearchParams(uri.query);
4575
// const difficulty: string = params.get("difficulty")!.toLowerCase();
4676
const score: string = params.get("score") || "0";

src/treeData/TreeDataService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export class TreeDataService implements vscode.TreeDataProvider<TreeNodeModel> {
7676
: vscode.TreeItemCollapsibleState.Collapsed,
7777
iconPath: this.parseIconPathFromProblemState(element),
7878
command: element.isProblem ? element.previewCommand : undefined,
79-
resourceUri: element.uri,
79+
resourceUri: element.TNMUri,
8080
contextValue: element.viewItem,
8181
};
8282
return result;

0 commit comments

Comments
 (0)