feat: 增加欢迎页以及空白页示例
This commit is contained in:
parent
9044f98741
commit
c99a164d53
|
@ -1 +1,2 @@
|
||||||
node_modules
|
node_modules
|
||||||
|
.DS_store
|
|
@ -29,6 +29,7 @@ import webSCM from './extensions/alex-ext-public.web-scm.js';
|
||||||
import * as SCMPlugin from './plugins/web-scm.plugin';
|
import * as SCMPlugin from './plugins/web-scm.plugin';
|
||||||
import * as AlexApp from './plugins/alex-app.plugin';
|
import * as AlexApp from './plugins/alex-app.plugin';
|
||||||
|
|
||||||
|
import { StartupModule } from './module/Startup.module'
|
||||||
|
|
||||||
const CodeServiceModule = requireModule(
|
const CodeServiceModule = requireModule(
|
||||||
'@alipay/alex-code-service'
|
'@alipay/alex-code-service'
|
||||||
|
@ -99,11 +100,11 @@ const App = () => (
|
||||||
gitlink: {
|
gitlink: {
|
||||||
// webpack 代理转发
|
// webpack 代理转发
|
||||||
endpoint: '/code-service',
|
endpoint: '/code-service',
|
||||||
// origin: 'https://testforgeplus.trustie.net'
|
// endpoint: 'https://testforgeplus.trustie.net'
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
CodeAPIModule,
|
CodeAPIModule,
|
||||||
// StartupModule,
|
StartupModule,
|
||||||
],
|
],
|
||||||
extensionMetadata: [
|
extensionMetadata: [
|
||||||
css,
|
css,
|
||||||
|
|
|
@ -0,0 +1,68 @@
|
||||||
|
import { requireModule } from "alex";
|
||||||
|
import { EditorEmptyComponent } from "./editorEmpty.view";
|
||||||
|
import { EditorWelcomeComponent } from "./welcome.view";
|
||||||
|
const CommonDI = requireModule("@opensumi/di");
|
||||||
|
const CoreBrowser = requireModule("@opensumi/ide-core-browser");
|
||||||
|
const Editor = requireModule("@opensumi/ide-editor");
|
||||||
|
const Theme = requireModule("@opensumi/ide-theme");
|
||||||
|
|
||||||
|
const { Injectable, Autowired } = CommonDI;
|
||||||
|
const { BrowserModule, Domain, ComponentContribution, getLanguageId , CommandContribution} = CoreBrowser;
|
||||||
|
const { BrowserEditorContribution } = Editor;
|
||||||
|
const { IIconService } = Theme;
|
||||||
|
|
||||||
|
const imageUrl =
|
||||||
|
"https://www.gitlink.org.cn/images/avatars/LaboratorySetting/1nav?t=1638344455";
|
||||||
|
|
||||||
|
@Domain(BrowserEditorContribution, ComponentContribution, CommandContribution)
|
||||||
|
export class WelcomeContribution {
|
||||||
|
@Autowired(IIconService)
|
||||||
|
iconService: any;
|
||||||
|
|
||||||
|
// 覆盖欢迎页
|
||||||
|
registerEditorComponent(registry: any) {
|
||||||
|
// 覆盖 alex 中的欢迎页
|
||||||
|
registry.registerEditorComponent({
|
||||||
|
uid: "welcome",
|
||||||
|
component: EditorWelcomeComponent,
|
||||||
|
renderMode: 3,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 覆盖空白页
|
||||||
|
registerComponent(registry: any) {
|
||||||
|
registry.register("editor-empty", {
|
||||||
|
id: "editor-empty",
|
||||||
|
component: EditorEmptyComponent,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// 覆盖资源图标
|
||||||
|
registerResource(service: any) {
|
||||||
|
service.registerResourceProvider({
|
||||||
|
scheme: "welcome",
|
||||||
|
provideResource: async (uri: any): Promise<any> => {
|
||||||
|
const iconClass = this.iconService.fromIcon("", imageUrl, "background");
|
||||||
|
return {
|
||||||
|
uri,
|
||||||
|
name: "欢迎使用",
|
||||||
|
icon: `${iconClass} icon-background`,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 注册获取语言命令 移除alex-app-plugin的同名命令
|
||||||
|
registerCommands(commands: any) {
|
||||||
|
commands.registerCommand(
|
||||||
|
{ id: 'alex.env.language' },
|
||||||
|
{
|
||||||
|
execute: () => getLanguageId(),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class StartupModule extends BrowserModule {
|
||||||
|
providers = [WelcomeContribution];
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
export const EditorEmptyComponent = () => {
|
||||||
|
return (
|
||||||
|
<div >
|
||||||
|
test empty page
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
|
@ -0,0 +1,4 @@
|
||||||
|
.icon-background {
|
||||||
|
width: 50px !important;
|
||||||
|
background-color: #ccc !important;
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
import './welcome.view.less'
|
||||||
|
export const EditorWelcomeComponent = () => {
|
||||||
|
return (
|
||||||
|
<div >
|
||||||
|
test welcome page
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
|
@ -16,14 +16,6 @@ export const activate = ({ commands }: IPluginAPI) => {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// scm 插件使用 英文 en-us
|
|
||||||
// TODO alex内暴露命令
|
|
||||||
commands.registerCommand(
|
|
||||||
'alex.env.language',
|
|
||||||
() => {
|
|
||||||
return 'zh-cn'
|
|
||||||
}
|
|
||||||
),
|
|
||||||
commands.registerCommand(
|
commands.registerCommand(
|
||||||
"code-service.replace-browser-url-hash",
|
"code-service.replace-browser-url-hash",
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
|
"experimentalDecorators": true,
|
||||||
"target": "ES2020",
|
"target": "ES2020",
|
||||||
"jsx": "react-jsx",
|
"jsx": "react-jsx",
|
||||||
"strict": true,
|
"strict": true,
|
||||||
|
|
Loading…
Reference in New Issue