diff --git a/src/leetCodeExecutor.ts b/src/leetCodeExecutor.ts index d2332c7a..03f8d3e6 100644 --- a/src/leetCodeExecutor.ts +++ b/src/leetCodeExecutor.ts @@ -5,7 +5,7 @@ import * as cp from "child_process"; import * as fse from "fs-extra"; import * as os from "os"; import * as path from "path"; -import * as requireFromString from "require-from-string"; +import requireFromString from "require-from-string"; import { ExtensionContext } from "vscode"; import { ConfigurationChangeEvent, Disposable, MessageItem, window, workspace, WorkspaceConfiguration } from "vscode"; import { Endpoint, IProblem, leetcodeHasInited, supportedPlugins } from "./shared"; diff --git a/src/shared.ts b/src/shared.ts index e8b59d89..b4c1c48d 100644 --- a/src/shared.ts +++ b/src/shared.ts @@ -125,7 +125,29 @@ export enum SortingStrategy { export const PREMIUM_URL_CN = "https://leetcode.cn/premium-payment/?source=vscode"; export const PREMIUM_URL_GLOBAL = "https://leetcode.com/subscribe/?ref=lp_pl&source=vscode"; -const protocol = vscode.env.appName.includes('Insiders') ? "vscode-insiders" : "vscode" +// 检测当前编辑器环境并返回对应的协议和扩展标识 +const getEditorInfo = () => { + const appName = vscode.env.appName; + if (appName.includes('Cursor')) { + return { + protocol: "cursor", + extensionId: "leetcode.vscode-leetcode" // Cursor 兼容 VSCode 扩展标识 + }; + } else if (appName.includes('Insiders')) { + return { + protocol: "vscode-insiders", + extensionId: "leetcode.vscode-leetcode" + }; + } else { + return { + protocol: "vscode", + extensionId: "leetcode.vscode-leetcode" + }; + } +}; + +const editorInfo = getEditorInfo(); +const protocol = editorInfo.protocol; export const urls = { // base urls @@ -133,7 +155,7 @@ export const urls = { graphql: "https://leetcode.com/graphql", userGraphql: "https://leetcode.com/graphql", login: "https://leetcode.com/accounts/login/", - authLoginUrl: `https://leetcode.com/authorize-login/${protocol}/?path=leetcode.vscode-leetcode`, + authLoginUrl: `https://leetcode.com/authorize-login/${protocol}/?path=${editorInfo.extensionId}`, }; export const urlsCn = { @@ -142,7 +164,7 @@ export const urlsCn = { graphql: "https://leetcode.cn/graphql", userGraphql: "https://leetcode.cn/graphql/", login: "https://leetcode.cn/accounts/login/", - authLoginUrl: `https://leetcode.cn/authorize-login/${protocol}/?path=leetcode.vscode-leetcode`, + authLoginUrl: `https://leetcode.cn/authorize-login/${protocol}/?path=${editorInfo.extensionId}`, }; export const getUrl = (key: string) => { diff --git a/src/webview/markdownEngine.ts b/src/webview/markdownEngine.ts index 4c1db65b..7282dfee 100644 --- a/src/webview/markdownEngine.ts +++ b/src/webview/markdownEngine.ts @@ -2,7 +2,7 @@ // Licensed under the MIT license. import * as hljs from "highlight.js"; -import * as MarkdownIt from "markdown-it"; +import MarkdownIt from "markdown-it"; import * as os from "os"; import * as path from "path"; import * as vscode from "vscode"; diff --git a/tsconfig.json b/tsconfig.json index 7bded852..46859205 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,7 +13,10 @@ "noImplicitReturns": true, "strictNullChecks": true, "noUnusedParameters": true, - "alwaysStrict": true + "alwaysStrict": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "skipLibCheck": true }, "exclude": [ "node_modules",