Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions packages/extension/src/browser/vscode/contributes/icon.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Autowired, Injectable } from '@opensumi/di';
import { StaticResourceService } from '@opensumi/ide-core-browser/lib/static-resource/static.definition';
import { ILogger, LifeCyclePhase, URI, localize, path } from '@opensumi/ide-core-common';
import { IIconService, IThemeContribution } from '@opensumi/ide-theme';
import { IIconService, IProductIconService, IThemeContribution } from '@opensumi/ide-theme';
import { getIconRegistry } from '@opensumi/ide-theme/lib/common/icon-registry';

import { Contributes, LifeCycle, VSCodeContributePoint } from '../../../common';
Expand Down Expand Up @@ -58,14 +58,14 @@ export class IconsContributionPoint extends VSCodeContributePoint<IconSchema> {
@Autowired(AbstractExtInstanceManagementService)
protected readonly extensionManageService: AbstractExtInstanceManagementService;

@Autowired(IProductIconService)
protected readonly productIconService: IProductIconService;

@Autowired()
private readonly staticResourceService: StaticResourceService;

@Autowired(IIconService)
protected readonly iconService: IIconService;

@Autowired(ILogger)
logger: ILogger;
private logger: ILogger;

private iconRegistry = getIconRegistry();

Expand Down Expand Up @@ -114,5 +114,6 @@ export class IconsContributionPoint extends VSCodeContributePoint<IconSchema> {
}
});
}
this.productIconService.updateProductIconThemes();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { AbstractExtInstanceManagementService } from '../../types';

export type ThemesSchema = Array<IThemeContribution>;

// TODO 需等待 monaco-colors 初始化完成 才能注册
@Injectable()
@Contributes('productIconThemes')
@LifeCycle(LifeCyclePhase.Initialize)
Expand Down
7 changes: 5 additions & 2 deletions packages/theme/src/browser/product-icon.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ export class ProductIconService extends WithEventBus implements IProductIconServ
@OnEvent(ExtensionDidContributes)
async onDidExtensionContributes() {
await this.updateProductIconThemes();
this.productIconThemeLoaded.resolve();
}

get preferenceThemeId(): string | undefined {
Expand All @@ -133,7 +132,10 @@ export class ProductIconService extends WithEventBus implements IProductIconServ
return this.currentTheme;
}

private async updateProductIconThemes() {
/**
* 初始化注册默认主题
*/
public async updateProductIconThemes() {
const themeMap = this.getAvailableThemeInfos().reduce((pre: Map<string, string>, cur: IconThemeInfo) => {
if (!pre.has(cur.themeId)) {
pre.set(cur.themeId, cur.name);
Expand All @@ -153,6 +155,7 @@ export class ProductIconService extends WithEventBus implements IProductIconServ
await this.applyTheme(this.preferenceThemeId);
}
}
this.productIconThemeLoaded.resolve();
}

async applyTheme(themeId: string): Promise<void> {
Expand Down
9 changes: 0 additions & 9 deletions packages/theme/src/browser/theme.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ export class ThemeContribution implements MenuContribution, CommandContribution,

async initialize() {
this.registerDefaultColorTheme();
this.registerDefaultProductIconTheme();

this.registerDefaultTokenStyles();
this.registerDefaultTokenType();
Expand All @@ -88,14 +87,6 @@ export class ThemeContribution implements MenuContribution, CommandContribution,
}
}

private registerDefaultProductIconTheme() {
const themeId = this.preferenceService.get<string>(GeneralSettingsId.ProductIconTheme);
const shouldApplyDefaultThemeId = !themeId;
if (shouldApplyDefaultThemeId) {
this.productIconService.applyTheme(DEFAULT_PRODUCT_ICON_THEME_ID);
}
}

private registerDefaultTokenModifier() {
this.semanticTokenRegistry.registerTokenModifier(
'declaration',
Expand Down
4 changes: 3 additions & 1 deletion packages/theme/src/common/theme.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IRawThemeSetting } from 'vscode-textmate';

import { Deferred, Event, IDisposable, IThemeColor, URI } from '@opensumi/ide-core-common';
import { Deferred, Event, IDisposable, IThemeColor, MaybePromise, URI } from '@opensumi/ide-core-common';

import { Color } from './color';
import { hc_black, hc_light, vs, vs_dark } from './default-themes';
Expand Down Expand Up @@ -146,6 +146,8 @@ export interface IThemeService {
export interface IProductIconService {
currentThemeId: string;
currentTheme: IProductIconTheme;
productIconThemeLoaded: Deferred<void>;
updateProductIconThemes(): MaybePromise<void>;
onDidProductIconThemeChange: Event<IProductIconTheme>;
applyTheme(themeId: string): Promise<void>;
registerProductIconThemes(productIconThemesContribution: IThemeContribution[], extPath: URI): void;
Expand Down