956*_*6MB 2 notifications visual-studio-code vscode-extensions
是否可以在 Visual Studio Code 中向用户显示您的扩展或颜色主题通知?对于安装了我的颜色主题或扩展并正在获取更新的人,我希望可能在他们更新扩展后向此人显示通知(可能是在 VSCode 启动时,或者在他们进入市场更新后)重新加载扩展和客户端本身。)
例如:我认为,如果他们在更新扩展程序后看到一条通知,上面写着“反馈?建议?修复?......关于主题?”,这对我来说是有益的,而不是侵入性的。或者通知他们主题发生了可能不利的变化。因此,如果他们愿意,他们可以“选择退出”该更改(例如某物周围的一组额外边框或某物的颜色变化。)
显然,关闭所有通知的人不会受到影响,但我认为在罕见的更新后偶尔收到通知也不会太糟糕。我无法找到有关这是否可能的信息,如果可能的话,如何做到这一点。任何有关这方面的信息都将受到赞赏。如果可能的话,那些阅读本文的人,无论您是否已经这样做,您是否会建议以这种方式向您的主题用户显示通知?
谢谢 :)
每当您的扩展程序更新时,都会在右下角显示通知。您还可以控制仅在主要/次要版本中显示它。
\n\n将以下代码添加到extension.ts:
import { window, ExtensionContext, extensions, env, Uri } from "vscode";\n\nconst extensionId = "jerrygoyal.shortcut-menu-bar";\n\n// this method is called when your extension is activated\nexport function activate(context: ExtensionContext) {\n showWhatsNew(context); // show notification in case of a major release i.e. 1.0.0 -> 2.0.0\n}\n\n// https://stackoverflow.com/a/66303259/3073272\nfunction isMajorUpdate(previousVersion: string, currentVersion: string) {\n // rain-check for malformed string\n if (previousVersion.indexOf(".") === -1) {\n return true;\n }\n //returns int array [1,1,1] i.e. [major,minor,patch]\n var previousVerArr = previousVersion.split(".").map(Number);\n var currentVerArr = currentVersion.split(".").map(Number);\n\n if (currentVerArr[0] > previousVerArr[0]) {\n return true;\n } else {\n return false;\n }\n}\n\nasync function showWhatsNew(context: ExtensionContext) {\n const previousVersion = context.globalState.get<string>(extensionId);\n const currentVersion = extensions.getExtension(extensionId)!.packageJSON\n .version;\n\n // store latest version\n context.globalState.update(extensionId, currentVersion);\n\n if (\n previousVersion === undefined ||\n isMajorUpdate(previousVersion, currentVersion)\n ) {\n // show whats new notificatin:\n const actions = [{ title: "See how" }];\n\n const result = await window.showInformationMessage(\n `Shortcut Menubar v${currentVersion} \xe2\x80\x94 Add your own buttons!`,\n ...actions\n );\n\n if (result !== null) {\n if (result === actions[0]) {\n await env.openExternal(\n Uri.parse(\n "https://github.com/GorvGoyl/Shortcut-Menu-Bar-VSCode-Extension#create-buttons-with-custom-commands"\n )\n );\n }\n }\n }\n}\n\nRun Code Online (Sandbox Code Playgroud)\n您可以在我的 VSCode 扩展存储库快捷菜单栏中看到此实现
\n| 归档时间: |
|
| 查看次数: |
1046 次 |
| 最近记录: |