feat:设置中添加插件商店地址配置选项,含有serviceUrl和itemUrl配置,功能有:

1.无需重启,直接修改;
2.添加中文显示.
3.code-server中正常使用.
4.命令行模式正常.
This commit is contained in:
chriswang521 2024-05-16 13:34:45 +08:00 committed by wangpenglong
parent 5f6482a4ad
commit 58c2fb5f52
13 changed files with 223 additions and 6 deletions

View File

@ -1975,6 +1975,14 @@
"versionSpecificity2": "\"engines.vscode\" ({0}) 中指定的版本不够具体。对于 1.0.0 之后的 vscode 版本,请至少定义主要想要的版本。例如: ^1.10.0、1.10.x、1.x.x、2.x.x 等。",
"versionSyntax": "无法解析 \"engines.vscode\" 的值 {0}。请改为如 ^1.22.0, ^1.22.x 等。"
},
"vs/platform/extensionsGallery/common/extensionsGallery.config.contribution":{
"extensionsGalleryConfigurationTitle":"插件商店地址",
"extensionsGalleryServiceUrl":"配置插件商店的服务器地址serviceUrl。例如:https://open-vsx.org/vscode/gallery",
"extensionsGalleryItemUrl":"配置插件商店的单个插件地址itemUrl。例如:https://open-vsx.org/vscode/item"
},
"vs/platform/extensionsGallery/common/extensionsGalleryConfig":{
"galleryConfigChanged":"插件商店配置地址已更改。"
},
"vs/platform/externalTerminal/node/externalTerminalService": {
"console.title": "Kylin-Code 控制台",
"ext.term.app.not.found": "找不到终端应用程序 \"{0}\"",
@ -9135,6 +9143,7 @@
"editorManagement": "编辑管理",
"experimental": "实验性",
"extensions": "插件",
"extensionsGallery":"插件商店地址",
"features": "功能",
"fileExplorer": "资源管理器",
"files": "文件",

View File

@ -29,6 +29,8 @@ import { IExtensionsProfileScannerService } from 'vs/platform/extensionManagemen
import { IExtensionsScannerService } from 'vs/platform/extensionManagement/common/extensionsScannerService';
import { ExtensionManagementService, INativeServerExtensionManagementService } from 'vs/platform/extensionManagement/node/extensionManagementService';
import { ExtensionsScannerService } from 'vs/platform/extensionManagement/node/extensionsScannerService';
import { ExtensionsGalleryConfigService } from 'vs/platform/extensionsGallery/common/extensionsGalleryConfig';
import { IExtensionsGalleryConfigService } from 'vs/platform/extensionsGallery/common/extensionsGalleryConfigService';
import { IFileService } from 'vs/platform/files/common/files';
import { FileService } from 'vs/platform/files/common/fileService';
import { DiskFileSystemProvider } from 'vs/platform/files/node/diskFileSystemProvider';
@ -200,6 +202,7 @@ class CliMain extends Disposable {
services.set(IDownloadService, new SyncDescriptor(DownloadService, undefined, true));
// Extensions
services.set(IExtensionsGalleryConfigService, new SyncDescriptor(ExtensionsGalleryConfigService, undefined, true));
services.set(IExtensionsProfileScannerService, new SyncDescriptor(ExtensionsProfileScannerService, undefined, true));
services.set(IExtensionsScannerService, new SyncDescriptor(ExtensionsScannerService, undefined, true));
services.set(IExtensionSignatureVerificationService, new SyncDescriptor(ExtensionSignatureVerificationService, undefined, true));

View File

@ -116,6 +116,10 @@ import { RemoteConnectionType } from 'vs/platform/remote/common/remoteAuthorityR
import { nodeSocketFactory } from 'vs/platform/remote/node/nodeSocketFactory';
import { NativeEnvironmentService } from 'vs/platform/environment/node/environmentService';
import { SharedProcessRawConnection, SharedProcessLifecycle } from 'vs/platform/sharedProcess/common/sharedProcess';
import { IExtensionsGalleryConfigService } from 'vs/platform/extensionsGallery/common/extensionsGalleryConfigService';
import { ExtensionsGalleryConfigService } from 'vs/platform/extensionsGallery/common/extensionsGalleryConfig';
// import { NotificationService } from 'vs/workbench/services/notification/common/notificationService';
// import { INotificationService } from 'vs/platform/notification/common/notification';
class SharedProcessMain extends Disposable implements IClientConnectionFilter {
@ -324,6 +328,9 @@ class SharedProcessMain extends Disposable implements IClientConnectionFilter {
services.set(IExtensionSignatureVerificationService, new SyncDescriptor(ExtensionSignatureVerificationService, undefined, true));
services.set(INativeServerExtensionManagementService, new SyncDescriptor(ExtensionManagementService, undefined, true));
// services.set(INotificationService, new SyncDescriptor(NotificationService, undefined, true));
services.set(IExtensionsGalleryConfigService, new SyncDescriptor(ExtensionsGalleryConfigService, undefined, true));
// Extension Gallery
services.set(IExtensionGalleryService, new SyncDescriptor(ExtensionGalleryService, undefined, true));

View File

@ -27,6 +27,7 @@ import { resolveMarketplaceHeaders } from 'vs/platform/externalServices/common/m
import { IStorageService } from 'vs/platform/storage/common/storage';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { StopWatch } from 'vs/base/common/stopwatch';
import { IExtensionsGalleryConfigService } from 'vs/platform/extensionsGallery/common/extensionsGalleryConfigService';
const CURRENT_TARGET_PLATFORM = isWeb ? TargetPlatform.WEB : getTargetPlatform(platform, arch);
const ACTIVITY_HEADER_NAME = 'X-Market-Search-Activity-Id';
@ -577,7 +578,7 @@ abstract class AbstractExtensionGalleryService implements IExtensionGalleryServi
declare readonly _serviceBrand: undefined;
private readonly extensionsGalleryUrl: string | undefined;
private extensionsGalleryUrl: string | undefined;
private readonly extensionsGallerySearchUrl: string | undefined;
private readonly extensionsControlUrl: string | undefined;
@ -592,10 +593,17 @@ abstract class AbstractExtensionGalleryService implements IExtensionGalleryServi
@IFileService private readonly fileService: IFileService,
@IProductService private readonly productService: IProductService,
@IConfigurationService private readonly configurationService: IConfigurationService,
@IExtensionsGalleryConfigService readonly extensionsGalleryConfigService: IExtensionsGalleryConfigService,
) {
const config = productService.extensionsGallery;
const isPPEEnabled = config?.servicePPEUrl && configurationService.getValue('_extensionsGallery.enablePPE');
this.extensionsGalleryUrl = isPPEEnabled ? config.servicePPEUrl : config?.serviceUrl;
if (extensionsGalleryConfigService && extensionsGalleryConfigService.serviceUrl) {
this.extensionsGalleryUrl = extensionsGalleryConfigService.serviceUrl;
} else {
this.extensionsGalleryUrl = isPPEEnabled ? config.servicePPEUrl : config?.serviceUrl;
}
this.extensionsGalleryConfigService!.onConfigChange!(this.onUpdateConfigChange, this);
this.extensionsGallerySearchUrl = isPPEEnabled ? undefined : config?.searchUrl;
this.extensionsControlUrl = config?.controlUrl;
this.commonHeadersPromise = resolveMarketplaceHeaders(
@ -608,6 +616,16 @@ abstract class AbstractExtensionGalleryService implements IExtensionGalleryServi
this.telemetryService);
}
private onUpdateConfigChange(serverURL: string) {
this.logService.info('wpl onUpdateConfigChange serverURL:' + serverURL);
if (serverURL) {
this.extensionsGalleryUrl = serverURL;
} else {
const config = this.productService.extensionsGallery;
this.extensionsGalleryUrl = config && config.serviceUrl;
}
}
private api(path = ''): string {
return `${this.extensionsGalleryUrl}${path}`;
}
@ -1263,8 +1281,9 @@ export class ExtensionGalleryService extends AbstractExtensionGalleryService {
@IFileService fileService: IFileService,
@IProductService productService: IProductService,
@IConfigurationService configurationService: IConfigurationService,
@IExtensionsGalleryConfigService extensionsGalleryConfigService: IExtensionsGalleryConfigService,
) {
super(storageService, requestService, logService, environmentService, telemetryService, fileService, productService, configurationService);
super(storageService, requestService, logService, environmentService, telemetryService, fileService, productService, configurationService, extensionsGalleryConfigService);
}
}
@ -1278,7 +1297,8 @@ export class ExtensionGalleryServiceWithNoStorageService extends AbstractExtensi
@IFileService fileService: IFileService,
@IProductService productService: IProductService,
@IConfigurationService configurationService: IConfigurationService,
@IExtensionsGalleryConfigService extensionsGalleryConfigService: IExtensionsGalleryConfigService,
) {
super(undefined, requestService, logService, environmentService, telemetryService, fileService, productService, configurationService);
super(undefined, requestService, logService, environmentService, telemetryService, fileService, productService, configurationService, extensionsGalleryConfigService);
}
}

View File

@ -0,0 +1,43 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) kylinIDETeam. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { localize } from 'vs/nls';
import { ConfigurationScope, Extensions as ConfigurationExtensions, IConfigurationRegistry } from 'vs/platform/configuration/common/configurationRegistry';
import { Registry } from 'vs/platform/registry/common/platform';
const configurationRegistry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration);
configurationRegistry.registerConfiguration({
id: 'extensionsGallery',
order: 199,
title: localize('extensionsGalleryConfigurationTitle', "extensionsGallery"),
type: 'object',
properties: {
'extensionsGallery.serviceUrl': {
type: 'string',
pattern: '^(http|https)?://([^:]*(:[^@]*)?@)?([^:]+|\\[[:0-9a-fA-F]+\\])(:\\d+)?/?$|^$',
default: '',
scope: ConfigurationScope.APPLICATION,
description: localize('extensionsGalleryServiceUrl', "Configure Extensions Gallery ServiceUrl.Sample:https://open-vsx.org/vscode/gallery"),
restricted: true
},
'extensionsGallery.itemUrl': {
type: 'string',
pattern: '^(http|https)?://([^:]*(:[^@]*)?@)?([^:]+|\\[[:0-9a-fA-F]+\\])(:\\d+)?/?$|^$',
default: '',
scope: ConfigurationScope.APPLICATION,
description: localize('extensionsGalleryItemUrl', "Configure Extensions Gallery ItemUrl.Sample:https://open-vsx.org/vscode/item"),
restricted: true,
}
},
});
export interface IExtensionsGalleryConfiguration {
// extensionsGallery?: {
serviceUrl: string;
itemUrl: string;
// }
}

View File

@ -0,0 +1,87 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) kylinIDETeam. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
// import { Action } from 'vs/base/common/actions';
// import { isWeb } from 'vs/base/common/platform';
import { localize } from 'vs/nls';
import { Emitter, Event } from 'vs/base/common/event';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IExtensionsGalleryConfiguration } from 'vs/platform/extensionsGallery/common/extensionsGallery.config.contribution';
import { IExtensionsGalleryConfigService } from 'vs/platform/extensionsGallery/common/extensionsGalleryConfigService';
import { INotificationService } from 'vs/platform/notification/common/notification';
// import { IHostService } from 'vs/workbench/services/host/browser/host';
export class ExtensionsGalleryConfigService implements IExtensionsGalleryConfigService {
declare readonly _serviceBrand: undefined;
private _serviceUrl: string = '';
private _itemUrl: string = '';
public extensionsGalleryConfiguration!: IExtensionsGalleryConfiguration;
private preExtensionsGalleryConfig: IExtensionsGalleryConfiguration;
private readonly _onConfigChange = new Emitter<string>();
readonly onConfigChange: Event<string> = this._onConfigChange.event;
constructor(
@IConfigurationService private readonly configurationService: IConfigurationService,
@INotificationService private readonly notificationService: INotificationService,
// @IHostService private readonly hostService: IHostService,
) {
this.preExtensionsGalleryConfig = this.configurationService.getValue<IExtensionsGalleryConfiguration>('extensionsGallery');
this.updateURL(this.preExtensionsGalleryConfig);
this.configurationService.onDidChangeConfiguration(() => this.configure(this.configurationService.getValue<IExtensionsGalleryConfiguration>('extensionsGallery')), this);
}
get serviceUrl(): string {
return this._serviceUrl;
}
get itemUrl(): string {
return this._itemUrl;
}
private updateURL(extensionsGalleryConfig: IExtensionsGalleryConfiguration) {
if (extensionsGalleryConfig) {
this._serviceUrl = extensionsGalleryConfig.serviceUrl;
this._itemUrl = extensionsGalleryConfig.itemUrl;
}
}
private configure(extensionsGalleryConfig: IExtensionsGalleryConfiguration) {
//不能直接使用==判断可以将内容转为json的比较必须序列一致
if (JSON.stringify(this.preExtensionsGalleryConfig) === JSON.stringify(extensionsGalleryConfig)) {
//前一次和本次修改一致,不做任何操作
} else {
this.preExtensionsGalleryConfig = extensionsGalleryConfig;
this.updateURL(extensionsGalleryConfig);
// if (extensionsGalleryConfig.serviceUrl) {
// this._serviceUrl = extensionsGalleryConfig!.serviceUrl!;
// this._itemUrl = extensionsGalleryConfig.itemUrl;
this._onConfigChange.fire(this._serviceUrl ? this._serviceUrl : '');
this.notificationService.info(localize('galleryConfigChanged', "Extensions Gallery Config Changed"));
// this.notificationService.prompt(
// Severity.Info,
// "changed testing",
// [
// {
// label: isWeb ? localize('reload', "Reload") : localize('restart', "Restart"),
// run: () => this.hostService.restart()
// }
// ]
// );
// this.notificationService.notify({
// severity: Severity.Info,
// message: "satest",
// actions: {
// primary: [
// new Action('Restart', isWeb ? localize('reload', "Reload") : localize('restart', "Restart"), undefined, true, () => this.hostService.restart())
// ]
// }
// });
// }
}
}
}

View File

@ -0,0 +1,15 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) kylinIDETeam. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Event } from 'vs/base/common/event';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
export const IExtensionsGalleryConfigService = createDecorator<IExtensionsGalleryConfigService>('extensionsGalleryConfigService');
export interface IExtensionsGalleryConfigService {
readonly serviceUrl: string;
readonly itemUrl: string;
readonly _serviceBrand: undefined;
readonly onConfigChange: Event<string>;
}

View File

@ -77,6 +77,8 @@ import { RemoteExtensionsScannerChannel, RemoteExtensionsScannerService } from '
import { RemoteExtensionsScannerChannelName } from 'vs/platform/remote/common/remoteExtensionsScanner';
import { RemoteUserDataProfilesServiceChannel } from 'vs/platform/userDataProfile/common/userDataProfileIpc';
import { NodePtyHostStarter } from 'vs/platform/terminal/node/nodePtyHostStarter';
import { IExtensionsGalleryConfigService } from 'vs/platform/extensionsGallery/common/extensionsGalleryConfigService';
import { ExtensionsGalleryConfigService } from 'vs/platform/extensionsGallery/common/extensionsGalleryConfig';
const eventPrefix = 'monacoworkbench';
@ -176,6 +178,7 @@ export async function setupServerServices(connectionToken: ServerConnectionToken
services.set(IServerTelemetryService, ServerNullTelemetryService);
}
services.set(IExtensionsGalleryConfigService, new SyncDescriptor(ExtensionsGalleryConfigService));
services.set(IExtensionGalleryService, new SyncDescriptor(ExtensionGalleryServiceWithNoStorageService));
const downloadChannel = socketServer.getChannel('download', router);

View File

@ -71,6 +71,7 @@ import { ILocaleService } from 'vs/workbench/services/localization/common/locale
import { isString } from 'vs/base/common/types';
import { showWindowLogActionId } from 'vs/workbench/services/log/common/logConstants';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IExtensionsGalleryConfigService } from 'vs/platform/extensionsGallery/common/extensionsGalleryConfigService';
export class PromptExtensionInstallFailureAction extends Action {
@ -89,6 +90,7 @@ export class PromptExtensionInstallFailureAction extends Action {
@IInstantiationService private readonly instantiationService: IInstantiationService,
@IExtensionGalleryService private readonly galleryService: IExtensionGalleryService,
@IExtensionManifestPropertiesService private readonly extensionManifestPropertiesService: IExtensionManifestPropertiesService,
@IExtensionsGalleryConfigService readonly extensionsGalleryConfigService: IExtensionsGalleryConfigService,
) {
super('extension.promptExtensionInstallFailure');
}
@ -177,6 +179,15 @@ export class PromptExtensionInstallFailureAction extends Action {
if (!this.extensionManagementServerService.localExtensionManagementServer && !this.extensionManagementServerService.remoteExtensionManagementServer) {
return undefined;
}
if (!this.productService.extensionsGallery || !(this.extensionsGalleryConfigService && this.extensionsGalleryConfigService.serviceUrl)) {
return undefined;
}
let extServiceURL: string = '';
if (this.extensionsGalleryConfigService && this.extensionsGalleryConfigService.serviceUrl) {
extServiceURL = this.extensionsGalleryConfigService.serviceUrl;
} else if (this.productService.extensionsGallery) {
extServiceURL = this.productService.extensionsGallery.serviceUrl;
}
let targetPlatform = this.extension.gallery.properties.targetPlatform;
if (targetPlatform !== TargetPlatform.UNIVERSAL && targetPlatform !== TargetPlatform.UNDEFINED && this.extensionManagementServerService.remoteExtensionManagementServer) {
try {
@ -192,7 +203,7 @@ export class PromptExtensionInstallFailureAction extends Action {
if (targetPlatform === TargetPlatform.UNKNOWN) {
return undefined;
}
return URI.parse(`${this.productService.extensionsGallery.serviceUrl}/publishers/${this.extension.publisher}/vsextensions/${this.extension.name}/${this.version}/vspackage${targetPlatform !== TargetPlatform.UNDEFINED ? `?targetPlatform=${targetPlatform}` : ''}`);
return URI.parse(`${extServiceURL}/publishers/${this.extension.publisher}/vsextensions/${this.extension.name}/${this.version}/vspackage${targetPlatform !== TargetPlatform.UNDEFINED ? `?targetPlatform=${targetPlatform}` : ''}`);
}
}

View File

@ -52,6 +52,7 @@ import { TelemetryTrustedValue } from 'vs/platform/telemetry/common/telemetryUti
import { ILifecycleService, LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';
import { IUserDataProfileService } from 'vs/workbench/services/userDataProfile/common/userDataProfile';
import { mainWindow } from 'vs/base/browser/window';
import { IExtensionsGalleryConfigService } from 'vs/platform/extensionsGallery/common/extensionsGalleryConfigService';
interface IExtensionStateProvider<T> {
(extension: Extension): T;
@ -82,7 +83,8 @@ export class Extension implements IExtension {
@ITelemetryService private readonly telemetryService: ITelemetryService,
@ILogService private readonly logService: ILogService,
@IFileService private readonly fileService: IFileService,
@IProductService private readonly productService: IProductService
@IProductService private readonly productService: IProductService,
@IExtensionsGalleryConfigService readonly extensionsGalleryConfigService: IExtensionsGalleryConfigService,
) { }
get type(): ExtensionType {
@ -165,6 +167,14 @@ export class Extension implements IExtension {
}
get url(): string | undefined {
if (this.extensionsGalleryConfigService.serviceUrl) {
if (this.extensionsGalleryConfigService.itemUrl && this.gallery) {
return `${this.extensionsGalleryConfigService.itemUrl}?itemName=${this.publisher}.${this.name}`;
} else {
this.logService.info('itemUrl undefine');
return undefined;
}
}
if (!this.productService.extensionsGallery || !this.gallery) {
return undefined;
}

View File

@ -276,6 +276,11 @@ export const tocData: ITOCEntry<string> = {
id: 'application/other',
label: localize('other', "Other"),
settings: ['application.*']
},
{
id: 'application/extensionsGallery',
label: localize('extensionsGallery', "Extensions Gallery"),
settings: ['extensionsGallery.*']
}
]
},

View File

@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import 'vs/platform/update/common/update.config.contribution';
import 'vs/platform/extensionsGallery/common/extensionsGallery.config.contribution';
import { localize } from 'vs/nls';
import { Registry } from 'vs/platform/registry/common/platform';
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';

View File

@ -119,6 +119,8 @@ import 'vs/workbench/services/userActivity/browser/userActivityBrowser';
import 'vs/workbench/services/issue/browser/issueTroubleshoot';
import { InstantiationType, registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { ExtensionsGalleryConfigService } from 'vs/platform/extensionsGallery/common/extensionsGalleryConfig';
import { IExtensionsGalleryConfigService } from 'vs/platform/extensionsGallery/common/extensionsGalleryConfigService';
import { ExtensionGalleryService } from 'vs/platform/extensionManagement/common/extensionGalleryService';
import { GlobalExtensionEnablementService } from 'vs/platform/extensionManagement/common/extensionEnablementService';
import { IExtensionGalleryService, IGlobalExtensionEnablementService } from 'vs/platform/extensionManagement/common/extensionManagement';
@ -148,6 +150,7 @@ registerSingleton(IUserDataSyncLogService, UserDataSyncLogService, Instantiation
registerSingleton(IIgnoredExtensionsManagementService, IgnoredExtensionsManagementService, InstantiationType.Delayed);
registerSingleton(IGlobalExtensionEnablementService, GlobalExtensionEnablementService, InstantiationType.Delayed);
registerSingleton(IExtensionStorageService, ExtensionStorageService, InstantiationType.Delayed);
registerSingleton(IExtensionsGalleryConfigService, ExtensionsGalleryConfigService, InstantiationType.Delayed);
registerSingleton(IExtensionGalleryService, ExtensionGalleryService, InstantiationType.Delayed);
registerSingleton(IContextViewService, ContextViewService, InstantiationType.Delayed);
registerSingleton(IListService, ListService, InstantiationType.Delayed);