Skip to content

Commit ac1e0f6

Browse files
author
guqiankun
committed
feat: 增加空白页以及欢迎页自定义
1 parent a4ea4c2 commit ac1e0f6

3 files changed

Lines changed: 21 additions & 3 deletions

File tree

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
import { Domain, ComponentContribution, ComponentRegistry } from '@opensumi/ide-core-browser';
2+
import { RuntimeConfig } from '../../common';
23
import { EditorEmptyComponent } from './editor-empty.view';
4+
import { Autowired } from '@opensumi/di';
35

46
@Domain(ComponentContribution)
57
export class EditorEmptyContribution implements ComponentContribution {
8+
@Autowired(RuntimeConfig)
9+
runtimeConfig: RuntimeConfig;
10+
611
registerComponent(registry: ComponentRegistry) {
12+
const editorEmpty = this.runtimeConfig.EditorEmpty;
13+
714
registry.register('editor-empty', {
815
id: 'editor-empty',
9-
component: EditorEmptyComponent,
16+
component: editorEmpty ? editorEmpty : EditorEmptyComponent,
1017
});
1118
}
1219
}

packages/core/src/client/welcome/welcome.contributon.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,10 @@ export class WelcomeContribution implements BrowserEditorContribution {
4545
commandService: CommandService;
4646

4747
registerEditorComponent(registry: EditorComponentRegistry) {
48+
const welcomePage = this.runtimeConfig.WelcomePage;
4849
registry.registerEditorComponent({
4950
uid: 'welcome',
50-
component: EditorWelcomeComponent,
51+
component: welcomePage ? welcomePage : EditorWelcomeComponent,
5152
renderMode: EditorComponentRenderMode.ONE_PER_WORKBENCH,
5253
});
5354

@@ -67,7 +68,9 @@ export class WelcomeContribution implements BrowserEditorContribution {
6768
return {
6869
uri,
6970
name: localize('menu.help.welcome'),
70-
icon: `${iconClass} ${styles.tabIcon}`,
71+
icon: this.runtimeConfig.WelcomePage
72+
? `${styles.tabIcon}`
73+
: `${iconClass} ${styles.tabIcon}`,
7174
};
7275
},
7376
});

packages/core/src/common/types.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,14 @@ export interface RuntimeConfig {
172172
options: FileSearchOptions
173173
): ProviderResult<string[]>;
174174
};
175+
/**
176+
* 欢迎页自定义内容
177+
*/
178+
WelcomePage?: React.FC;
179+
/**
180+
* 空白页自定义内容
181+
*/
182+
EditorEmpty?: React.FC;
175183
}
176184

177185
export type SearchMode = Boolean | 'local';

0 commit comments

Comments
 (0)