Skip to content

Commit

Permalink
3.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ccagml committed May 10, 2024
1 parent 440179e commit a451490
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 37 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# version 3.2.2

- 手气一下显示分数范围
- 工地过期上红色

# version 3.2.1

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

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": "3.2.1",
"version": "3.2.2",
"author": "ccagml",
"publisher": "ccagml",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion src/bricksData/BricksDataService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class BricksDataService implements TreeDataProvider<TreeNodeModel> {
collapsibleState: element.collapsibleState || TreeItemCollapsibleState.None,
iconPath: this.parseIconPathFromProblemState(element),
command: element.isProblem ? element.previewCommand : undefined,
resourceUri: element.uri,
resourceUri: element.TNMUri,
contextValue: element.viewItem,
};
return result;
Expand Down
14 changes: 8 additions & 6 deletions src/controller/TreeViewController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -616,8 +616,14 @@ class TreeViewController implements Disposable {
picks.push(pick_item);
}

const user_score = BABA.getProxy(BabaStr.StatusBarProxy).getUserContestScore() || 0;
let min_score: number = getPickOneByRankRangeMin();
let max_score: number = getPickOneByRankRangeMax();
const need_min = user_score + min_score;
const need_max = user_score + max_score;

const choice: Array<IQuickItemEx<string>> | undefined = await window.showQuickPick(picks, {
title: "指定Tag类型",
title: user_score > 0 ? `手气一下,score:[${Math.ceil(need_min)} - ${Math.floor(need_max)}]` : "手气一下",
matchOnDescription: false,
matchOnDetail: false,
placeHolder: "指定Tag类型",
Expand All @@ -636,13 +642,9 @@ class TreeViewController implements Disposable {
const problems: TreeNodeModel[] = await BABA.getProxy(BabaStr.QuestionDataProxy).getfidMapQuestionData();
let randomProblem: TreeNodeModel;

const user_score = BABA.getProxy(BabaStr.StatusBarProxy).getUserContestScore();

if (user_score > 0) {
let min_score: number = getPickOneByRankRangeMin();
let max_score: number = getPickOneByRankRangeMax();
let temp_problems: TreeNodeModel[] = [];
const need_min = user_score + min_score;
const need_max = user_score + max_score;
problems.forEach((element) => {
if (BABA.getProxy(BabaStr.RankScoreDataProxy).getDataByFid(element.id)?.Rating) {
if (
Expand Down
67 changes: 42 additions & 25 deletions src/model/TreeNodeModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,32 @@ export enum TreeNodeType {

}


export function is_problem_by_nodeType(nt) {
let nodeType = Number(nt)
return (
nodeType == TreeNodeType.Tree_search_score_leaf ||
nodeType == TreeNodeType.Tree_search_contest_leaf ||
nodeType == TreeNodeType.Tree_day_leaf ||
nodeType == TreeNodeType.Tree_All_leaf ||
nodeType == TreeNodeType.Tree_difficulty_easy_leaf ||
nodeType == TreeNodeType.Tree_difficulty_mid_leaf ||
nodeType == TreeNodeType.Tree_difficulty_hard_leaf ||
nodeType == TreeNodeType.Tree_tag_fenlei_leaf ||
nodeType == TreeNodeType.Tree_favorite_leaf ||
nodeType == TreeNodeType.Tree_choice_fenlei_leaf ||
nodeType == TreeNodeType.Tree_score_fen_leaf ||
nodeType == TreeNodeType.Tree_contest_Q1_leaf ||
nodeType == TreeNodeType.Tree_contest_Q2_leaf ||
nodeType == TreeNodeType.Tree_contest_Q3_leaf ||
nodeType == TreeNodeType.Tree_contest_Q4_leaf ||
nodeType == TreeNodeType.Bricks_NeedReview_Day_leaf ||
nodeType == TreeNodeType.Bricks_TodaySubmit_leaf ||
nodeType == TreeNodeType.Bricks_Diy_leaf
);

}

export function CreateTreeNodeModel(data: ITreeDataNormal | ITreeDataSearch | ITreeDataDay | IQuestionData | IBricksToday, nodeType: TreeNodeType): TreeNodeModel {
return new TreeNodeModel(data, nodeType);
}
Expand Down Expand Up @@ -235,27 +261,7 @@ export class TreeNodeModel {
}

public get isProblem(): boolean {
return (
this.nodeType == TreeNodeType.Tree_search_score_leaf ||
this.nodeType == TreeNodeType.Tree_search_contest_leaf ||
this.nodeType == TreeNodeType.Tree_day_leaf ||
this.nodeType == TreeNodeType.Tree_All_leaf ||
this.nodeType == TreeNodeType.Tree_difficulty_easy_leaf ||
this.nodeType == TreeNodeType.Tree_difficulty_mid_leaf ||
this.nodeType == TreeNodeType.Tree_difficulty_hard_leaf ||
this.nodeType == TreeNodeType.Tree_tag_fenlei_leaf ||
this.nodeType == TreeNodeType.Tree_favorite_leaf ||
this.nodeType == TreeNodeType.Tree_choice_fenlei_leaf ||
this.nodeType == TreeNodeType.Tree_score_fen_leaf ||
this.nodeType == TreeNodeType.Tree_contest_Q1_leaf ||
this.nodeType == TreeNodeType.Tree_contest_Q2_leaf ||
this.nodeType == TreeNodeType.Tree_contest_Q3_leaf ||
this.nodeType == TreeNodeType.Tree_contest_Q4_leaf ||
this.nodeType == TreeNodeType.Bricks_NeedReview_Day_leaf ||
this.nodeType == TreeNodeType.Bricks_TodaySubmit_leaf ||
this.nodeType == TreeNodeType.Bricks_Diy_leaf

);
return is_problem_by_nodeType(this.nodeType)
}

public get viewItem(): string {
Expand Down Expand Up @@ -310,12 +316,23 @@ export class TreeNodeModel {
};
}

public get uri(): Uri {
public nodeUri_Query() {
if (this.isProblem) {
return `nodeType=${this.nodeType}&difficulty=${this.difficulty}&score=${this.score}`
}
return `nodeType=${this.nodeType}&groupTime=${this.groupTime || 0}`;
}

public get TNMUri(): Uri {

// scheme://authority/path?query#fragment

return Uri.from({
scheme: "leetcode",
authority: this.isProblem ? "problems" : "tree-node",
scheme: "lcpr",
authority: `${this.nodeType}`,
path: `/${this.id}`, // path must begin with slash /
query: `difficulty=${this.difficulty}&score=${this.score}&user_score=0`,
query: this.nodeUri_Query(),
fragment: this.viewItem
});
}
}
34 changes: 32 additions & 2 deletions src/treeColor/TreeColorModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import {
WorkspaceConfiguration,
} from "vscode";
import { BABA, BabaStr } from "../BABA";
import { is_problem_by_nodeType, TreeNodeType } from "../model/TreeNodeModel";
import { getDayNow, getYMD } from "../utils/SystemUtils";

export class TreeColor implements FileDecorationProvider {
private readonly ITEM_COLOR: { [key: string]: ThemeColor } = {
Expand All @@ -37,10 +39,38 @@ export class TreeColor implements FileDecorationProvider {
return;
}

if (uri.authority !== "problems") {
return;
// 不是插件的上色点
if (uri.scheme !== "lcpr") {
return
}
if (is_problem_by_nodeType(uri.authority)) {
return this.leafColor(uri);
}

// 看是不是日期节点
if (Number(uri.authority) == TreeNodeType.Bricks_NeedReview_Day) {
return this.NeedReview_Day_Color(uri)
}
return;
}
// 复习过期颜色
private NeedReview_Day_Color(uri: Uri): ProviderResult<FileDecoration> {
const params: URLSearchParams = new URLSearchParams(uri.query);
const groupTimeStr: string = params.get("groupTime") || "0";
const groupTime = Number(groupTimeStr)

const file_color: FileDecoration = {};
if (groupTime > 0) {
let cur_time = getDayNow()
if (cur_time > (groupTime + 86400)) {
file_color.color = this.ITEM_COLOR.red;
file_color.tooltip = `已过期${getYMD(groupTime)}`;
}
}
return file_color;
}
// 叶子的颜色既问题难度分的颜色
private leafColor(uri: Uri): ProviderResult<FileDecoration> {
const params: URLSearchParams = new URLSearchParams(uri.query);
// const difficulty: string = params.get("difficulty")!.toLowerCase();
const score: string = params.get("score") || "0";
Expand Down
2 changes: 1 addition & 1 deletion src/treeData/TreeDataService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class TreeDataService implements vscode.TreeDataProvider<TreeNodeModel> {
: vscode.TreeItemCollapsibleState.Collapsed,
iconPath: this.parseIconPathFromProblemState(element),
command: element.isProblem ? element.previewCommand : undefined,
resourceUri: element.uri,
resourceUri: element.TNMUri,
contextValue: element.viewItem,
};
return result;
Expand Down

0 comments on commit a451490

Please sign in to comment.