帮助菜单增加插件依赖管理器和离线插件管理器入口菜单.

This commit is contained in:
wangpenglong 2023-04-18 11:22:32 +08:00 committed by chriswang521
parent 0d2aea1f11
commit 61f98eb0db
3 changed files with 53 additions and 3 deletions

View File

@ -2775,7 +2775,9 @@
"openTipsAndTricksUrl": "提示与技巧",
"openTwitterUrl": "在 Twitter 上和我们互动",
"openUserVoiceUrl": "搜索功能请求",
"openVideoTutorialsUrl": "视频教程"
"openVideoTutorialsUrl": "视频教程",
"miOpenExtensionDependency": "打开插件依赖管理器",
"miOpenOfflineExtensionsManager": "打开离线插件管理器"
},
"vs/workbench/browser/actions/layoutActions": {
"active": "活动",

View File

@ -9,12 +9,13 @@ import { isMacintosh, isLinux, language } from 'vs/base/common/platform';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IOpenerService } from 'vs/platform/opener/common/opener';
import { URI } from 'vs/base/common/uri';
import { MenuId, Action2, registerAction2 } from 'vs/platform/actions/common/actions';
import { MenuId, Action2, registerAction2, MenuRegistry } from 'vs/platform/actions/common/actions';
import { KeyChord, KeyMod, KeyCode } from 'vs/base/common/keyCodes';
import { IProductService } from 'vs/platform/product/common/productService';
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { CATEGORIES } from 'vs/workbench/common/actions';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
class KeybindingsReferenceAction extends Action2 {
@ -353,3 +354,26 @@ if (OpenLicenseUrlAction.AVAILABLE) {
if (OpenPrivacyStatementUrlAction.AVAILABE) {
registerAction2(OpenPrivacyStatementUrlAction);
}
// --- Menu Registration
MenuRegistry.appendMenuItem(MenuId.MenubarHelpMenu, {
group: '6_open',
command: {
id: 'InstDep.detail',
title: localize({ key: 'miOpenExtensionDependency', comment: ['&& denotes a mnemonic'] }, "&&Open Extension Dependency")
},
order: 1,
when: ContextKeyExpr.has('hasExtDependency'),
});
MenuRegistry.appendMenuItem(MenuId.MenubarHelpMenu, {
group: '6_open',
command: {
id: 'extensions.manager.open',
title: localize({ key: 'miOpenOfflineExtensionsManager', comment: ['&& denotes a mnemonic'] }, "&&Open Offline Extensions Manager")
},
order: 2,
when: ContextKeyExpr.has('hasOfflineExtManager'),
});

View File

@ -14,7 +14,7 @@ import { Context as SuggestContext } from 'vs/editor/contrib/suggest/browser/sug
import * as nls from 'vs/nls';
import { Action2, MenuId, MenuRegistry, registerAction2 } from 'vs/platform/actions/common/actions';
import { CommandsRegistry, ICommandService } from 'vs/platform/commands/common/commands';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { ContextKeyExpr, IContextKey, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
import { InputFocusedContext, IsMacNativeContext } from 'vs/platform/contextkey/common/contextkeys';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
@ -60,6 +60,10 @@ const SETTINGS_EDITOR_COMMAND_FILTER_UNTRUSTED = 'settings.filterUntrusted';
const SETTINGS_COMMAND_OPEN_SETTINGS = 'workbench.action.openSettings';
const HasInstalledExtDependencyExtensionContext = new RawContextKey<boolean>('hasExtDependency', false); //by wpl
const HasInstalledOfflineExtManagerExtensionContext = new RawContextKey<boolean>('hasOfflineExtManager', false); //by wpl
Registry.as<IEditorPaneRegistry>(EditorExtensions.EditorPane).registerEditorPane(
EditorPaneDescriptor.create(
SettingsEditor2,
@ -137,12 +141,16 @@ function sanitizeOpenSettingsArgs(args: any): IOpenSettingsActionOptions {
class PreferencesActionsContribution extends Disposable implements IWorkbenchContribution {
private HasInstalledExtDependencyExtensionContextKey: IContextKey<boolean>;
private HasInstalledOfflineExtManagerExtensionContextKey: IContextKey<boolean>;
constructor(
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService,
@IPreferencesService private readonly preferencesService: IPreferencesService,
@IWorkspaceContextService private readonly workspaceContextService: IWorkspaceContextService,
@ILabelService private readonly labelService: ILabelService,
@IExtensionService private readonly extensionService: IExtensionService,
@IContextKeyService contextKeyService: IContextKeyService,
) {
super();
@ -152,6 +160,22 @@ class PreferencesActionsContribution extends Disposable implements IWorkbenchCon
this.updatePreferencesEditorMenuItem();
this._register(workspaceContextService.onDidChangeWorkbenchState(() => this.updatePreferencesEditorMenuItem()));
this._register(workspaceContextService.onDidChangeWorkspaceFolders(() => this.updatePreferencesEditorMenuItemForWorkspaceFolders()));
this.HasInstalledExtDependencyExtensionContextKey = HasInstalledExtDependencyExtensionContext.bindTo(contextKeyService);
this.HasInstalledOfflineExtManagerExtensionContextKey = HasInstalledOfflineExtManagerExtensionContext.bindTo(contextKeyService);
this.checkallextension();
}
//check extension
private async checkallextension() {
const runningExtensions = await this.extensionService.getExtensions();
for (let extension of runningExtensions) {
if (extension.identifier.value === 'KylinIDETeam.extension-dependency') {
this.HasInstalledExtDependencyExtensionContextKey.set(true);
} else if (extension.identifier.value === 'KylinIDETeam.offline-extensions-manager') {
this.HasInstalledOfflineExtManagerExtensionContextKey.set(true);
}
}
}
private registerSettingsActions() {