From f540a12b47bfed9f5bc04d9cffbbf0a2ae7e498f Mon Sep 17 00:00:00 2001 From: ccagml Date: Thu, 2 May 2024 10:14:17 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=A4=8D=E4=B9=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 69 +++++-- package.nls.json | 17 +- package.nls.zh-cn.json | 23 ++- src/bricksData/BricksDataService.ts | 50 +++-- src/controller/BricksViewController.ts | 134 +++++++----- src/controller/TreeViewController.ts | 270 ++++++++++++------------- src/dao/bricksDao.ts | 195 +++++++++++------- src/model/ConstDefind.ts | 33 +-- src/model/TreeNodeModel.ts | 263 +++++++++--------------- src/questionData/QuestionDataModule.ts | 4 +- src/remark/RemarkServiceModule.ts | 2 +- src/treeData/TreeDataService.ts | 85 ++++---- src/utils/ConfigUtils.ts | 7 + 13 files changed, 597 insertions(+), 555 deletions(-) diff --git a/package.json b/package.json index 1649370..e55c2d8 100644 --- a/package.json +++ b/package.json @@ -129,11 +129,6 @@ "title": "%main.contributes.commands.lcpr.setBricksType6.title%", "category": "LeetCode" }, - { - "command": "lcpr.setBricksType7", - "title": "%main.contributes.commands.lcpr.setBricksType7.title%", - "category": "LeetCode" - }, { "command": "lcpr.searchProblem", "title": "%main.contributes.commands.lcpr.searchProblem.title%", @@ -258,6 +253,16 @@ "command": "lcpr.removeBricksHave", "title": "%main.contributes.commands.lcpr.removeBricksHave.title%", "icon": "$(remove)" + }, + { + "command": "lcpr.removeBricksNeedReviewDay", + "title": "%main.contributes.commands.lcpr.removeBricksNeedReviewDay.title%", + "icon": "$(remove)" + }, + { + "command": "lcpr.removeBricksNeedReviewDayNode", + "title": "%main.contributes.commands.lcpr.removeBricksNeedReviewDayNode.title%", + "icon": "$(remove)" } ], "viewsContainers": { @@ -454,12 +459,12 @@ }, { "command": "lcpr.addQidToGroup", - "when": "view == BricksExplorer && viewItem != nodebricksdiy && viewItem != brickshave && viewItem != brickstoday && viewItem != bricksdiy", + "when": "view == BricksExplorer && viewItem != nodebricksdiy && viewItem != bricksneedredate && viewItem != bricksneedreview && viewItem != brickstodaysubmit && viewItem != bricksdiy", "group": "leetcode@5" }, { "command": "lcpr.removeBricksHave", - "when": "view == BricksExplorer && viewItem == brickshave", + "when": "view == BricksExplorer && viewItem == bricksneedreview", "group": "leetcode@5" }, { @@ -471,6 +476,16 @@ "command": "lcpr.removeBrickGroup", "when": "view == BricksExplorer && viewItem == bricksdiy", "group": "leetcode@1" + }, + { + "command": "lcpr.removeBricksNeedReviewDay", + "when": "view == BricksExplorer && viewItem == bricksneedredate", + "group": "leetcode@1" + }, + { + "command": "lcpr.removeBricksNeedReviewDayNode", + "when": "view == BricksExplorer && viewItem == bricksneedreview", + "group": "leetcode@1" } ], "explorer/context": [ @@ -514,27 +529,27 @@ "group": "leetcode@1" }, { - "command": "lcpr.setBricksType6", + "command": "lcpr.setBricksType1", "group": "leetcode@2" }, { - "command": "lcpr.setBricksType5", + "command": "lcpr.setBricksType2", "group": "leetcode@3" }, { - "command": "lcpr.setBricksType4", + "command": "lcpr.setBricksType3", "group": "leetcode@4" }, { - "command": "lcpr.setBricksType3", + "command": "lcpr.setBricksType4", "group": "leetcode@5" }, { - "command": "lcpr.setBricksType2", + "command": "lcpr.setBricksType5", "group": "leetcode@6" }, { - "command": "lcpr.setBricksType1", + "command": "lcpr.setBricksType6", "group": "leetcode@7" } ], @@ -544,27 +559,27 @@ "group": "leetcode@1" }, { - "command": "lcpr.setBricksType6", + "command": "lcpr.setBricksType1", "group": "leetcode@2" }, { - "command": "lcpr.setBricksType5", + "command": "lcpr.setBricksType2", "group": "leetcode@3" }, { - "command": "lcpr.setBricksType4", + "command": "lcpr.setBricksType3", "group": "leetcode@4" }, { - "command": "lcpr.setBricksType3", + "command": "lcpr.setBricksType4", "group": "leetcode@5" }, { - "command": "lcpr.setBricksType2", + "command": "lcpr.setBricksType5", "group": "leetcode@6" }, { - "command": "lcpr.setBricksType1", + "command": "lcpr.setBricksType6", "group": "leetcode@7" } ] @@ -1039,6 +1054,22 @@ "scope": "application", "description": "%main.contributes.configuration.properties.leetcode-problem-rating.enableTimerBar.description%" }, + "leetcode-problem-rating.editor.bricksReviewDay": { + "type": "array", + "default": [ + 1, + 4, + 7, + 14, + 28, + 60 + ], + "items": { + "type": "number" + }, + "scope": "application", + "description": "%main.contributes.configuration.properties.leetcode-problem-rating.editor.bricksNextDay.description%" + }, "leetcode-problem-rating.editor.shortcuts": { "type": "array", "default": [ diff --git a/package.nls.json b/package.nls.json index 4c1be8d..104d1b2 100644 --- a/package.nls.json +++ b/package.nls.json @@ -10,14 +10,13 @@ "main.contributes.commands.lcpr.deleteAllCache.title": "deleteAllCache", "main.contributes.commands.lcpr.showProblem.title": "showProblem", "main.contributes.commands.lcpr.previewProblem.title": "previewProblem", - "main.contributes.commands.lcpr.setBricksType0.title": "settings do not appear", - "main.contributes.commands.lcpr.setBricksType1.title": "Appears after 14 days", - "main.contributes.commands.lcpr.setBricksType2.title": "Appears after 7 days", - "main.contributes.commands.lcpr.setBricksType3.title": "Appears after 5 days", - "main.contributes.commands.lcpr.setBricksType4.title": "Appears after 3 days", - "main.contributes.commands.lcpr.setBricksType5.title": "Appears after 2 days", - "main.contributes.commands.lcpr.setBricksType6.title": "Appears after 1 days", - "main.contributes.commands.lcpr.setBricksType7.title": "Appears after 1 days", + "main.contributes.commands.lcpr.setBricksType0.title": "Appears after 1 days", + "main.contributes.commands.lcpr.setBricksType1.title": "Appears after 2 days", + "main.contributes.commands.lcpr.setBricksType2.title": "Appears after 4 days", + "main.contributes.commands.lcpr.setBricksType3.title": "Appears after 7 days", + "main.contributes.commands.lcpr.setBricksType4.title": "Appears after 14 days", + "main.contributes.commands.lcpr.setBricksType5.title": "Appears after 28 days", + "main.contributes.commands.lcpr.setBricksType6.title": "Appears after 60 days", "main.contributes.commands.lcpr.searchProblem.title": "Search Problem", "main.contributes.commands.lcpr.getHelp.title": "getHelp", "main.contributes.commands.lcpr.testSolution.title": "Test in LeetCode", @@ -37,6 +36,8 @@ "main.contributes.commands.lcpr.newBrickGroup.title": "new category", "main.contributes.commands.lcpr.addQidToGroup.title": "add to category", "main.contributes.commands.lcpr.removeBrickGroup.title": "delete category", + "main.contributes.commands.lcpr.removeBricksNeedReviewDay.title": "delete day", + "main.contributes.commands.lcpr.removeBricksNeedReviewDayNode.title": "delete node", "main.contributes.commands.lcpr.removeBricksHave.title": "remove bricks have", "main.contributes.commands.lcpr.removeQidFromGroup.title": "remove this", "main.contributes.commands.lcpr.includeTemplates.title": "insert template", diff --git a/package.nls.zh-cn.json b/package.nls.zh-cn.json index d55f444..5c01ca1 100644 --- a/package.nls.zh-cn.json +++ b/package.nls.zh-cn.json @@ -10,14 +10,13 @@ "main.contributes.commands.lcpr.deleteAllCache.title": "删除题目缓存", "main.contributes.commands.lcpr.showProblem.title": "做题", "main.contributes.commands.lcpr.previewProblem.title": "预览题目", - "main.contributes.commands.lcpr.setBricksType0.title": "设置不出现在工地", - "main.contributes.commands.lcpr.setBricksType1.title": "最后一次提交在14天前,出现在工地", - "main.contributes.commands.lcpr.setBricksType2.title": "最后一次提交在7天前,出现在工地", - "main.contributes.commands.lcpr.setBricksType3.title": "最后一次提交在5天前,出现在工地", - "main.contributes.commands.lcpr.setBricksType4.title": "最后一次提交在3天前,出现在工地", - "main.contributes.commands.lcpr.setBricksType5.title": "最后一次提交在2天前,出现在工地", - "main.contributes.commands.lcpr.setBricksType6.title": "最后一次提交在1天前,出现在工地", - "main.contributes.commands.lcpr.setBricksType7.title": "最后一次提交在1天前,出现在工地", + "main.contributes.commands.lcpr.setBricksType0.title": "1天后的砖", + "main.contributes.commands.lcpr.setBricksType1.title": "2天后的砖", + "main.contributes.commands.lcpr.setBricksType2.title": "4天后的砖", + "main.contributes.commands.lcpr.setBricksType3.title": "7天后的砖", + "main.contributes.commands.lcpr.setBricksType4.title": "14天后的砖", + "main.contributes.commands.lcpr.setBricksType5.title": "28天后的砖", + "main.contributes.commands.lcpr.setBricksType6.title": "60天后的砖", "main.contributes.commands.lcpr.searchProblem.title": "查找题目", "main.contributes.commands.lcpr.getHelp.title": "获取题解", "main.contributes.commands.lcpr.testSolution.title": "测试", @@ -37,7 +36,9 @@ "main.contributes.commands.lcpr.newBrickGroup.title": "新建一个自定义分类", "main.contributes.commands.lcpr.addQidToGroup.title": "添加题目到自定义分类", "main.contributes.commands.lcpr.removeBrickGroup.title": "移除这个自定义分类", - "main.contributes.commands.lcpr.removeBricksHave.title": "砖头太多搬不过来了,重置砖头", + "main.contributes.commands.lcpr.removeBricksNeedReviewDay.title": "移除这个日期", + "main.contributes.commands.lcpr.removeBricksNeedReviewDayNode.title": "移除这块砖", + "main.contributes.commands.lcpr.removeBricksHave.title": "清空所有砖头", "main.contributes.commands.lcpr.removeQidFromGroup.title": "从分类中移除这个题目", "main.contributes.commands.lcpr.includeTemplates.title": "插入头文件模板", "main.contributes.commands.lcpr.simpleDebug.title": "简单调试", @@ -45,8 +46,8 @@ "main.contributes.views.lcpr_bar.QuestionExplorer.name": "题目列表", "main.contributes.views.lcpr_bar.BricksExplorer.name": "搬砖工地", "main.contributes.submenus.lcpr.editorAction.label": "LCPR菜单", - "main.contributes.submenus.lcpr.setBricksType_sub.label": "设置砖头类型", - "main.contributes.submenus.lcpr.setBricksType_sub1.label": "设置砖头类型", + "main.contributes.submenus.lcpr.setBricksType_sub.label": "设置几天后搬", + "main.contributes.submenus.lcpr.setBricksType_sub1.label": "设置几天后搬", "main.contributes.configuration.title": "leetcode-problem-rating", "main.contributes.configuration.properties.leetcode-problem-rating.includeTemplates.description": "引入一些默认内容,防止VSCode都是波浪红线", "main.contributes.configuration.properties.leetcode-problem-rating.includeTemplatesAuto.description": "自动引入模板", diff --git a/src/bricksData/BricksDataService.ts b/src/bricksData/BricksDataService.ts index 44c36dd..69035e6 100644 --- a/src/bricksData/BricksDataService.ts +++ b/src/bricksData/BricksDataService.ts @@ -8,9 +8,9 @@ */ import { TreeDataProvider, EventEmitter, Event, TreeItem, TreeItemCollapsibleState } from "vscode"; -import { BricksNormalId, ISubmitEvent } from "../model/ConstDefind"; +import { BricksNormalId, BricksType, ISubmitEvent } from "../model/ConstDefind"; import { bricksViewController } from "../controller/BricksViewController"; -import { TreeNodeModel, TreeNodeType } from "../model/TreeNodeModel"; +import { CreateTreeNodeModel, TreeNodeModel, TreeNodeType } from "../model/TreeNodeModel"; import { bricksDao } from "../dao/bricksDao"; import { groupDao } from "../dao/groupDao"; import { BABA, BABAMediator, BABAProxy, BabaStr, BaseCC } from "../BABA"; @@ -33,7 +33,7 @@ export class BricksDataService implements TreeDataProvider { // 节点的内容 public getTreeItem(element: TreeNodeModel): TreeItem | Thenable { - if (element.id === "notSignIn") { + if (element.id === BricksNormalId.NotSignIn) { return { label: element.name, collapsibleState: element.collapsibleState, // 没有子节点 @@ -69,33 +69,31 @@ export class BricksDataService implements TreeDataProvider { let sbp = BABA.getProxy(BabaStr.StatusBarProxy); if (!sbp.getUser()) { return [ - new TreeNodeModel( - { - id: "notSignIn", - name: "工头说你不是我们工地的人", - collapsibleState: TreeItemCollapsibleState.None, - }, - TreeNodeType.BricksDataNormal - ), + CreateTreeNodeModel({ + id: BricksNormalId.NotSignIn, + name: "工头说你不是我们工地的人", + collapsibleState: TreeItemCollapsibleState.None, + }, + TreeNodeType.BricksNotSignIn) ]; } if (!element) { return await bricksViewController.getRootNodes(); } else { - switch (element.id) { - case BricksNormalId.Today: - return await bricksViewController.getTodayNodes(); - break; - case BricksNormalId.Have: - return await bricksViewController.getHaveNodes(); - break; - case BricksNormalId.DIY: - return await bricksViewController.getDiyNode(element); - break; - default: - return []; - break; + + if (element.nodeType == TreeNodeType.Bricks_TodaySubmit) { + return await bricksViewController.getTodayNodes(); + } + else if (element.nodeType == TreeNodeType.Bricks_NeedReview) { + return await bricksViewController.getNeedReviewDayNodes(); } + else if (element.nodeType == TreeNodeType.Bricks_Diy) { + return await bricksViewController.getDiyNode(element); + } + else if (element.nodeType == TreeNodeType.Bricks_NeedReview_Day) { + return await bricksViewController.getNeedReviewNodesByDay(element); + } + return []; } } @@ -107,9 +105,9 @@ export class BricksDataService implements TreeDataProvider { } } - public async setBricksType(node: TreeNodeModel, type) { + public async setBricksType(node: TreeNodeModel, type: BricksType) { let qid: string = node.qid.toString(); - bricksDao.setTypeByQid(qid, type); + await bricksDao.setReviewDayByQidAndType(qid, type); BABA.sendNotification(BabaStr.BricksData_setBricksTypeFinish); } diff --git a/src/controller/BricksViewController.ts b/src/controller/BricksViewController.ts index c2698d6..513d297 100644 --- a/src/controller/BricksViewController.ts +++ b/src/controller/BricksViewController.ts @@ -13,47 +13,71 @@ import { BABA, BabaStr } from "../BABA"; import { bricksDao } from "../dao/bricksDao"; import { groupDao } from "../dao/groupDao"; import { BricksNormalId, IQuickItemEx } from "../model/ConstDefind"; -import { TreeNodeModel, TreeNodeType } from "../model/TreeNodeModel"; +import { CreateTreeNodeModel, TreeNodeModel, TreeNodeType } from "../model/TreeNodeModel"; +import { getYMD } from "../utils/SystemUtils"; // 视图控制器 class BricksViewController implements Disposable { - // 需要的 - public async getHaveNodes() { - let all_qid: string[] = await bricksDao.getTodayBricks(); - let qid_tip = await bricksDao.getLastSubmitTimeToolTip(all_qid); - const baseNode: TreeNodeModel[] = []; - all_qid.forEach((qid) => { - let node = BABA.getProxy(BabaStr.QuestionDataProxy).getNodeByQid(qid); - if (node) { - let new_obj = new TreeNodeModel( - Object.assign({}, node.get_data(), { - collapsibleState: TreeItemCollapsibleState.None, - groupTime: 0, - toolTip: qid_tip.get(qid), - }), - TreeNodeType.BricksDataLeaf - ); - baseNode.push(new_obj); - } + + // 根据日期获取需要复习的点 + public async getNeedReviewNodesByDay(element: TreeNodeModel) { + let groupTime = element.groupTime + let all_node: TreeNodeModel[] = []; + if (groupTime != undefined) { + let all_qid: string[] = await bricksDao.getNeedReviewQidByReviewTime(groupTime); + const baseNode: TreeNodeModel[] = []; + all_qid.forEach((qid) => { + let node = BABA.getProxy(BabaStr.QuestionDataProxy).getNodeByQid(qid); + if (node) { + let new_obj = CreateTreeNodeModel( + Object.assign({}, node.get_data(), { + collapsibleState: TreeItemCollapsibleState.None, + groupTime: 0, + }), + TreeNodeType.Bricks_NeedReview_Day_leaf + ); + baseNode.push(new_obj); + } + }); + return baseNode; + } + + return all_node + } + + // 需要复习的日期节点 + public async getNeedReviewDayNodes() { + let all_review_day: number[] = await bricksDao.getNeedReviewDay(); + + let all_day_node: TreeNodeModel[] = []; + all_review_day.forEach((review_time) => { + let new_obj = CreateTreeNodeModel( + { + id: BricksNormalId.NeedReDate, + name: getYMD(review_time), + collapsibleState: TreeItemCollapsibleState.Collapsed, + groupTime: review_time, + }, + TreeNodeType.Bricks_NeedReview_Day + ); + all_day_node.push(new_obj); }); - return baseNode; + return all_day_node; } // 今天搬的 public async getTodayNodes() { - // 增加tooltip let all_qid: string[] = await bricksDao.getTodayBricksSubmit(); - let qid_tip = await bricksDao.getTodayBricksSubmitToolTip(all_qid); + const baseNode: TreeNodeModel[] = []; all_qid.forEach((qid) => { let node = BABA.getProxy(BabaStr.QuestionDataProxy).getNodeByQid(qid); if (node) { - let new_obj = new TreeNodeModel( + let new_obj = CreateTreeNodeModel( Object.assign({}, node.get_data(), { collapsibleState: TreeItemCollapsibleState.None, groupTime: 0, - toolTip: qid_tip.get(qid), }), - TreeNodeType.BricksDataLeaf + TreeNodeType.Bricks_TodaySubmit_leaf ); baseNode.push(new_obj); } @@ -71,12 +95,12 @@ class BricksViewController implements Disposable { all_qid.forEach((qid) => { let node = BABA.getProxy(BabaStr.QuestionDataProxy).getNodeByQid(qid); if (node) { - let new_obj = new TreeNodeModel( + let new_obj = CreateTreeNodeModel( Object.assign({}, node.get_data(), { collapsibleState: TreeItemCollapsibleState.None, groupTime: time, }), - TreeNodeType.BricksDataLeaf + TreeNodeType.Bricks_Diy_leaf ); baseNode.push(new_obj); } @@ -85,23 +109,38 @@ class BricksViewController implements Disposable { } public async getRootNodes(): Promise { - let all_qid: string[] = await bricksDao.getTodayBricks(); + let all_review_day: number[] = await bricksDao.getNeedReviewDay(); let all_submit_qid: string[] = await bricksDao.getTodayBricksSubmit(); - let has_qid = all_qid.length > 0; + let has_qid = all_review_day.length > 0; let has_submit = all_submit_qid.length > 0; const baseNode: TreeNodeModel[] = []; - // 监工 - baseNode.push( - new TreeNodeModel( - { - id: has_qid ? BricksNormalId.Have : BricksNormalId.No, - name: has_qid ? BricksNormalId.HaveDesc : BricksNormalId.NoDesc, - collapsibleState: has_qid ? TreeItemCollapsibleState.Collapsed : TreeItemCollapsibleState.None, - }, - TreeNodeType.BricksDataNormal - ) - ); + + if (has_qid) { + // 有要复习 + baseNode.push( + CreateTreeNodeModel( + { + id: BricksNormalId.NeedReview, + name: BricksNormalId.NeedReviewDesc, + collapsibleState: TreeItemCollapsibleState.Collapsed, + }, + TreeNodeType.Bricks_NeedReview + ) + ); + } else { + // 没有要复习 + baseNode.push( + CreateTreeNodeModel( + { + id: BricksNormalId.NoReview, + name: BricksNormalId.NoReviewDesc, + collapsibleState: TreeItemCollapsibleState.None, + }, + TreeNodeType.Bricks_NoReview + ) + ); + } // 今日提交 if (has_submit) { @@ -114,15 +153,15 @@ class BricksViewController implements Disposable { }); baseNode.push( - new TreeNodeModel( + CreateTreeNodeModel( { - id: BricksNormalId.Today, + id: BricksNormalId.TodaySubmit, name: `今天搬了${all_submit_qid.length}块砖,赚了${temp_score}分` + (all_submit_qid.length > 3 ? ",又是上分的一天~" : ",别吹牛了,赶紧干活啊!!!"), collapsibleState: TreeItemCollapsibleState.Collapsed, }, - TreeNodeType.BricksDataNormal + TreeNodeType.Bricks_TodaySubmit ) ); } @@ -130,7 +169,7 @@ class BricksViewController implements Disposable { let all_group = await groupDao.getAllGroup(); all_group.forEach((element) => { baseNode.push( - new TreeNodeModel( + CreateTreeNodeModel( { id: BricksNormalId.DIY, name: element.name, @@ -138,7 +177,7 @@ class BricksViewController implements Disposable { groupTime: element.time, }, - TreeNodeType.BricksDataNormal + TreeNodeType.Bricks_Diy ) ); }); @@ -149,7 +188,7 @@ class BricksViewController implements Disposable { public async setBricksType(node: TreeNodeModel, type) { await BABA.getProxy(BabaStr.BricksDataProxy).setBricksType(node, type); } - public dispose(): void {} + public dispose(): void { } public async newBrickGroup() { let name = await window.showInputBox({ @@ -206,8 +245,7 @@ class BricksViewController implements Disposable { } public async removeBricksHave() { - let all_qid: string[] = await bricksDao.getTodayBricks(); - await bricksDao.addQidSubmitTime(all_qid); + await bricksDao.removeReviewDay(); BABA.sendNotification(BabaStr.BricksData_removeBricksHaveFinish); } } diff --git a/src/controller/TreeViewController.ts b/src/controller/TreeViewController.ts index de9f3ee..ff2c4a4 100644 --- a/src/controller/TreeViewController.ts +++ b/src/controller/TreeViewController.ts @@ -46,7 +46,7 @@ import { getBelongingWorkspaceFolderUri, selectWorkspaceFolder, } from "../utils/ConfigUtils"; -import { ITodayDataResponse, TreeNodeModel, TreeNodeType } from "../model/TreeNodeModel"; +import { CreateTreeNodeModel, ITodayDataResponse, TreeNodeModel, TreeNodeType } from "../model/TreeNodeModel"; import { ISearchSet } from "../model/ConstDefind"; import { ShowMessage, promptForSignIn, promptHintMessage } from "../utils/OutputUtils"; @@ -974,61 +974,61 @@ class TreeViewController implements Disposable { public getRootNodes(): TreeNodeModel[] { const baseNode: TreeNodeModel[] = [ - new TreeNodeModel( + CreateTreeNodeModel( { id: Category.All, name: Category.All, rootNodeSortId: RootNodeSort.All, }, - TreeNodeType.TreeDataNormal + TreeNodeType.Tree_All ), - new TreeNodeModel( + CreateTreeNodeModel( { id: Category.Difficulty, name: Category.Difficulty, rootNodeSortId: RootNodeSort.Difficulty, }, - TreeNodeType.TreeDataNormal + TreeNodeType.Tree_difficulty ), - new TreeNodeModel( + CreateTreeNodeModel( { id: Category.Tag, name: Category.Tag, rootNodeSortId: RootNodeSort.Tag, }, - TreeNodeType.TreeDataNormal + TreeNodeType.Tree_tag ), - new TreeNodeModel( + CreateTreeNodeModel( { id: Category.Favorite, name: Category.Favorite, rootNodeSortId: RootNodeSort.Favorite, }, - TreeNodeType.TreeDataNormal + TreeNodeType.Tree_favorite ), - new TreeNodeModel( + CreateTreeNodeModel( { id: Category.Score, name: Category.Score, rootNodeSortId: RootNodeSort.Score, }, - TreeNodeType.TreeDataNormal + TreeNodeType.Tree_score ), - new TreeNodeModel( + CreateTreeNodeModel( { id: Category.Choice, name: Category.Choice, rootNodeSortId: RootNodeSort.Choice, }, - TreeNodeType.TreeDataNormal + TreeNodeType.Tree_choice ), - new TreeNodeModel( + CreateTreeNodeModel( { id: Category.Contest, name: Category.Contest, - rootNodeSortId: RootNodeSort.Context, + rootNodeSortId: RootNodeSort.Contest, }, - TreeNodeType.TreeDataNormal + TreeNodeType.Tree_contest ), ]; @@ -1038,23 +1038,22 @@ class TreeViewController implements Disposable { today_info.forEach((element: ITodayDataResponse) => { const curDate = new Date(element.time * 1000); baseNode.push( - new TreeNodeModel( + CreateTreeNodeModel( { id: element.fid, - name: `[${curDate.getFullYear()}-${curDate.getMonth() + 1}-${curDate.getDate()}]${ - SearchSetTypeName[SearchSetType.Day] - }`, + name: `[${curDate.getFullYear()}-${curDate.getMonth() + 1}-${curDate.getDate()}]${SearchSetTypeName[SearchSetType.Day] + }`, isSearchResult: true, rootNodeSortId: RootNodeSort.Day, }, - TreeNodeType.TreeDataDay + TreeNodeType.Tree_day ) ); }); this.searchSet.forEach((element) => { baseNode.push( - new TreeNodeModel( + CreateTreeNodeModel( { id: element.type, name: SearchSetTypeName[element.type] + element.value, @@ -1062,7 +1061,7 @@ class TreeViewController implements Disposable { isSearchResult: true, rootNodeSortId: RootNodeSort[element.type], }, - TreeNodeType.TreeDataSearch + TreeNodeType.Tree_search ) ); }); @@ -1096,7 +1095,7 @@ class TreeViewController implements Disposable { return; } if (rank_a <= Number(element.score) && Number(element.score) <= rank_b) { - sorceNode.push(new TreeNodeModel(element.get_data(), TreeNodeType.TreeDataSearchLeaf)); + sorceNode.push(CreateTreeNodeModel(element.get_data(), TreeNodeType.Tree_search_score_leaf)); } }); } @@ -1113,7 +1112,7 @@ class TreeViewController implements Disposable { return true; } - public getContextNodes(rank_range: string): TreeNodeModel[] { + public getContestNodes(rank_range: string): TreeNodeModel[] { const sorceNode: TreeNodeModel[] = []; const rank_r: Array = rank_range.split("-"); let rank_a = Number(rank_r[0]); @@ -1126,9 +1125,9 @@ class TreeViewController implements Disposable { const slu_arr: Array = slu.split("-"); const slu_id = Number(slu_arr[slu_arr.length - 1]); if (rank_b > 0 && rank_a <= slu_id && slu_id <= rank_b) { - sorceNode.push(new TreeNodeModel(element.get_data(), TreeNodeType.TreeDataSearchLeaf)); + sorceNode.push(CreateTreeNodeModel(element.get_data(), TreeNodeType.Tree_search_contest_leaf)); } else if (rank_a == slu_id) { - sorceNode.push(new TreeNodeModel(element.get_data(), TreeNodeType.TreeDataSearchLeaf)); + sorceNode.push(CreateTreeNodeModel(element.get_data(), TreeNodeType.Tree_search_contest_leaf)); } }); } @@ -1141,7 +1140,7 @@ class TreeViewController implements Disposable { let DayQuestionNode: TreeNodeModel | undefined = BABA.getProxy(BabaStr.QuestionDataProxy).getNodeById(fid); if (DayQuestionNode != undefined) { - sorceNode.push(new TreeNodeModel(DayQuestionNode.get_data(), TreeNodeType.TreeDataDayLeaf)); + sorceNode.push(CreateTreeNodeModel(DayQuestionNode.get_data(), TreeNodeType.Tree_day_leaf)); } return sortNodeList(sorceNode); @@ -1154,52 +1153,44 @@ class TreeViewController implements Disposable { .getfidMapQuestionData() .forEach((node) => { if (this.canShow(node)) { - res.push(new TreeNodeModel(node.get_data(), TreeNodeType.TreeDataLeaf)); + res.push(CreateTreeNodeModel(node.get_data(), TreeNodeType.Tree_All_leaf)); } }); return sortNodeList(res); } - public getAllDifficultyNodes(): TreeNodeModel[] { + public getDifficultyChild(): TreeNodeModel[] { const res: TreeNodeModel[] = []; res.push( - new TreeNodeModel( + CreateTreeNodeModel( { - id: `${Category.Difficulty}.Easy`, + id: `Easy`, name: "Easy", rootNodeSortId: RootNodeSort.DIFEASY, }, - TreeNodeType.TreeDataNormal + TreeNodeType.Tree_difficulty_easy ), - new TreeNodeModel( + CreateTreeNodeModel( { - id: `${Category.Difficulty}.Medium`, + id: `Medium`, name: "Medium", rootNodeSortId: RootNodeSort.DIFMID, }, - TreeNodeType.TreeDataNormal + TreeNodeType.Tree_difficulty_mid ), - new TreeNodeModel( + CreateTreeNodeModel( { - id: `${Category.Difficulty}.Hard`, + id: `Hard`, name: "Hard", rootNodeSortId: RootNodeSort.DIFHARD, }, - TreeNodeType.TreeDataNormal + TreeNodeType.Tree_difficulty_hard ) ); - res.sort(function (a: TreeNodeModel, b: TreeNodeModel): number { - if (a.rootNodeSortId < b.rootNodeSortId) { - return -1; - } else if (a.rootNodeSortId > b.rootNodeSortId) { - return 1; - } - return 0; - }); return res; } - public getAllScoreNodes(): TreeNodeModel[] { + public getScoreChild(): TreeNodeModel[] { const user_score = BABA.getProxy(BabaStr.StatusBarProxy).getUserContestScore(); const res: TreeNodeModel[] = []; const score_array: Array = [ @@ -1227,18 +1218,18 @@ class TreeViewController implements Disposable { "1200", "1100", ]; - score_array.forEach((element) => { - const temp_num = Number(element); + score_array.forEach((score_str) => { + const temp_num = Number(score_str); const diff = Math.abs(temp_num - user_score); if (diff <= 200) { res.push( - new TreeNodeModel( + CreateTreeNodeModel( { - id: `${Category.Score}.${element}`, - name: `${element}`, + id: `${score_str}`, + name: `${score_str}`, rootNodeSortId: temp_num, }, - TreeNodeType.TreeDataNormal + TreeNodeType.Tree_score_fen ) ); } @@ -1246,93 +1237,74 @@ class TreeViewController implements Disposable { return res; } - public getAllContestNodes(): TreeNodeModel[] { + public getContestChild(): TreeNodeModel[] { const res: TreeNodeModel[] = []; res.push( - new TreeNodeModel( + CreateTreeNodeModel( { - id: `${Category.Contest}.Q1`, + id: `Q1`, name: "Q1", rootNodeSortId: 1, }, - TreeNodeType.TreeDataNormal + TreeNodeType.Tree_contest_Q1 ), - new TreeNodeModel( + CreateTreeNodeModel( { - id: `${Category.Contest}.Q2`, + id: `Q2`, name: "Q2", rootNodeSortId: 2, }, - TreeNodeType.TreeDataNormal + TreeNodeType.Tree_contest_Q2 ), - new TreeNodeModel( + CreateTreeNodeModel( { - id: `${Category.Contest}.Q3`, + id: `Q3`, name: "Q3", rootNodeSortId: 3, }, - TreeNodeType.TreeDataNormal + TreeNodeType.Tree_contest_Q3 ), - new TreeNodeModel( + CreateTreeNodeModel( { - id: `${Category.Contest}.Q4`, + id: `Q4`, name: "Q4", rootNodeSortId: 4, }, - TreeNodeType.TreeDataNormal + TreeNodeType.Tree_contest_Q4 ) ); - this.sortSubCategoryNodes(res, Category.Contest); return res; } - public getAllChoiceNodes(): TreeNodeModel[] { + public getChoiceChild(): TreeNodeModel[] { const res: TreeNodeModel[] = []; const all_choice = BABA.getProxy(BabaStr.TreeDataProxy).getChoiceData(); all_choice.forEach((element) => { res.push( - new TreeNodeModel( + CreateTreeNodeModel( { - id: `${Category.Choice}.${element.id}`, + id: `${element.id}`, name: `${element.name}`, rootNodeSortId: 4, }, - TreeNodeType.TreeDataNormal + TreeNodeType.Tree_choice_fenlei ) ); }); return res; } - public getAllCompanyNodes(): TreeNodeModel[] { - const res: TreeNodeModel[] = []; - for (const company of BABA.getProxy(BabaStr.QuestionDataProxy).getCompanySet().values()) { - res.push( - new TreeNodeModel( - { - id: `${Category.Company}.${company}`, - name: lodash.startCase(company), - rootNodeSortId: 4, - }, - TreeNodeType.TreeDataNormal - ) - ); - } - this.sortSubCategoryNodes(res, Category.Company); - return res; - } - - public getAllTagNodes(): TreeNodeModel[] { + public getTagChild(): TreeNodeModel[] { const res: TreeNodeModel[] = []; for (const tag of BABA.getProxy(BabaStr.QuestionDataProxy).getTagSet().values()) { res.push( - new TreeNodeModel( + CreateTreeNodeModel( { - id: `${Category.Tag}.${tag}`, + id: `${tag}`, name: lodash.startCase(tag), rootNodeSortId: 4, }, - TreeNodeType.TreeDataNormal + TreeNodeType.Tree_tag_fenlei ) ); } @@ -1346,22 +1318,20 @@ class TreeViewController implements Disposable { .getfidMapQuestionData() .forEach((node) => { if (this.canShow(node) && node.isFavorite) { - res.push(new TreeNodeModel(node.get_data(), TreeNodeType.TreeDataLeaf)); + res.push(CreateTreeNodeModel(node.get_data(), TreeNodeType.Tree_favorite_leaf)); } }); return sortNodeList(res); } - public getChildrenNodesById(id: string): TreeNodeModel[] { - // The sub-category node's id is named as {Category.SubName} - const metaInfo: string[] = id.split("."); + // 第二层取第三层的叶子 + public getChildrenSon(TreeChildNode: TreeNodeModel): TreeNodeModel[] { const res: TreeNodeModel[] = []; - const choiceQuestionId: Map = new Map(); - if (metaInfo[0] == Category.Choice) { + if (TreeChildNode.nodeType == TreeNodeType.Tree_choice_fenlei) { const all_choice = BABA.getProxy(BabaStr.TreeDataProxy).getChoiceData(); all_choice.forEach((element) => { - if (element.id == metaInfo[1]) { + if (element.id == TreeChildNode.id) { element.questions.forEach((kk) => { choiceQuestionId[kk] = true; }); @@ -1374,44 +1344,71 @@ class TreeViewController implements Disposable { if (!this.canShow(node)) { continue; } - let new_node = new TreeNodeModel(node.get_data(), TreeNodeType.TreeDataLeaf); + if (TreeChildNode.nodeType == TreeNodeType.Tree_difficulty_easy) { + if (node.get_data().difficulty === TreeChildNode.id) { + res.push(CreateTreeNodeModel(node.get_data(), TreeNodeType.Tree_difficulty_easy_leaf)); - switch (metaInfo[0]) { - case Category.Company: - if (new_node.companies.indexOf(metaInfo[1]) >= 0) { - res.push(new_node); - } - break; - case Category.Difficulty: - if (new_node.difficulty === metaInfo[1]) { - res.push(new_node); - } - break; - case Category.Tag: - if (new_node.tags.indexOf(metaInfo[1]) >= 0) { - res.push(new_node); - } - break; - case Category.Score: - if (new_node.score > "0") { - const check_rank = toNumber(metaInfo[1]); - const node_rank = toNumber(new_node.score); - if (check_rank <= node_rank && node_rank < check_rank + 100) { - res.push(new_node); - } - } - break; - case Category.Choice: - if (choiceQuestionId[Number(new_node.qid)]) { - res.push(new_node); - } - break; - case Category.Contest: - if (new_node.ProblemIndex == metaInfo[1]) { - res.push(new_node); + } + } + else if (TreeChildNode.nodeType == TreeNodeType.Tree_difficulty_mid) { + if (node.get_data().difficulty === TreeChildNode.id) { + res.push(CreateTreeNodeModel(node.get_data(), TreeNodeType.Tree_difficulty_mid_leaf)); + + } + } + else if (TreeChildNode.nodeType == TreeNodeType.Tree_difficulty_hard) { + if (node.get_data().difficulty === TreeChildNode.id) { + res.push(CreateTreeNodeModel(node.get_data(), TreeNodeType.Tree_difficulty_hard_leaf)); + + } + } + else if (TreeChildNode.nodeType == TreeNodeType.Tree_tag_fenlei) { + if (node.tags.indexOf(TreeChildNode.id) >= 0) { + res.push(CreateTreeNodeModel(node.get_data(), TreeNodeType.Tree_tag_fenlei_leaf)); + } + } + + else if (TreeChildNode.nodeType == TreeNodeType.Tree_score_fen) { + if (node.score > "0") { + const check_rank = toNumber(TreeChildNode.id); + const node_rank = toNumber(node.score); + if (check_rank <= node_rank && node_rank < check_rank + 100) { + res.push(CreateTreeNodeModel(node.get_data(), TreeNodeType.Tree_score_fen_leaf)); } - break; + } + } + + else if (TreeChildNode.nodeType == TreeNodeType.Tree_choice_fenlei) { + if (choiceQuestionId[Number(node.get_data().qid)]) { + res.push(CreateTreeNodeModel(node.get_data(), TreeNodeType.Tree_choice_fenlei_leaf)); + } + } + + else if (TreeChildNode.nodeType == TreeNodeType.Tree_contest_Q1) { + if (node.ProblemIndex == TreeChildNode.id) { + res.push(CreateTreeNodeModel(node.get_data(), TreeNodeType.Tree_contest_Q1_leaf)); + } } + + else if (TreeChildNode.nodeType == TreeNodeType.Tree_contest_Q2) { + if (node.ProblemIndex == TreeChildNode.id) { + res.push(CreateTreeNodeModel(node.get_data(), TreeNodeType.Tree_contest_Q2_leaf)); + } + } + + else if (TreeChildNode.nodeType == TreeNodeType.Tree_contest_Q3) { + if (node.ProblemIndex == TreeChildNode.id) { + res.push(CreateTreeNodeModel(node.get_data(), TreeNodeType.Tree_contest_Q3_leaf)); + } + } + + else if (TreeChildNode.nodeType == TreeNodeType.Tree_contest_Q4) { + if (node.ProblemIndex == TreeChildNode.id) { + res.push(CreateTreeNodeModel(node.get_data(), TreeNodeType.Tree_contest_Q4_leaf)); + } + } + + } return sortNodeList(res); } @@ -1424,7 +1421,6 @@ class TreeViewController implements Disposable { private sortSubCategoryNodes(subCategoryNodes: TreeNodeModel[], category: Category): void { switch (category) { case Category.Tag: - case Category.Company: subCategoryNodes.sort((a: TreeNodeModel, b: TreeNodeModel): number => { if (a.name === "Unknown") { return 1; diff --git a/src/dao/bricksDao.ts b/src/dao/bricksDao.ts index 8766a18..36f7c82 100644 --- a/src/dao/bricksDao.ts +++ b/src/dao/bricksDao.ts @@ -7,11 +7,11 @@ * Copyright (c) 2022 ccagml . All rights reserved. */ -import { selectWorkspaceFolder } from "../utils/ConfigUtils"; -import { useWsl, toWinPath, getDayStart, getDayNow, getYMD, getDayEnd } from "../utils/SystemUtils"; +import { getbricksReviewDay, selectWorkspaceFolder } from "../utils/ConfigUtils"; +import { useWsl, toWinPath, getDayStart, getDayNow, getDayEnd } from "../utils/SystemUtils"; import * as path from "path"; import * as fse from "fs-extra"; -import { BricksType, BricksTypeName } from "../model/ConstDefind"; +import { BricksType } from "../model/ConstDefind"; // let bricks_json = { // version: 1, @@ -114,32 +114,6 @@ class BricksDao { return add_flag ? today_time + need_day_ago * 86400 : today_time - need_day_ago * 86400; } - private getTypeName(type: number) { - switch (type) { - case BricksType.TYPE_0: - return BricksTypeName.TYPE_0; - case BricksType.TYPE_1: - // 1:(14天搬砖simple) - return BricksTypeName.TYPE_1; - case BricksType.TYPE_2: - // 2:(7天后搬砖simple_error) - return BricksTypeName.TYPE_2; - case BricksType.TYPE_3: - // 3:(5天后搬砖simple_time) - return BricksTypeName.TYPE_3; - case BricksType.TYPE_4: - // 4:(3天后搬砖(time_limit)) - return BricksTypeName.TYPE_4; - case BricksType.TYPE_5: - // 5:(2天后搬砖(medium)) - return BricksTypeName.TYPE_5; - case BricksType.TYPE_6: - // 6: (1天后搬砖(hard)) - return BricksTypeName.TYPE_6; - default: - return ""; - } - } public async getTodayBricks(): Promise { let today_time = getDayStart(); @@ -158,20 +132,72 @@ class BricksDao { return all_qid; } - public async getLastSubmitTimeToolTip(qid_list: Array) { + public async getNeedReviewQidByReviewTime(review_time: number): Promise { let all_bricks = await this.getAllBricks(); - let result: Map = new Map(); - qid_list.forEach((qid) => { + let all_qid: Array = []; + for (const qid in all_bricks) { const value = all_bricks[qid]; - const submit_time = value.submit_time || []; - const submit_size = submit_time.length; - if (submit_size >= 1) { - result.set(qid, `${getYMD(submit_time[submit_size - 1])}日提交`); + const review_day = value.review_day || []; + if (review_day.includes(review_time)) { + all_qid.push(qid) } + } + return all_qid; + } + + // 获取需要复习的日期,时间戳 + public async getNeedReviewDay(): Promise { + let all_bricks = await this.getAllBricks(); + let day_map: Map = new Map(); + for (const qid in all_bricks) { + const value = all_bricks[qid]; + const review_day: Array = value.review_day || []; + if (review_day.length > 0) { + review_day.forEach(re_time => { + day_map.set(re_time, 1) + }); + } + } + let result: number[] = []; + day_map.forEach((_, key) => { + result.push(key); }); + + result.sort((a, b) => a - b); return result; } + // 设置下次出现的日期 + public async setReviewDayByQidAndType(qid: string, type: BricksType) { + let today_time = getDayStart(); //获取当天零点的时间 + let next_review_time = today_time + type * 86400 + + let temp_data = await this.getInfoByQid(qid); + + let review_day = temp_data.review_day || [] + if (!review_day.includes(next_review_time)) { + review_day.push(next_review_time) + review_day.sort((a, b) => a - b); + } + temp_data.review_day = review_day; + await this.setInfoByQid(qid, temp_data); + } + + + // public async getLastSubmitTimeToolTip(qid_list: Array) { + // let all_bricks = await this.getAllBricks(); + // let result: Map = new Map(); + // qid_list.forEach((qid) => { + // const value = all_bricks[qid]; + // const submit_time = value.submit_time || []; + // const submit_size = submit_time.length; + // if (submit_size >= 1) { + // result.set(qid, `${getYMD(submit_time[submit_size - 1])}日提交`); + // } + // }); + // return result; + // } + public async getTodayBricksSubmit(): Promise { let today_time = getDayStart(); let today_time_end = getDayEnd(); @@ -192,33 +218,32 @@ class BricksDao { return all_qid; } - public async getTodayBricksSubmitToolTip(qid_list: Array) { - let today_time = getDayStart(); - let all_bricks = await this.getAllBricks(); - let result: Map = new Map(); - qid_list.forEach((qid) => { - const value = all_bricks[qid]; - if (value == undefined) { - result.set(qid, this.TypetimeToMan(BricksType.TYPE_2, this.getTimeByType(BricksType.TYPE_2, today_time, true))); - } else { - result.set( - qid, - this.TypetimeToMan( - value.type != undefined ? value.type : BricksType.TYPE_2, - this.getTimeByType(value.type != undefined ? value.type : BricksType.TYPE_2, today_time, true) - ) - ); - } - }); - return result; - } - public TypetimeToMan(type, time: number) { - if (time < 10) { - return BricksTypeName.TYPE_0; - } - - return `${this.getTypeName(type)}后${getYMD(time)}出现`; //this.getTypeName(type) + getYMD(time) + "出现"; - } + // public async getTodayBricksSubmitToolTip(qid_list: Array) { + // let today_time = getDayStart(); + // let all_bricks = await this.getAllBricks(); + // let result: Map = new Map(); + // qid_list.forEach((qid) => { + // const value = all_bricks[qid]; + // if (value == undefined) { + // result.set(qid, this.TypetimeToMan(BricksType.TYPE_2, this.getTimeByType(BricksType.TYPE_2, today_time, true))); + // } else { + // result.set( + // qid, + // this.TypetimeToMan( + // value.type != undefined ? value.type : BricksType.TYPE_2, + // this.getTimeByType(value.type != undefined ? value.type : BricksType.TYPE_2, today_time, true) + // ) + // ); + // } + // }); + // return result; + // } + // public TypetimeToMan(type, time: number) { + // if (time < 10) { + // return BricksTypeName.TYPE_0; + // } + // return `${this.getTypeName(type)}后${getYMD(time)}出现`; //this.getTypeName(type) + getYMD(time) + "出现"; + // } public async getInfoByQid(qid: string) { let all_bricks = await this.getAllBricks(); @@ -232,20 +257,19 @@ class BricksDao { await this._write_data(all_data); } // 清空 - public async addQidSubmitTime(qid_list: string[]) { + public async removeReviewDay() { let all_data = await this._read_data(); let temp = all_data.all_bricks || {}; - qid_list.forEach((qid) => { - const value = temp[qid] || {}; - const submit_time = value.submit_time || []; - submit_time.push(2012345678); - value.submit_time = submit_time; - temp[qid] = value; - }); + + for (const qid in temp) { + delete temp[qid].review_day + } + all_data.all_bricks = temp; await this._write_data(all_data); } + // 设置其提交时间 和 复习时间 public async addSubmitTimeByQid(qid: string) { let temp_data = await this.getInfoByQid(qid); let submit_time = temp_data.submit_time || []; @@ -255,14 +279,33 @@ class BricksDao { if (!temp_data.type) { temp_data.type = BricksType.TYPE_2; } + + let cur_start_time = getDayStart() + let review_day: Array = temp_data.review_day || []; + // 移除需要复习的 + if (review_day.length > 0) { + let new_review_day: Array = [] + review_day.forEach(re_time => { + if (re_time > submit_now) { + new_review_day.push(re_time) + } + }); + review_day = new_review_day + } else { + let review_day_cfg = getbricksReviewDay() + review_day_cfg.forEach(r_day => { + review_day.push(cur_start_time + r_day * 86400) + }) + } + temp_data.review_day = review_day await this.setInfoByQid(qid, temp_data); return submit_now; } - public async setTypeByQid(qid: string, type) { - let temp_data = await this.getInfoByQid(qid); - temp_data.type = type; - await this.setInfoByQid(qid, temp_data); - } + // public async setTypeByQid(qid: string, type) { + // let temp_data = await this.getInfoByQid(qid); + // temp_data.type = type; + // await this.setInfoByQid(qid, temp_data); + // } } export const bricksDao: BricksDao = new BricksDao(); diff --git a/src/model/ConstDefind.ts b/src/model/ConstDefind.ts index 314921d..152b8d2 100644 --- a/src/model/ConstDefind.ts +++ b/src/model/ConstDefind.ts @@ -135,7 +135,7 @@ export enum RootNodeSort { Choice = 7, Score = 8, ScoreRange = 9, - Context = 9, + Contest = 9, DIFEASY = 1, DIFMID = 2, DIFHARD = 3, @@ -156,23 +156,25 @@ export interface IScoreData { } export enum BricksNormalId { - Have = "bricksHave", // 有活 - HaveDesc = "别吹牛了,工头让我叫你快去搬砖了", - No = "bricksNo", // 没活 - NoDesc = "工头让你去上面那个工地,过几天再回来", - Today = "bricksToday", - DIY = "bricksDiy", + NeedReview = "bricksneedreview", // 有活需要复习 + NeedReviewDesc = "别吹牛了,工头让我叫你快去搬砖了", + NeedReDate = "bricksneedRedate", // 复习的日期节点 + NoReview = "bricksnoreview", // 没活 + NoReviewDesc = "工头让你去上面那个工地,过几天再回来", + TodaySubmit = "brickstodaysubmit", + DIY = "bricksdiy", + NotSignIn = "notsignin" // 没登录 } +// 类型默认天数 export enum BricksType { - TYPE_0 = 0, - TYPE_1 = 1, - TYPE_2 = 2, - TYPE_3 = 3, - TYPE_4 = 4, - TYPE_5 = 5, - TYPE_6 = 6, - TYPE_7 = 7, + TYPE_0 = 1, + TYPE_1 = 2, + TYPE_2 = 4, + TYPE_3 = 7, + TYPE_4 = 14, + TYPE_5 = 28, + TYPE_6 = 60, } export enum BricksTypeName { @@ -183,7 +185,6 @@ export enum BricksTypeName { TYPE_4 = "3天", TYPE_5 = "2天", TYPE_6 = "1天", - TYPE_7 = "999天", } export enum Category { diff --git a/src/model/TreeNodeModel.ts b/src/model/TreeNodeModel.ts index 967a099..3af1447 100644 --- a/src/model/TreeNodeModel.ts +++ b/src/model/TreeNodeModel.ts @@ -72,17 +72,85 @@ export interface ITodayDataResponse { } export enum TreeNodeType { - TreeDataNormal = 1, // 普通题目根 - TreeDataLeaf = 2, // 普通题目叶子 - BricksDataNormal = 3, // 普通砖头根 - BricksDataLeaf = 4, // 普通砖头叶子 - TreeDataSearch = 5, // 查询的根 - TreeDataSearchLeaf = 6, // 查询的叶子 - TreeDataDay = 7, // 每日一题的根 - TreeDataDayLeaf = 8, // 每日一题的叶子 - TreeQuestionData = 9, // 题目数据 + + // 功能节点 + TreeNotSignIn = 30100, + BricksNotSignIn = 30200, + TreeQuestionData = 30300, + + // 四位 + // 万位 1:题目列表 2:搬砖工地 + // 千位 第一层的标识 + // 百位 第一层的标识 + // 十位 第二层的标识 + // 个位 第三层标识 + + Tree_day = 10100, // 题目列表 每日一题 + Tree_day_leaf = 10111, // 题目列表 每日一题的叶子 + Tree_All = 10200, // all层 + Tree_All_leaf = 10211, // all层 的题目 + + Tree_difficulty = 10300, // difficulty + Tree_difficulty_easy = 10310, // difficulty/easy + Tree_difficulty_easy_leaf = 10311, // difficulty/easy + Tree_difficulty_mid = 10320, // difficulty/medium + Tree_difficulty_mid_leaf = 10321, // difficulty/medium + Tree_difficulty_hard = 10330, // difficulty/hard + Tree_difficulty_hard_leaf = 10331, // difficulty/hard + + Tree_tag = 10400, // tag + Tree_tag_fenlei = 10410, // tag + Tree_tag_fenlei_leaf = 10411, // tag + + Tree_favorite = 10500, // favorite + Tree_favorite_leaf = 10511, // 题目 + + Tree_choice = 10600, // choice + Tree_choice_fenlei = 10610, // choice 分类层 + Tree_choice_fenlei_leaf = 10611, // choice 分类层 + + Tree_score = 10700,// score + Tree_score_fen = 10710, //具体分数层 + Tree_score_fen_leaf = 10711, //具体分数层 + + Tree_contest = 10800, // contest + Tree_contest_Q1 = 10810, // contest q1 + Tree_contest_Q1_leaf = 10811, // contest q1 + Tree_contest_Q2 = 10820, // contest q2 + Tree_contest_Q2_leaf = 10821, // contest q2 + Tree_contest_Q3 = 10830, // contest q3 + Tree_contest_Q3_leaf = 10831, // contest q3 + Tree_contest_Q4 = 10840, // contest q4 + Tree_contest_Q4_leaf = 10841, // contest q4 + + Tree_search = 10900, // 查询分数范围,周赛期数 + Tree_search_score_leaf = 10911, // 分数范围的叶子 + Tree_search_contest_leaf = 10921, // 分数范围的叶子 + + + // 工地================= + + Bricks_NeedReview = 20100, // 工地 有需要复习 + Bricks_NeedReview_Day = 20110, // 工地 有需要复习,日期那层 + Bricks_NeedReview_Day_leaf = 20111, // 工地 有需要复习,题目 + + Bricks_NoReview = 20200, // 工地 没有需要复习 + + Bricks_TodaySubmit = 20300, // 工地 今日提交 + Bricks_TodaySubmit_leaf = 20301, // 工地 今日提交 + + + Bricks_Diy = 20400, // 工地 自己创建的那层 + Bricks_Diy_leaf = 20401, // 工地 自己创建的那层 + + +} + +export function CreateTreeNodeModel(data: ITreeDataNormal | ITreeDataSearch | ITreeDataDay | IQuestionData | IBricksToday, nodeType: TreeNodeType): TreeNodeModel { + return new TreeNodeModel(data, nodeType); } + export class TreeNodeModel { __DataPool: Map = new Map(); @@ -163,15 +231,30 @@ export class TreeNodeModel { } public get isSearchResult(): boolean { - return this.nodeType == TreeNodeType.TreeDataSearch || this.nodeType == TreeNodeType.TreeDataDay; + return this.nodeType == TreeNodeType.Tree_search || this.nodeType == TreeNodeType.Tree_day; } public get isProblem(): boolean { return ( - this.nodeType == TreeNodeType.TreeDataLeaf || - this.nodeType == TreeNodeType.BricksDataLeaf || - this.nodeType == TreeNodeType.TreeDataSearchLeaf || - this.nodeType == TreeNodeType.TreeDataDayLeaf + 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 + ); } @@ -231,155 +314,3 @@ export class TreeNodeModel { }); } } - -// export class NodeModel { -// private _u_score; -// constructor(public data: IProblem, public isProblemNode: boolean = true, userscore: number = 0) { -// this._u_score = userscore; -// } - -// public get locked(): boolean { -// return this.data.locked; -// } -// public get name(): string { -// return this.data.name; -// } -// public get cn_name(): string { -// return this.data.cn_name; -// } -// public get en_name(): string { -// return this.data.en_name; -// } - -// public get state(): ProblemState { -// // 每日一题的修正 -// if (this.todayData) { -// const us = this.todayDataUserStatus; -// if (us == "FINISH") { -// return ProblemState.AC; -// } else { -// return ProblemState.Unknown; -// } -// } - -// return this.data.state; -// } - -// public get id(): string { -// return this.data.id; -// } - -// public get passRate(): string { -// return this.data.passRate; -// } - -// public get difficulty(): string { -// return this.data.difficulty; -// } - -// public get companies(): string[] { -// return this.data.companies; -// } - -// public get isFavorite(): boolean { -// return this.data.isFavorite; -// } - -// public get isProblem(): boolean { -// return this.isProblemNode; -// } -// public get rootNodeSortId(): RootNodeSort { -// return this.data.rootNodeSortId; -// } - -// public get previewCommand(): Command { -// return { -// title: "Preview Problem", -// command: "lcpr.previewProblem", -// arguments: [this], -// }; -// } - -// public get acceptanceRate(): number { -// return Number(this.passRate) || 50; -// } - -// public get uri(): Uri { -// return Uri.from({ -// scheme: "leetcode", -// authority: this.isProblem ? "problems" : "tree-node", -// path: `/${this.id}`, // path must begin with slash / -// query: `difficulty=${this.difficulty}&score=${this.score}&user_score=${this._u_score}`, -// }); -// } - -// public set set_user_score(s: number) { -// this._u_score = s; -// } - -// public get user_score(): number { -// return this._u_score; -// } - -// // rank分 -// public get score(): string { -// return this.data.scoreData?.score || "0"; -// } -// // 周赛名称 -// public get ContestID_en(): string { -// return this.data.scoreData?.ContestID_en || ""; -// } -// // 周赛第几题 -// public get ProblemIndex(): string { -// return this.data.scoreData?.ProblemIndex || ""; -// } -// // 周赛名称符号链接 -// public get ContestSlug(): string { -// return this.data.scoreData?.ContestSlug || ""; -// } -// public get scoreData(): IScoreData | undefined { -// return this.data.scoreData; -// } -// public get isSearchResult(): boolean { -// return this.data.isSearchResult; -// } -// public get input(): string { -// return this.data.input || ""; -// } -// // 每日一题的一些信息 -// public get todayData(): ITodayData | undefined { -// return this.data.todayData; -// } -// public set todayData(s: ITodayData | undefined) { -// this.data.todayData = s; -// } -// public get todayDataDate(): string { -// return this.data.todayData?.date || ""; -// } -// public get todayDataUserStatus(): string { -// return this.data.todayData?.userStatus || ""; -// } -// public get qid(): string { -// return this.data.qid || ""; -// } -// } - -// export class BricksNode extends NodeModel { -// public collapsibleState?; -// public groupTime?; -// public toolTip?; -// constructor( -// data: IProblem, -// ipn: boolean = true, -// userscore: number = 0, -// collapsibleState = 0, -// groupTime?: number, -// toolTip?: string -// ) { -// super(data, ipn, userscore); -// this.isProblemNode = ipn; -// this.collapsibleState = collapsibleState; -// this.groupTime = groupTime; -// this.toolTip = toolTip; -// } -// } diff --git a/src/questionData/QuestionDataModule.ts b/src/questionData/QuestionDataModule.ts index bc2f1be..796ce65 100644 --- a/src/questionData/QuestionDataModule.ts +++ b/src/questionData/QuestionDataModule.ts @@ -9,7 +9,7 @@ import { BABA, BABAMediator, BABAProxy, BabaStr, BaseCC } from "../BABA"; import { ISubmitEvent, OutPutType, ProblemState, UserStatus } from "../model/ConstDefind"; -import { IQuestionData, TreeNodeModel, TreeNodeType } from "../model/TreeNodeModel"; +import { CreateTreeNodeModel, IQuestionData, TreeNodeModel, TreeNodeType } from "../model/TreeNodeModel"; import { isShowLocked, isUseEndpointTranslation } from "../utils/ConfigUtils"; import { ShowMessage } from "../utils/OutputUtils"; @@ -32,7 +32,7 @@ class QuestionData { public async ReBuildQuestionData() { let all_data = await BABA.getProxy(BabaStr.QuestionDataProxy).getAllQuestionData(); for (const problem of all_data) { - let TreeNodeObj = new TreeNodeModel(problem, TreeNodeType.TreeQuestionData); + let TreeNodeObj = CreateTreeNodeModel(problem, TreeNodeType.TreeQuestionData); this.fidMapQuestionData.set(TreeNodeObj.id, TreeNodeObj); this.fidToQid.set(TreeNodeObj.id, TreeNodeObj.qid.toString()); this.qidToFid.set(TreeNodeObj.qid.toString(), TreeNodeObj.id); diff --git a/src/remark/RemarkServiceModule.ts b/src/remark/RemarkServiceModule.ts index 53ad3b5..5667aa2 100644 --- a/src/remark/RemarkServiceModule.ts +++ b/src/remark/RemarkServiceModule.ts @@ -217,7 +217,7 @@ class RemarkService implements Disposable { this._qid_map_thread.get(qid)?.dispose(); } - public dispose(): void {} + public dispose(): void { } } export const remarkService: RemarkService = new RemarkService(); diff --git a/src/treeData/TreeDataService.ts b/src/treeData/TreeDataService.ts index 160edd9..63ea8ef 100644 --- a/src/treeData/TreeDataService.ts +++ b/src/treeData/TreeDataService.ts @@ -10,9 +10,9 @@ // import * as os from "os"; import * as path from "path"; import * as vscode from "vscode"; -import { Category, ProblemState, SearchSetType, OutPutType, Endpoint, IQuickItemEx } from "../model/ConstDefind"; +import { Category, ProblemState, SearchSetType, OutPutType, Endpoint, IQuickItemEx, BricksNormalId } from "../model/ConstDefind"; import { treeViewController } from "../controller/TreeViewController"; -import { TreeNodeModel, TreeNodeType } from "../model/TreeNodeModel"; +import { CreateTreeNodeModel, TreeNodeModel, TreeNodeType } from "../model/TreeNodeModel"; import { choiceDao } from "../dao/choiceDao"; import { tagsDao } from "../dao/tagsDao"; import { ShowMessage, promptForSignIn } from "../utils/OutputUtils"; @@ -55,7 +55,7 @@ export class TreeDataService implements vscode.TreeDataProvider { } public getTreeItem(element: TreeNodeModel): vscode.TreeItem | Thenable { - if (element.id === "notSignIn") { + if (element.id === BricksNormalId.NotSignIn) { return { label: element.name, collapsibleState: vscode.TreeItemCollapsibleState.None, @@ -92,12 +92,12 @@ export class TreeDataService implements vscode.TreeDataProvider { public getChildren(element?: TreeNodeModel | undefined): vscode.ProviderResult { if (!BABA.getProxy(BabaStr.StatusBarProxy).getUser()) { return [ - new TreeNodeModel( + CreateTreeNodeModel( { - id: "notSignIn", + id: BricksNormalId.NotSignIn, name: "未登录", }, - TreeNodeType.TreeDataNormal + TreeNodeType.TreeNotSignIn ), ]; } @@ -105,49 +105,44 @@ export class TreeDataService implements vscode.TreeDataProvider { // Root view return treeViewController.getRootNodes(); } else { - if (element.nodeType == TreeNodeType.TreeDataDay) { + if (element.nodeType == TreeNodeType.Tree_day) { return treeViewController.getDayNodes(element); - } else if (element.isSearchResult) { - switch (element.id) { - case SearchSetType.ScoreRange: - return treeViewController.getScoreRangeNodes(element.input); - break; - case SearchSetType.Context: - return treeViewController.getContextNodes(element.input); - break; - case SearchSetType.Day: - return treeViewController.getDayNodes(element); - break; - default: - break; + } + else if (element.nodeType == TreeNodeType.Tree_search) { + if (element.id == SearchSetType.ScoreRange) { + return treeViewController.getScoreRangeNodes(element.input); + } + else if (element.id == SearchSetType.Context) { + return treeViewController.getContestNodes(element.input); } return []; - } else { - switch ( - element.id // First-level - ) { - case Category.All: - return treeViewController.getAllNodes(); - case Category.Favorite: - return treeViewController.getFavoriteNodes(); - case Category.Difficulty: - return treeViewController.getAllDifficultyNodes(); - case Category.Tag: - return treeViewController.getAllTagNodes(); - case Category.Company: - return treeViewController.getAllCompanyNodes(); - case Category.Score: - return treeViewController.getAllScoreNodes(); - case Category.Choice: - return treeViewController.getAllChoiceNodes(); - case Category.Contest: - return treeViewController.getAllContestNodes(); - default: - if (element.isProblem) { - return []; - } - return treeViewController.getChildrenNodesById(element.id); + } + else if (element.nodeType == TreeNodeType.Tree_All) { + return treeViewController.getAllNodes(); + } + else if (element.nodeType == TreeNodeType.Tree_favorite) { + return treeViewController.getFavoriteNodes(); + } + else if (element.nodeType == TreeNodeType.Tree_difficulty) { + return treeViewController.getDifficultyChild() + } + else if (element.nodeType == TreeNodeType.Tree_tag) { + return treeViewController.getTagChild() + } + else if (element.nodeType == TreeNodeType.Tree_score) { + return treeViewController.getScoreChild(); + } + else if (element.nodeType == TreeNodeType.Tree_choice) { + return treeViewController.getChoiceChild(); + } + else if (element.nodeType == TreeNodeType.Tree_contest) { + return treeViewController.getContestChild(); + } + else { + if (element.isProblem) { + return []; } + return treeViewController.getChildrenSon(element); } } } diff --git a/src/utils/ConfigUtils.ts b/src/utils/ConfigUtils.ts index fd865ab..eabfb95 100644 --- a/src/utils/ConfigUtils.ts +++ b/src/utils/ConfigUtils.ts @@ -545,3 +545,10 @@ export function getOpenClearProblemCacheTime(): number { export function isOpenClearProblemCache(): boolean { return getVsCodeConfig().get("openClearProblemCache", false); } + +// 获取 +export function getbricksReviewDay() { + const shortcuts: number[] = getVsCodeConfig().get("bricksReviewDay", [1, 4, 7, 14, 28, 60]); + return shortcuts +} + From ae4abd6529b1662bad477299573555f3fb37aea6 Mon Sep 17 00:00:00 2001 From: ccagml Date: Thu, 2 May 2024 14:18:24 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=8A=82=E7=82=B9?= =?UTF-8?q?=E7=9A=84=E4=B8=8A=E4=B8=8B=E6=96=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 4 ++-- package.json | 36 ++++++++++++++--------------- src/BABA.ts | 2 ++ src/bricksData/BricksDataService.ts | 8 +------ src/extension.ts | 7 ++++++ src/model/TreeNodeModel.ts | 7 +++++- src/treeData/TreeDataService.ts | 9 +------- 7 files changed, 37 insertions(+), 36 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0fc7e7d..8934235 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "vscode-leetcode-problem-rating", - "version": "3.1.20", + "version": "3.1.23", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "vscode-leetcode-problem-rating", - "version": "3.1.20", + "version": "3.1.23", "license": "MIT", "dependencies": { "ansi-styles": "3.2.1", diff --git a/package.json b/package.json index e55c2d8..a78a442 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "vscode-leetcode-problem-rating", "displayName": "LeetCode", "description": "%main.description%", - "version": "3.1.22", + "version": "3.1.23", "author": "ccagml", "publisher": "ccagml", "license": "MIT", @@ -404,87 +404,87 @@ "view/item/context": [ { "command": "lcpr.previewProblem", - "when": "view == QuestionExplorer && viewItem =~ /problem*/", + "when": "view == QuestionExplorer && viewItem =~ /leaf*/", "group": "leetcode@1" }, { "command": "lcpr.showProblem", - "when": "view == QuestionExplorer && viewItem =~ /problem*/", + "when": "view == QuestionExplorer && viewItem =~ /leaf*/", "group": "leetcode@2" }, { "command": "lcpr.getHelp", - "when": "view == QuestionExplorer && viewItem =~ /problem*/", + "when": "view == QuestionExplorer && viewItem =~ /leaf*/", "group": "leetcode@3" }, { "submenu": "lcpr.setBricksType_sub", - "when": "view == QuestionExplorer && viewItem =~ /problem*/", + "when": "view == QuestionExplorer && viewItem =~ /leaf*/", "group": "leetcode@4" }, { "command": "lcpr.addQidToGroup", - "when": "view == QuestionExplorer && viewItem =~ /problem*/", + "when": "view == QuestionExplorer && viewItem =~ /leaf*/", "group": "leetcode@5" }, { "command": "lcpr.addFavorite", - "when": "view == QuestionExplorer && viewItem == problem", + "when": "view == QuestionExplorer && viewItem =~ /leaf*/ && viewItem != leaf#10511#", "group": "inline" }, { "command": "lcpr.removeFavorite", - "when": "view == QuestionExplorer && viewItem == problem-favorite", + "when": "view == QuestionExplorer && viewItem == leaf#10511#", "group": "inline" }, { "command": "lcpr.previewProblem", - "when": "view == BricksExplorer && viewItem =~ /nodebricks*/", + "when": "view == BricksExplorer && viewItem =~ /leaf*/", "group": "leetcode@1" }, { "command": "lcpr.showProblem", - "when": "view == BricksExplorer && viewItem =~ /nodebricks*/", + "when": "view == BricksExplorer && viewItem =~ /leaf*/", "group": "leetcode@2" }, { "command": "lcpr.getHelp", - "when": "view == BricksExplorer && viewItem =~ /nodebricks*/", + "when": "view == BricksExplorer && viewItem =~ /leaf*/", "group": "leetcode@3" }, { "submenu": "lcpr.setBricksType_sub1", - "when": "view == BricksExplorer && viewItem =~ /nodebricks*/ ", + "when": "view == BricksExplorer && viewItem =~ /leaf*/ ", "group": "leetcode@4" }, { "command": "lcpr.addQidToGroup", - "when": "view == BricksExplorer && viewItem != nodebricksdiy && viewItem != bricksneedredate && viewItem != bricksneedreview && viewItem != brickstodaysubmit && viewItem != bricksdiy", + "when": "view == BricksExplorer && viewItem =~ /leaf*/ ", "group": "leetcode@5" }, { "command": "lcpr.removeBricksHave", - "when": "view == BricksExplorer && viewItem == bricksneedreview", + "when": "view == BricksExplorer && viewItem == cc#20100#", "group": "leetcode@5" }, { "command": "lcpr.removeQidFromGroup", - "when": "view == BricksExplorer && viewItem == nodebricksdiy", + "when": "view == BricksExplorer && viewItem == leaf#20401#", "group": "leetcode@5" }, { "command": "lcpr.removeBrickGroup", - "when": "view == BricksExplorer && viewItem == bricksdiy", + "when": "view == BricksExplorer && viewItem == cc#20400#", "group": "leetcode@1" }, { "command": "lcpr.removeBricksNeedReviewDay", - "when": "view == BricksExplorer && viewItem == bricksneedredate", + "when": "view == BricksExplorer && viewItem == cc#20110#", "group": "leetcode@1" }, { "command": "lcpr.removeBricksNeedReviewDayNode", - "when": "view == BricksExplorer && viewItem == bricksneedreview", + "when": "view == BricksExplorer && viewItem == leaf#20111#", "group": "leetcode@1" } ], diff --git a/src/BABA.ts b/src/BABA.ts index 61898a0..61278fb 100644 --- a/src/BABA.ts +++ b/src/BABA.ts @@ -103,6 +103,8 @@ export enum BabaStr { BABACMD_newBrickGroup = "BABACMD_newBrickGroup", BABACMD_addQidToGroup = "BABACMD_addQidToGroup", BABACMD_removeBrickGroup = "BABACMD_removeBrickGroup", + BABACMD_removeBricksNeedReviewDay = "BABACMD_removeBricksNeedReviewDay", + BABACMD_removeBricksNeedReviewDayNode = "BABACMD_removeBricksNeedReviewDayNode", BABACMD_removeBricksHave = "BABACMD_removeBricksHave", BricksData_removeBricksHaveFinish = "BricksData_removeBricksHaveFinish", BABACMD_removeQidFromGroup = "BABACMD_removeQidFromGroup", diff --git a/src/bricksData/BricksDataService.ts b/src/bricksData/BricksDataService.ts index 69035e6..d2a7b21 100644 --- a/src/bricksData/BricksDataService.ts +++ b/src/bricksData/BricksDataService.ts @@ -43,12 +43,6 @@ export class BricksDataService implements TreeDataProvider { }, }; } - let contextValue: string; - if (element.isProblem) { - contextValue = element.groupTime ? "nodebricksdiy" : "nodebricks"; - } else { - contextValue = element.id.toLowerCase(); - } const result: TreeItem | Thenable = { label: element.isProblem @@ -59,7 +53,7 @@ export class BricksDataService implements TreeDataProvider { iconPath: this.parseIconPathFromProblemState(element), command: element.isProblem ? element.previewCommand : undefined, resourceUri: element.uri, - contextValue, + contextValue: element.viewItem, }; return result; } diff --git a/src/extension.ts b/src/extension.ts index db9d792..dad91c8 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -173,6 +173,13 @@ export async function activate(context: ExtensionContext): Promise { commands.registerCommand("lcpr.removeBrickGroup", (a) => BABA.sendNotification(BabaStr.BABACMD_removeBrickGroup, a) ), + commands.registerCommand("lcpr.removeBricksNeedReviewDay", (a) => + BABA.sendNotification(BabaStr.BABACMD_removeBricksNeedReviewDay, a) + ), + commands.registerCommand("lcpr.removeBricksNeedReviewDayNode", (a) => + BABA.sendNotification(BabaStr.BABACMD_removeBricksNeedReviewDayNode, a) + ), + commands.registerCommand("lcpr.removeBricksHave", (a) => BABA.sendNotification(BabaStr.BABACMD_removeBricksHave, a) ), diff --git a/src/model/TreeNodeModel.ts b/src/model/TreeNodeModel.ts index 3af1447..da69c29 100644 --- a/src/model/TreeNodeModel.ts +++ b/src/model/TreeNodeModel.ts @@ -258,7 +258,12 @@ export class TreeNodeModel { ); } - // rank分 + public get viewItem(): string { + if (this.isProblem) { + return `leaf#${this.nodeType}#` + } + return `cc#${this.nodeType}#` + } // rank分 public get score(): string { return BABA.getProxy(BabaStr.RankScoreDataProxy).getDataByFid(this.fid)?.score || "0"; } diff --git a/src/treeData/TreeDataService.ts b/src/treeData/TreeDataService.ts index 63ea8ef..1819dda 100644 --- a/src/treeData/TreeDataService.ts +++ b/src/treeData/TreeDataService.ts @@ -66,13 +66,6 @@ export class TreeDataService implements vscode.TreeDataProvider { }; } - let contextValue: string; - if (element.isProblem) { - contextValue = element.isFavorite ? "problem-favorite" : "problem"; - } else { - contextValue = element.id.toLowerCase(); - } - const result: vscode.TreeItem | Thenable = { label: element.isProblem ? (element.score > "0" ? "[score:" + element.score + "]" : "") + `ID:${element.id}.${element.name} ` @@ -84,7 +77,7 @@ export class TreeDataService implements vscode.TreeDataProvider { iconPath: this.parseIconPathFromProblemState(element), command: element.isProblem ? element.previewCommand : undefined, resourceUri: element.uri, - contextValue, + contextValue: element.viewItem, }; return result; } From 6692c517a2d663eaf47a038c8913bc14912de211 Mon Sep 17 00:00:00 2001 From: ccagml Date: Thu, 2 May 2024 14:38:00 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E5=A4=8D=E4=B9=A0?= =?UTF-8?q?=E7=9A=84=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bricksData/BricksDataService.ts | 8 +++++++ src/controller/BricksViewController.ts | 13 ++++++++++- src/dao/bricksDao.ts | 32 ++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/src/bricksData/BricksDataService.ts b/src/bricksData/BricksDataService.ts index d2a7b21..f4641e7 100644 --- a/src/bricksData/BricksDataService.ts +++ b/src/bricksData/BricksDataService.ts @@ -198,6 +198,8 @@ export class BricksDataMediator extends BABAMediator { BabaStr.CommitResult_showFinish, BabaStr.BricksData_removeBricksHaveFinish, BabaStr.BABACMD_removeBricksHave, + BabaStr.BABACMD_removeBricksNeedReviewDay, + BabaStr.BABACMD_removeBricksNeedReviewDayNode ]; } async handleNotification(_notification: BaseCC.BaseCC.INotification) { @@ -249,6 +251,12 @@ export class BricksDataMediator extends BABAMediator { case BabaStr.BABACMD_removeBricksHave: bricksViewController.removeBricksHave(); break; + case BabaStr.BABACMD_removeBricksNeedReviewDay: + bricksViewController.removeBricksNeedReviewDay(body); + break; + case BabaStr.BABACMD_removeBricksNeedReviewDayNode: + bricksViewController.removeBricksNeedReviewDayNode(body); + break; default: break; } diff --git a/src/controller/BricksViewController.ts b/src/controller/BricksViewController.ts index 513d297..3af3848 100644 --- a/src/controller/BricksViewController.ts +++ b/src/controller/BricksViewController.ts @@ -32,7 +32,7 @@ class BricksViewController implements Disposable { let new_obj = CreateTreeNodeModel( Object.assign({}, node.get_data(), { collapsibleState: TreeItemCollapsibleState.None, - groupTime: 0, + groupTime: groupTime, }), TreeNodeType.Bricks_NeedReview_Day_leaf ); @@ -244,6 +244,17 @@ class BricksViewController implements Disposable { BABA.sendNotification(BabaStr.BricksData_removeQidFromGroupFinish); } + // 移除某个日期 + public async removeBricksNeedReviewDay(node) { + bricksDao.removeBricksNeedReviewDay(node.groupTime); + BABA.sendNotification(BabaStr.BricksData_removeQidFromGroupFinish); + } + // 移除某个日期的某一题 + public async removeBricksNeedReviewDayNode(node) { + bricksDao.removeBricksNeedReviewDayNode(node.groupTime, node.qid); + BABA.sendNotification(BabaStr.BricksData_removeQidFromGroupFinish); + } + public async removeBricksHave() { await bricksDao.removeReviewDay(); BABA.sendNotification(BabaStr.BricksData_removeBricksHaveFinish); diff --git a/src/dao/bricksDao.ts b/src/dao/bricksDao.ts index 36f7c82..6ec218d 100644 --- a/src/dao/bricksDao.ts +++ b/src/dao/bricksDao.ts @@ -269,6 +269,38 @@ class BricksDao { await this._write_data(all_data); } + // 清空日期 + public async removeBricksNeedReviewDay(review_time: number) { + let all_data = await this._read_data(); + let temp = all_data.all_bricks || {}; + + for (const qid in temp) { + if (temp[qid].review_day != undefined && temp[qid].review_day.includes(review_time)) { + let new_review_day = temp[qid].review_day.filter((p) => { p != review_time }) + temp[qid].review_day = new_review_day + } + } + + all_data.all_bricks = temp; + await this._write_data(all_data); + } + + // 清空日期下的点 + public async removeBricksNeedReviewDayNode(review_time: number, qid) { + let all_data = await this._read_data(); + let temp = all_data.all_bricks || {}; + + if (temp[qid] != undefined) { + if (temp[qid].review_day != undefined && temp[qid].review_day.includes(review_time)) { + let new_review_day = temp[qid].review_day.filter((p) => { p != review_time }) + temp[qid].review_day = new_review_day + } + } + + all_data.all_bricks = temp; + await this._write_data(all_data); + } + // 设置其提交时间 和 复习时间 public async addSubmitTimeByQid(qid: string) { let temp_data = await this.getInfoByQid(qid); From 55f52949f0c9e2e89af637586bfa528340269461 Mon Sep 17 00:00:00 2001 From: ccagml Date: Thu, 2 May 2024 14:59:28 +0800 Subject: [PATCH 4/4] =?UTF-8?q?3.2.1=20=E6=90=AC=E7=A0=96=E5=B7=A5?= =?UTF-8?q?=E5=9C=B0=E4=BF=AE=E6=94=B9=E8=89=BE=E5=AE=BE=E6=B5=A9=E6=96=AF?= =?UTF-8?q?=E8=AE=B0=E5=BF=86=E6=B3=95=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 6 ++++++ README.md | 1 + package.json | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 18cb4e0..b77b441 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# version 3.2.1 + +- 搬砖工地修改题目AC后在对应 1,4,7,14,28,60 天数后需要复习 +- 通过配置 bricksReviewDay 可以设置需要复习的天数 +- 一些按钮选项是否显示相关判断的上下文修改 + # version 3.1.22 - 修改预览题目、题解的样式加载方式,原本的方式在高版本的 VS Code 会加载失败 401 错误,导致界面很乱 diff --git a/README.md b/README.md index 74c50ce..ee0069b 100644 --- a/README.md +++ b/README.md @@ -211,6 +211,7 @@ | 配置项名称显示红色为与官方配置有不同的地方 | 描述 | 默认值 | | --------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- | | leetcode-problem-rating.hideSolved | 指定是否要隐藏已解决的问题 | `false` | +| leetcode-problem-rating.bricksReviewDay | 设置x天后复习 | [1,4,7,14,28,60 ] | | leetcode-problem-rating.showLocked` | 指定是否显示付费题目,只有付费账户才可以打开付费题目 | `false` | | leetcode-problem-rating.defaultLanguage | 指定答题时使用的默认语言,可选语言有:`bash`, `c`, `cpp`, `csharp`, `golang`, `java`, `javascript`, `kotlin`, `mysql`, `php`, `python`,`python3`,`ruby`, `rust`, `scala`, `swift`, `typescript` | `N/A` | | leetcode-problem-rating.useWsl | 指定是否启用 WSL | `false` | diff --git a/package.json b/package.json index a78a442..1c9b76d 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "vscode-leetcode-problem-rating", "displayName": "LeetCode", "description": "%main.description%", - "version": "3.1.23", + "version": "3.2.1", "author": "ccagml", "publisher": "ccagml", "license": "MIT",