插件详情页面添加显示插件的downloadUrl。

This commit is contained in:
chriswang521 2023-05-19 14:46:12 +08:00
parent 2a5901b893
commit 10cefae105
5 changed files with 19 additions and 3 deletions

View File

@ -5353,6 +5353,7 @@
"description": "说明",
"details": "细节",
"detailstooltip": "扩展详细信息,显示扩展的 \"README.md\" 文件。",
"downloadUrl": "国内下载地址",
"extension pack": "扩展包({0})",
"extension version": "扩展版本",
"extensionpack": "扩展包",

View File

@ -281,6 +281,7 @@ export interface IRelaxedExtensionManifest {
api?: string;
scripts?: { [key: string]: string };
capabilities?: IExtensionCapabilities;
downloadUrl?: string;
}
export type IExtensionManifest = Readonly<IRelaxedExtensionManifest>;

View File

@ -970,7 +970,7 @@ export class ExtensionEditor extends EditorPane {
}
}
private renderExtensionResources(container: HTMLElement, extension: IExtension): void {
private async renderExtensionResources(container: HTMLElement, extension: IExtension): Promise<void> {
const resources: [string, URI][] = [];
if (extension.url) {
resources.push([localize('Marketplace', "Marketplace"), URI.parse(extension.url)]);
@ -981,8 +981,13 @@ export class ExtensionEditor extends EditorPane {
if (extension.url && extension.licenseUrl) {
resources.push([localize('license', "License"), URI.parse(extension.licenseUrl)]);
}
if (extension.publisherUrl) {
resources.push([extension.publisherDisplayName, extension.publisherUrl]);
if (extension.downloadUrl) {
resources.push([localize('downloadUrl', "ChinaDownloadUrl"), URI.parse(extension.downloadUrl)]);
} else {
const manifest = await this.extensionManifest!.get().promise;
if (manifest && manifest.downloadUrl) {
resources.push([localize('downloadUrl', "ChinaDownloadUrl"), URI.parse(manifest.downloadUrl)]);
}
}
if (resources.length || extension.publisherSponsorLink) {
const extensionResourcesContainer = append(container, $('.resources-container.additional-details-element'));

View File

@ -407,6 +407,14 @@ ${this.description}
}
return [];
}
get downloadUrl(): string | undefined {
const { local } = this;
if (local && local.manifest.downloadUrl) {
return local.manifest.downloadUrl;
}
return undefined;
}
}
class Extensions extends Disposable {

View File

@ -81,6 +81,7 @@ export interface IExtension {
gallery?: IGalleryExtension;
readonly isMalicious: boolean;
readonly deprecationInfo?: IDeprecationInfo;
readonly downloadUrl?: string;
}
export const SERVICE_ID = 'extensionsWorkbenchService';