Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c41435d

Browse files
committedJun 14, 2025
feat: Add support for Cursor editor authentication
1 parent 586b3e4 commit c41435d

File tree

4 files changed

+31
-6
lines changed

4 files changed

+31
-6
lines changed
 

‎src/leetCodeExecutor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as cp from "child_process";
55
import * as fse from "fs-extra";
66
import * as os from "os";
77
import * as path from "path";
8-
import * as requireFromString from "require-from-string";
8+
import requireFromString from "require-from-string";
99
import { ExtensionContext } from "vscode";
1010
import { ConfigurationChangeEvent, Disposable, MessageItem, window, workspace, WorkspaceConfiguration } from "vscode";
1111
import { Endpoint, IProblem, leetcodeHasInited, supportedPlugins } from "./shared";

‎src/shared.ts

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,37 @@ export enum SortingStrategy {
125125
export const PREMIUM_URL_CN = "https://leetcode.cn/premium-payment/?source=vscode";
126126
export const PREMIUM_URL_GLOBAL = "https://leetcode.com/subscribe/?ref=lp_pl&source=vscode";
127127

128-
const protocol = vscode.env.appName.includes('Insiders') ? "vscode-insiders" : "vscode"
128+
// 检测当前编辑器环境并返回对应的协议和扩展标识
129+
const getEditorInfo = () => {
130+
const appName = vscode.env.appName;
131+
if (appName.includes('Cursor')) {
132+
return {
133+
protocol: "cursor",
134+
extensionId: "leetcode.vscode-leetcode" // Cursor 兼容 VSCode 扩展标识
135+
};
136+
} else if (appName.includes('Insiders')) {
137+
return {
138+
protocol: "vscode-insiders",
139+
extensionId: "leetcode.vscode-leetcode"
140+
};
141+
} else {
142+
return {
143+
protocol: "vscode",
144+
extensionId: "leetcode.vscode-leetcode"
145+
};
146+
}
147+
};
148+
149+
const editorInfo = getEditorInfo();
150+
const protocol = editorInfo.protocol;
129151

130152
export const urls = {
131153
// base urls
132154
base: "https://leetcode.com",
133155
graphql: "https://leetcode.com/graphql",
134156
userGraphql: "https://leetcode.com/graphql",
135157
login: "https://leetcode.com/accounts/login/",
136-
authLoginUrl: `https://leetcode.com/authorize-login/${protocol}/?path=leetcode.vscode-leetcode`,
158+
authLoginUrl: `https://leetcode.com/authorize-login/${protocol}/?path=${editorInfo.extensionId}`,
137159
};
138160

139161
export const urlsCn = {
@@ -142,7 +164,7 @@ export const urlsCn = {
142164
graphql: "https://leetcode.cn/graphql",
143165
userGraphql: "https://leetcode.cn/graphql/",
144166
login: "https://leetcode.cn/accounts/login/",
145-
authLoginUrl: `https://leetcode.cn/authorize-login/${protocol}/?path=leetcode.vscode-leetcode`,
167+
authLoginUrl: `https://leetcode.cn/authorize-login/${protocol}/?path=${editorInfo.extensionId}`,
146168
};
147169

148170
export const getUrl = (key: string) => {

‎src/webview/markdownEngine.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Licensed under the MIT license.
33

44
import * as hljs from "highlight.js";
5-
import * as MarkdownIt from "markdown-it";
5+
import MarkdownIt from "markdown-it";
66
import * as os from "os";
77
import * as path from "path";
88
import * as vscode from "vscode";

‎tsconfig.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
"noImplicitReturns": true,
1414
"strictNullChecks": true,
1515
"noUnusedParameters": true,
16-
"alwaysStrict": true
16+
"alwaysStrict": true,
17+
"esModuleInterop": true,
18+
"allowSyntheticDefaultImports": true,
19+
"skipLibCheck": true
1720
},
1821
"exclude": [
1922
"node_modules",

0 commit comments

Comments
 (0)
Please sign in to comment.