Skip to content

Commit

Permalink
重置所有砖头
Browse files Browse the repository at this point in the history
  • Loading branch information
ccagml committed Oct 25, 2023
1 parent 994538e commit fc9b88c
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 3 deletions.
1 change: 1 addition & 0 deletions p.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
./c.sh
rm -rf out/
vsce package
rm -rf out
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,11 @@
"command": "lcpr.simpleDebug",
"title": "%main.contributes.commands.lcpr.simpleDebug.title%",
"icon": "$(remove)"
},
{
"command": "lcpr.removeBricksHave",
"title": "%main.contributes.commands.lcpr.removeBricksHave.title%",
"icon": "$(remove)"
}
],
"viewsContainers": {
Expand Down Expand Up @@ -452,6 +457,11 @@
"when": "view == BricksExplorer && viewItem != nodebricksdiy && viewItem != brickshave && viewItem != brickstoday && viewItem != bricksdiy",
"group": "leetcode@5"
},
{
"command": "lcpr.removeBricksHave",
"when": "view == BricksExplorer && viewItem == brickshave",
"group": "leetcode@5"
},
{
"command": "lcpr.removeQidFromGroup",
"when": "view == BricksExplorer && viewItem == nodebricksdiy",
Expand Down
1 change: 1 addition & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"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.removeBricksHave.title": "remove bricks have",
"main.contributes.commands.lcpr.removeQidFromGroup.title": "remove this",
"main.contributes.commands.lcpr.includeTemplates.title": "insert template",
"main.contributes.commands.lcpr.simpleDebug.title": "simple debug",
Expand Down
1 change: 1 addition & 0 deletions package.nls.zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"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.removeQidFromGroup.title": "从分类中移除这个题目",
"main.contributes.commands.lcpr.includeTemplates.title": "插入头文件模板",
"main.contributes.commands.lcpr.simpleDebug.title": "简单调试",
Expand Down
2 changes: 2 additions & 0 deletions src/BABA.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ export enum BabaStr {
BABACMD_newBrickGroup = "BABACMD_newBrickGroup",
BABACMD_addQidToGroup = "BABACMD_addQidToGroup",
BABACMD_removeBrickGroup = "BABACMD_removeBrickGroup",
BABACMD_removeBricksHave = "BABACMD_removeBricksHave",
BricksData_removeBricksHaveFinish = "BricksData_removeBricksHaveFinish",
BABACMD_removeQidFromGroup = "BABACMD_removeQidFromGroup",
DebugProxy = "DebugProxy",
DebugMediator = "DebugMediator",
Expand Down
6 changes: 6 additions & 0 deletions src/bricksData/BricksDataService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ export class BricksDataMediator extends BABAMediator {
BabaStr.BricksData_addQidToGroupFinish,
BabaStr.BricksData_removeQidFromGroupFinish,
BabaStr.CommitResult_showFinish,
BabaStr.BricksData_removeBricksHaveFinish,
BabaStr.BABACMD_removeBricksHave,
];
}
async handleNotification(_notification: BaseCC.BaseCC.INotification) {
Expand Down Expand Up @@ -231,6 +233,7 @@ export class BricksDataMediator extends BABAMediator {
case BabaStr.ConfigChange_hideScore:
case BabaStr.ConfigChange_SortStrategy:
case BabaStr.TreeData_favoriteChange:
case BabaStr.BricksData_removeBricksHaveFinish:
bricksDataService.fire();
break;
case BabaStr.CommitResult_showFinish:
Expand All @@ -251,6 +254,9 @@ export class BricksDataMediator extends BABAMediator {
case BabaStr.BABACMD_removeQidFromGroup:
bricksViewController.removeQidFromGroup(body);
break;
case BabaStr.BABACMD_removeBricksHave:
bricksViewController.removeBricksHave();
break;
default:
break;
}
Expand Down
17 changes: 16 additions & 1 deletion src/controller/BricksViewController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,20 @@ 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) {
baseNode.push(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);
}
});
return baseNode;
Expand Down Expand Up @@ -195,6 +204,12 @@ class BricksViewController implements Disposable {
groupDao.removeQidFromTime(node.qid, node.groupTime);
BABA.sendNotification(BabaStr.BricksData_removeQidFromGroupFinish);
}

public async removeBricksHave() {
let all_qid: string[] = await bricksDao.getTodayBricks();
await bricksDao.addQidSubmitTime(all_qid);
BABA.sendNotification(BabaStr.BricksData_removeBricksHaveFinish);
}
}

export const bricksViewController: BricksViewController = new BricksViewController();
37 changes: 35 additions & 2 deletions src/dao/bricksDao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

import { selectWorkspaceFolder } from "../utils/ConfigUtils";
import { useWsl, toWinPath, getDayStart, getDayNow, getYMD } from "../utils/SystemUtils";
import { useWsl, toWinPath, getDayStart, getDayNow, getYMD, getDayEnd } from "../utils/SystemUtils";
import * as path from "path";
import * as fse from "fs-extra";
import { BricksType, BricksTypeName } from "../model/ConstDefind";
Expand Down Expand Up @@ -158,15 +158,34 @@ class BricksDao {
return all_qid;
}

public async getLastSubmitTimeToolTip(qid_list: Array<string>) {
let all_bricks = await this.getAllBricks();
let result: Map<string, string> = new Map<string, string>();
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<string[]> {
let today_time = getDayStart();
let today_time_end = getDayEnd();
let all_bricks = await this.getAllBricks();
let all_qid: Array<string> = [];
for (const qid in all_bricks) {
const value = all_bricks[qid];
const submit_time = value.submit_time || [];
let submit_size = submit_time.length;
if (submit_size > 0 && submit_time[submit_size - 1] >= today_time) {
if (
submit_size > 0 &&
submit_time[submit_size - 1] >= today_time &&
submit_time[submit_size - 1] <= today_time_end
) {
all_qid.push(qid);
}
}
Expand Down Expand Up @@ -212,6 +231,20 @@ class BricksDao {
all_data.all_bricks = temp;
await this._write_data(all_data);
}
// 清空
public async addQidSubmitTime(qid_list: string[]) {
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;
});
all_data.all_bricks = temp;
await this._write_data(all_data);
}

public async addSubmitTimeByQid(qid: string) {
let temp_data = await this.getInfoByQid(qid);
Expand Down
3 changes: 3 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ export async function activate(context: ExtensionContext): Promise<void> {
commands.registerCommand("lcpr.removeBrickGroup", (a) =>
BABA.sendNotification(BabaStr.BABACMD_removeBrickGroup, a)
),
commands.registerCommand("lcpr.removeBricksHave", (a) =>
BABA.sendNotification(BabaStr.BABACMD_removeBricksHave, a)
),
commands.registerCommand("lcpr.removeQidFromGroup", (node) =>
BABA.sendNotification(BabaStr.BABACMD_removeQidFromGroup, node)
),
Expand Down

0 comments on commit fc9b88c

Please sign in to comment.