Skip to content

Commit

Permalink
允许点击状态栏临时关闭或开启防沉迷检测
Browse files Browse the repository at this point in the history
  • Loading branch information
qxchuckle committed Sep 7, 2023
1 parent 9cc747d commit 5af0ce7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@
{
"command": "cec-ide.resetSensitiveWordsFile",
"title": "CEC-ResetSensitiveWordsFile"
},
{
"command": "cec-ide.antiAddictionRemind",
"title": "临时开启或关闭防沉迷检测"
}
],
"menus": {
Expand Down
19 changes: 16 additions & 3 deletions src/adolescentMode/AdolescentStatusBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,21 @@ class AdolescentStatusBar {
}

private statusBarInit() {
// this.statusBar.command = '';
this.statusBar.command = 'cec-ide.antiAddictionRemind';
this.statusBar.text = '';
this.statusBar.tooltip = '今日编辑器使用时间';
this.statusBar.tooltip = '点击临时关闭防沉迷检测';
this.statusBar.show();
this._context.subscriptions.push(vscode.commands.registerCommand('cec-ide.antiAddictionRemind', () => {
this.antiAddictionRemind = !this.antiAddictionRemind;
if(this.antiAddictionRemind){
this.formatActiveTime();
vscode.window.showInformationMessage('已开启防沉迷提醒');
this.statusBar.tooltip = '点击临时关闭防沉迷检测';
}else{
vscode.window.showInformationMessage('已临时关闭防沉迷检测');
this.statusBar.tooltip = '点击开启防沉迷检测';
}
}));
}

private timeInit() {
Expand All @@ -43,7 +54,7 @@ class AdolescentStatusBar {
private intervalInit() {
this.timer = setInterval(() => {
this.updateStatus();
}, 60 * 1000);
}, 3000);
}

private updateStatus() {
Expand Down Expand Up @@ -75,6 +86,8 @@ class AdolescentStatusBar {
vscode.commands.executeCommand('workbench.action.closeWindow');
} else if (selectedAction === antiAddictionAction) {
this.antiAddictionRemind = false;
vscode.window.showInformationMessage('已临时关闭防沉迷检测');
this.statusBar.tooltip = '点击开启防沉迷检测';
}
});
}
Expand Down

0 comments on commit 5af0ce7

Please sign in to comment.