Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit42512f8

Browse files
committed
delete cache after switch the endpoint
1 parentb9cea44 commit42512f8

File tree

6 files changed

+28
-1
lines changed

6 files changed

+28
-1
lines changed

‎package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@
4040
"main":"./out/src/extension",
4141
"contributes": {
4242
"commands": [
43+
{
44+
"command":"leetcode.deleteCache",
45+
"title":"Delete cache",
46+
"category":"LeetCode"
47+
},
4348
{
4449
"command":"leetcode.toogleLeetCodeCn",
4550
"title":"Switch endpoint",

‎src/commands/cache.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
"use strict";
2+
3+
import{leetCodeExecutor}from"../leetCodeExecutor";
4+
import{DialogType,promptForOpenOutputChannel}from"../utils/uiUtils";
5+
6+
exportasyncfunctiondeleteCache():Promise<void>{
7+
try{
8+
awaitleetCodeExecutor.deleteCache();
9+
}catch(error){
10+
awaitpromptForOpenOutputChannel("Failed to delete cache. Please open the output channel for details.",DialogType.error);
11+
}
12+
}

‎src/commands/plugin.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export async function toogleLeetCodeCn(): Promise<void> {
4040

4141
try{
4242
awaitvscode.commands.executeCommand("leetcode.signout");
43+
awaitvscode.commands.executeCommand("leetcode.deleteCache");
4344
awaitpromptForSignIn();
4445
}catch(error){
4546
awaitpromptForOpenOutputChannel("Failed to sign in. Please open the output channel for details.",DialogType.error);

‎src/extension.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use strict";
22

33
import*asvscodefrom"vscode";
4+
import*ascachefrom"./commands/cache";
45
import*aspluginfrom"./commands/plugin";
56
import*assessionfrom"./commands/session";
67
import*asshowfrom"./commands/show";
@@ -21,6 +22,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
2122

2223
context.subscriptions.push(
2324
vscode.window.registerTreeDataProvider("leetCodeExplorer",leetCodeTreeDataProvider),
25+
vscode.commands.registerCommand("leetcode.deleteCache",()=>cache.deleteCache()),
2426
vscode.commands.registerCommand("leetcode.toogleLeetCodeCn",()=>plugin.toogleLeetCodeCn()),
2527
vscode.commands.registerCommand("leetcode.signin",()=>leetCodeManager.signIn()),
2628
vscode.commands.registerCommand("leetcode.signout",()=>leetCodeManager.signOut()),

‎src/leetCodeExecutor.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ export interface ILeetCodeExecutor {
1212
meetRequirements():Promise<boolean>;
1313
getLeetCodeBinaryPath():Promise<string>;
1414

15+
/* section for cache command */
16+
deleteCache():Promise<string>;
17+
1518
/* section for user command */
1619
getUserInfo():Promise<string>;
1720
signOut():Promise<string>;
@@ -70,6 +73,10 @@ class LeetCodeExecutor implements ILeetCodeExecutor {
7073
}
7174
}
7275

76+
publicasyncdeleteCache():Promise<string>{
77+
returnawaitthis.executeCommandEx("node",[awaitthis.getLeetCodeBinaryPath(),"cache","-d"]);
78+
}
79+
7380
publicasyncgetUserInfo():Promise<string>{
7481
returnawaitthis.executeCommandEx("node",[awaitthis.getLeetCodeBinaryPath(),"user"]);
7582
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp