From c99a164d53b953d9c98a53df25e295b86a90d291 Mon Sep 17 00:00:00 2001 From: "guqiankun.gqk" Date: Mon, 5 Sep 2022 16:15:20 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E6=AC=A2=E8=BF=8E?= =?UTF-8?q?=E9=A1=B5=E4=BB=A5=E5=8F=8A=E7=A9=BA=E7=99=BD=E9=A1=B5=E7=A4=BA?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + src/main.tsx | 5 ++- src/module/Startup.module.ts | 68 +++++++++++++++++++++++++++++++++ src/module/editorEmpty.view.tsx | 7 ++++ src/module/welcome.view.less | 4 ++ src/module/welcome.view.tsx | 8 ++++ src/plugins/alex-app.plugin.ts | 8 ---- tsconfig.json | 1 + 8 files changed, 92 insertions(+), 10 deletions(-) create mode 100644 src/module/Startup.module.ts create mode 100644 src/module/editorEmpty.view.tsx create mode 100644 src/module/welcome.view.less create mode 100644 src/module/welcome.view.tsx diff --git a/.gitignore b/.gitignore index 3c3629e..a31eedb 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules +.DS_store \ No newline at end of file diff --git a/src/main.tsx b/src/main.tsx index 7aad200..87feea0 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -29,6 +29,7 @@ import webSCM from './extensions/alex-ext-public.web-scm.js'; import * as SCMPlugin from './plugins/web-scm.plugin'; import * as AlexApp from './plugins/alex-app.plugin'; +import { StartupModule } from './module/Startup.module' const CodeServiceModule = requireModule( '@alipay/alex-code-service' @@ -99,11 +100,11 @@ const App = () => ( gitlink: { // webpack 代理转发 endpoint: '/code-service', - // origin: 'https://testforgeplus.trustie.net' + // endpoint: 'https://testforgeplus.trustie.net' }, }), CodeAPIModule, - // StartupModule, + StartupModule, ], extensionMetadata: [ css, diff --git a/src/module/Startup.module.ts b/src/module/Startup.module.ts new file mode 100644 index 0000000..90e2228 --- /dev/null +++ b/src/module/Startup.module.ts @@ -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 => { + 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]; +} diff --git a/src/module/editorEmpty.view.tsx b/src/module/editorEmpty.view.tsx new file mode 100644 index 0000000..aee937f --- /dev/null +++ b/src/module/editorEmpty.view.tsx @@ -0,0 +1,7 @@ +export const EditorEmptyComponent = () => { + return ( +
+ test empty page +
+ ); +}; \ No newline at end of file diff --git a/src/module/welcome.view.less b/src/module/welcome.view.less new file mode 100644 index 0000000..7b5dbba --- /dev/null +++ b/src/module/welcome.view.less @@ -0,0 +1,4 @@ +.icon-background { + width: 50px !important; + background-color: #ccc !important; +} \ No newline at end of file diff --git a/src/module/welcome.view.tsx b/src/module/welcome.view.tsx new file mode 100644 index 0000000..21c0243 --- /dev/null +++ b/src/module/welcome.view.tsx @@ -0,0 +1,8 @@ +import './welcome.view.less' +export const EditorWelcomeComponent = () => { + return ( +
+ test welcome page +
+ ); +}; \ No newline at end of file diff --git a/src/plugins/alex-app.plugin.ts b/src/plugins/alex-app.plugin.ts index b846a79..6949b54 100644 --- a/src/plugins/alex-app.plugin.ts +++ b/src/plugins/alex-app.plugin.ts @@ -16,14 +16,6 @@ export const activate = ({ commands }: IPluginAPI) => { } ); - // scm 插件使用 英文 en-us - // TODO alex内暴露命令 - commands.registerCommand( - 'alex.env.language', - () => { - return 'zh-cn' - } - ), commands.registerCommand( "code-service.replace-browser-url-hash", diff --git a/tsconfig.json b/tsconfig.json index a256c86..088d642 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "experimentalDecorators": true, "target": "ES2020", "jsx": "react-jsx", "strict": true,