fixed:update extensions metadata,delay notification prompt.

This commit is contained in:
chriswang521 2024-05-16 14:39:00 +08:00 committed by wangpenglong
parent 8a5a41462f
commit 983c10edab
3 changed files with 58 additions and 26 deletions

View File

@ -6997,7 +6997,8 @@
"postUpdateTooltip": "请重新启动 Kylin-Code 以完成对此插件的更新。",
"singleDependentError": "无法单独禁用 \"{0}\" 插件。\"{1}\" 插件依赖于此插件。要禁用所有这些插件吗?",
"twoDependentsError": "无法单独禁用 \"{0}\" 插件。\"{1}\" 和 \"{2}\" 插件依赖于此插件。要禁用所有这些插件吗?",
"uninstallingExtension": "正在卸载插件..."
"uninstallingExtension": "正在卸载插件...",
"changedServiceUrlError": "网络请求错误,请检查网络或者配置的插件商店地址是否正确。"
},
"vs/workbench/contrib/extensions/browser/fileBasedRecommendations": {
"fileBasedRecommendation": "根据你最近打开的文件,建议使用此插件。",

View File

@ -11,6 +11,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
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 { debounce } from 'vs/base/common/decorators';
// import { IHostService } from 'vs/workbench/services/host/browser/host';
export class ExtensionsGalleryConfigService implements IExtensionsGalleryConfigService {
@ -59,29 +60,37 @@ export class ExtensionsGalleryConfigService implements IExtensionsGalleryConfigS
// 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())
// ]
// }
// });
// }
this.showMessage();
}
}
//notification
@debounce(2000)
showMessage() {
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

@ -508,7 +508,8 @@ class Extensions extends Disposable {
const extensions = await this.mapInstalledExtensionWithCompatibleGalleryExtension(galleryExtensions);
for (const [extension, gallery] of extensions) {
// update metadata of the extension if it does not exist
if (extension.local && !extension.local.identifier.uuid) {
// and exist,but not same --kylinIDETeam add
if (extension.local && (!extension.local.identifier.uuid || extension.local.identifier.uuid !== extension.gallery?.identifier.uuid)) {
extension.local = await this.updateMetadata(extension.local, gallery);
}
if (!extension.gallery || extension.gallery.version !== gallery.version || extension.gallery.properties.targetPlatform !== gallery.properties.targetPlatform) {
@ -849,7 +850,7 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension
private initializeAutoUpdate(): void {
// Register listeners for auto updates
this._register(this.configurationService.onDidChangeConfiguration(e => {
this._register(this.configurationService.onDidChangeConfiguration(async e => {
if (e.affectsConfiguration(AutoUpdateConfigurationKey)) {
this.onDidAutoUpdateConfigurationChange();
}
@ -858,6 +859,25 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension
this.checkForUpdates();
}
}
if (e.affectsConfiguration('extensionsGallery.serviceUrl')) {
try {
await this.checkForUpdates();
} catch (error) {
this.notificationService.error(nls.localize('changedServiceUrlError', 'Network request failed or Configuration extensionsGallery serviceUrl Error.Please check network or reconfiguration serviceUrl.'));
throw error;
}
// this.notificationService.prompt(Severity.Warning, nls.localize('changedServiceUrlSuccess', 'checkForUpdate extensions Successfully,need restart IDE'),
// [
// {
// label: nls.localize('restartIde', 'Restart IDE'),
// run: async () => {
// this.hostService.restart();
// }
// }
// ], {
// onCancel: () => { }
// });
}
}));
this._register(this.extensionEnablementService.onEnablementChanged(platformExtensions => {
if (this.getAutoUpdateValue() === 'onlyEnabledExtensions' && platformExtensions.some(e => this.extensionEnablementService.isEnabled(e))) {
@ -1364,6 +1384,7 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension
// Skip checking updates for a builtin extension if it is a system extension or if it does not has Marketplace identifier
continue;
}
this.logService.debug('wpl checkForUpdates installed:' + installed.name);
infos.push({ ...installed.identifier, preRelease: !!installed.local?.preRelease });
}
if (infos.length) {
@ -1381,6 +1402,7 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension
});
const galleryExtensions = await this.galleryService.getExtensions(infos, { targetPlatform, compatible: true }, CancellationToken.None);
if (galleryExtensions.length) {
this.logService.debug('wpl galleryService.getExtensions:' + galleryExtensions.length);
await this.syncInstalledExtensionsWithGallery(galleryExtensions);
}
}