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

Commit92d48db

Browse files
committed
clear cache when switch endpoint
1 parent42512f8 commit92d48db

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

‎src/commands/plugin.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
"use strict";
22

3+
import*asfsefrom"fs-extra";
4+
import*asosfrom"os";
5+
import*aspathfrom"path";
36
import*asvscodefrom"vscode";
47
import{leetCodeExecutor}from"../leetCodeExecutor";
58
import{IQuickItemEx}from"../shared";
69
import{Endpoint}from"../shared";
710
import{DialogType,promptForOpenOutputChannel,promptForSignIn}from"../utils/uiUtils";
11+
import{deleteCache}from"./cache";
812

913
exportasyncfunctiontoogleLeetCodeCn():Promise<void>{
1014
constisCnEnbaled:boolean=isLeetCodeCnEnabled();
@@ -40,15 +44,20 @@ export async function toogleLeetCodeCn(): Promise<void> {
4044

4145
try{
4246
awaitvscode.commands.executeCommand("leetcode.signout");
43-
awaitvscode.commands.executeCommand("leetcode.deleteCache");
47+
awaitdeleteCache();
4448
awaitpromptForSignIn();
4549
}catch(error){
4650
awaitpromptForOpenOutputChannel("Failed to sign in. Please open the output channel for details.",DialogType.error);
4751
}
4852
}
4953

5054
exportasyncfunctioninitializeEndpoint():Promise<void>{
51-
awaitleetCodeExecutor.toggleLeetCodeCn(isLeetCodeCnEnabled());
55+
constisCnEnabledInExtension:boolean=isLeetCodeCnEnabled();
56+
constisCnEnabledInCli:boolean=awaitisLeetCodeCnEnabledInCli();
57+
awaitleetCodeExecutor.toggleLeetCodeCn(isCnEnabledInExtension);
58+
if(isCnEnabledInCli!==isCnEnabledInExtension){
59+
awaitdeleteCache();
60+
}
5261
}
5362

5463
exportfunctionisLeetCodeCnEnabled():boolean{
@@ -59,3 +68,12 @@ export function isLeetCodeCnEnabled(): boolean {
5968
}
6069
returnfalse;
6170
}
71+
72+
asyncfunctionisLeetCodeCnEnabledInCli():Promise<boolean>{
73+
constpluginsStatusFile:string=path.join(os.homedir(),".lc","plugins.json");
74+
if(!awaitfse.pathExists(pluginsStatusFile)){
75+
returnfalse;
76+
}
77+
constpluginsObj:{}=awaitfse.readJson(pluginsStatusFile);
78+
returnpluginsObj["leetcode.cn"];
79+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp