From 3992a79241ed567c4d080a5c4e685c5564fbb448 Mon Sep 17 00:00:00 2001 From: scarqin <1054139596@qq.com> Date: Mon, 15 Aug 2022 17:55:08 +0800 Subject: [PATCH] feat: lazyload & fix base64 script tips error --- .../src/app/pages/api/api-routing.module.ts | 12 +++----- .../browser/src/app/pages/api/api.module.ts | 2 -- .../app/pages/api/detail/api-detail.module.ts | 27 +++++++++++++++-- .../src/app/pages/api/edit/api-edit.module.ts | 7 +++++ .../src/app/pages/api/mock/api-mock.module.ts | 30 +++++++++++++++++++ .../src/app/pages/api/test/api-test.module.ts | 7 +++++ .../shared/components/api-script/constant.ts | 30 +++++++++---------- .../services/storage/storage.service.ts | 2 +- 8 files changed, 89 insertions(+), 28 deletions(-) create mode 100644 src/workbench/browser/src/app/pages/api/mock/api-mock.module.ts diff --git a/src/workbench/browser/src/app/pages/api/api-routing.module.ts b/src/workbench/browser/src/app/pages/api/api-routing.module.ts index c28cc24ce..1dd16dbb5 100644 --- a/src/workbench/browser/src/app/pages/api/api-routing.module.ts +++ b/src/workbench/browser/src/app/pages/api/api-routing.module.ts @@ -2,11 +2,7 @@ import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { ApiComponent } from './api.component'; -import { ApiDetailComponent } from './detail/api-detail.component'; -import { ApiEditComponent } from './edit/api-edit.component'; import { ApiOverviewComponent } from './overview/api-overview.component'; -import { ApiTestComponent } from './test/api-test.component'; -import { ApiMockComponent } from './mock/api-mock.component'; const routes: Routes = [ { @@ -24,19 +20,19 @@ const routes: Routes = [ }, { path: 'detail', - component: ApiDetailComponent, + loadChildren: () => import('./detail/api-detail.module').then((m) => m.ApiDetailModule), }, { path: 'edit', - component: ApiEditComponent, + loadChildren: () => import('./edit/api-edit.module').then((m) => m.ApiEditModule), }, { path: 'test', - component: ApiTestComponent, + loadChildren: () => import('./test/api-test.module').then((m) => m.ApiTestModule), }, { path: 'mock', - component: ApiMockComponent, + loadChildren: () => import('./mock/api-mock.module').then((m) => m.ApiMockModule), }, ], }, diff --git a/src/workbench/browser/src/app/pages/api/api.module.ts b/src/workbench/browser/src/app/pages/api/api.module.ts index 0334bcba1..f280735c8 100644 --- a/src/workbench/browser/src/app/pages/api/api.module.ts +++ b/src/workbench/browser/src/app/pages/api/api.module.ts @@ -40,7 +40,6 @@ import { ApiService } from './api.service'; import { ElectronService } from '../../core/services'; import { ApiOverviewComponent } from './overview/api-overview.component'; import { HistoryComponent } from './history/eo-history.component'; -import { ApiMockComponent } from './mock/api-mock.component'; import { IndexedDBStorage } from 'eo/workbench/browser/src/app/shared/services/storage/IndexedDB/lib/'; import { SharedModule } from 'eo/workbench/browser/src/app/shared/shared.module'; import { ApiTabStorageService } from 'eo/workbench/browser/src/app/pages/api/tab/api-tab-storage.service'; @@ -57,7 +56,6 @@ const COMPONENTS = [ ApiOverviewComponent, ImportApiComponent, ExtensionSelectComponent, - ApiMockComponent, HistoryComponent, ]; @NgModule({ diff --git a/src/workbench/browser/src/app/pages/api/detail/api-detail.module.ts b/src/workbench/browser/src/app/pages/api/detail/api-detail.module.ts index e15e560fe..258b0bdc8 100644 --- a/src/workbench/browser/src/app/pages/api/detail/api-detail.module.ts +++ b/src/workbench/browser/src/app/pages/api/detail/api-detail.module.ts @@ -22,8 +22,17 @@ import { ApiDetailMockComponent } from './mock/api-detail-mock.component'; import { ApiDetailUtilService } from './api-detail-util.service'; import { NzCollapseModule } from 'ng-zorro-antd/collapse'; +import { RouterModule } from '@angular/router'; -const NZ_COMPONETS = [NzButtonModule, NzCollapseModule,NzIconModule, NzTagModule, NzModalModule, NzFormModule, NzToolTipModule]; +const NZ_COMPONETS = [ + NzButtonModule, + NzCollapseModule, + NzIconModule, + NzTagModule, + NzModalModule, + NzFormModule, + NzToolTipModule, +]; const COMPONENTS = [ ApiDetailComponent, ApiDetailHeaderComponent, @@ -34,7 +43,21 @@ const COMPONENTS = [ ]; @NgModule({ declarations: [...COMPONENTS], - imports: [FormsModule, ReactiveFormsModule, Ng1Module, CommonModule, ...NZ_COMPONETS, EouiModule, SharedModule], + imports: [ + RouterModule.forChild([ + { + path: '', + component: ApiDetailComponent, + }, + ]), + FormsModule, + ReactiveFormsModule, + Ng1Module, + CommonModule, + ...NZ_COMPONETS, + EouiModule, + SharedModule, + ], providers: [ApiDetailUtilService], }) export class ApiDetailModule {} diff --git a/src/workbench/browser/src/app/pages/api/edit/api-edit.module.ts b/src/workbench/browser/src/app/pages/api/edit/api-edit.module.ts index 57574aaf1..8c30b454b 100644 --- a/src/workbench/browser/src/app/pages/api/edit/api-edit.module.ts +++ b/src/workbench/browser/src/app/pages/api/edit/api-edit.module.ts @@ -31,6 +31,7 @@ import { ApiParamsExtraSettingComponent } from './extra-setting/api-params-extra import { ApiEditUtilService } from './api-edit-util.service'; import { ApiEditService } from 'eo/workbench/browser/src/app/pages/api/edit/api-edit.service'; +import { RouterModule } from '@angular/router'; const NZ_COMPONETS = [ NzDropDownModule, @@ -59,6 +60,12 @@ const COMPONENTS = [ @NgModule({ declarations: [...COMPONENTS], imports: [ + RouterModule.forChild([ + { + path: '', + component: ApiEditComponent, + }, + ]), FormsModule, ReactiveFormsModule, Ng1Module, diff --git a/src/workbench/browser/src/app/pages/api/mock/api-mock.module.ts b/src/workbench/browser/src/app/pages/api/mock/api-mock.module.ts new file mode 100644 index 000000000..a99097852 --- /dev/null +++ b/src/workbench/browser/src/app/pages/api/mock/api-mock.module.ts @@ -0,0 +1,30 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { ApiMockComponent } from './api-mock.component'; +import { SharedModule } from 'eo/workbench/browser/src/app/shared/shared.module'; +import { NzFormModule } from 'ng-zorro-antd/form'; +import { NzInputModule } from 'ng-zorro-antd/input'; +import { FormsModule } from '@angular/forms'; +import { NzModalModule } from 'ng-zorro-antd/modal'; +import { EouiModule } from 'eo/workbench/browser/src/app/eoui/eoui.module'; +import { RouterModule } from '@angular/router'; + +@NgModule({ + declarations: [ApiMockComponent], + imports: [ + RouterModule.forChild([ + { + path: '', + component: ApiMockComponent, + }, + ]), + CommonModule, + SharedModule, + NzFormModule, + NzInputModule, + FormsModule, + NzModalModule, + EouiModule, + ], +}) +export class ApiMockModule {} diff --git a/src/workbench/browser/src/app/pages/api/test/api-test.module.ts b/src/workbench/browser/src/app/pages/api/test/api-test.module.ts index f0554b67e..e8be75fb3 100644 --- a/src/workbench/browser/src/app/pages/api/test/api-test.module.ts +++ b/src/workbench/browser/src/app/pages/api/test/api-test.module.ts @@ -43,6 +43,7 @@ import { ApiTestResultResponseComponent } from './result-response/api-test-resul import { ApiTestResultRequestBodyComponent } from './result-request-body/api-test-result-request-body.component'; import { TestServerRemoteService } from 'eo/workbench/browser/src/app/shared/services/api-test/remote-node/test-connect.service'; import { NzUploadModule } from 'ng-zorro-antd/upload'; +import { RouterModule, Routes } from '@angular/router'; const NZ_COMPONETS = [ NzDropDownModule, NzModalModule, @@ -76,6 +77,12 @@ const COMPONENTS = [ @NgModule({ declarations: [...COMPONENTS, ByteToStringPipe], imports: [ + RouterModule.forChild([ + { + path: '', + component: ApiTestComponent, + }, + ]), FormsModule, ReactiveFormsModule, Ng1Module, diff --git a/src/workbench/browser/src/app/shared/components/api-script/constant.ts b/src/workbench/browser/src/app/shared/components/api-script/constant.ts index b222d2e58..c9625cb05 100644 --- a/src/workbench/browser/src/app/shared/components/api-script/constant.ts +++ b/src/workbench/browser/src/app/shared/components/api-script/constant.ts @@ -211,10 +211,10 @@ const COMMON_DATA: TreeNode[] = [ }, { name: $localize`JSON Decode`, - caption: 'json.decode', - value: 'json.decode(json)', + caption: 'eo.json.decode', + value: 'eo.json.decode(json)', note: { - code: 'json.decode(json)', + code: 'eo.json.decode(json)', desc: $localize`JSON Decode`, input: [{ key: 'json', value: $localize`JSON string` }], output: $localize`JSON object`, @@ -222,10 +222,10 @@ const COMMON_DATA: TreeNode[] = [ }, { name: $localize`XML Encode`, - caption: 'xml.encode', - value: 'xml.encode(xml_object)', + caption: 'eo.xml.encode', + value: 'eo.xml.encode(xml_object)', note: { - code: 'xml.encode(xml_object)', + code: 'eo.xml.encode(xml_object)', desc: $localize`XML Encode`, input: [{ key: 'xml_object', value: $localize`XML object` }], output: $localize`XML string`, @@ -233,10 +233,10 @@ const COMMON_DATA: TreeNode[] = [ }, { name: $localize`XML Decode`, - caption: 'xml.decode', - value: 'xml.decode(xml)', + caption: 'eo.xml.decode', + value: 'eo.xml.decode(xml)', note: { - code: 'xml.decode(xml)', + code: 'eo.xml.decode(xml)', desc: $localize`XML Decode`, input: [{ key: 'xml', value: $localize`XML string` }], output: $localize`XML code`, @@ -244,10 +244,10 @@ const COMMON_DATA: TreeNode[] = [ }, { name: $localize`Base64 Encode`, - caption: 'base64.encode', - value: 'base64.encode(data)', + caption: 'eo.base64.encode', + value: 'eo.base64.encode(data)', note: { - code: 'base64.encode(data)', + code: 'eo.base64.encode(data)', desc: $localize`Base64 Encode`, input: [{ key: 'data', value: $localize`string of wait for encode` }], output: $localize`string after encode`, @@ -255,10 +255,10 @@ const COMMON_DATA: TreeNode[] = [ }, { name: $localize`Base64 Decode`, - caption: 'base64.decode', - value: 'base64.decode(data)', + caption: 'eo.base64.decode', + value: 'eo.base64.decode(data)', note: { - code: 'base64.decode(data)', + code: 'eo.base64.decode(data)', desc: $localize`Base64 Decode`, input: [{ key: 'data', value: $localize`string of wait for decode` }], output: $localize`string after decode`, diff --git a/src/workbench/browser/src/app/shared/services/storage/storage.service.ts b/src/workbench/browser/src/app/shared/services/storage/storage.service.ts index 85ab3af04..eb3759daa 100644 --- a/src/workbench/browser/src/app/shared/services/storage/storage.service.ts +++ b/src/workbench/browser/src/app/shared/services/storage/storage.service.ts @@ -39,7 +39,7 @@ export class StorageService { data: undefined, callback, }; - console.log('this.instance', this.instance, action); + // console.log('this.instance', this.instance, action); if (!this.instance[action]) { throw Error(`Lack request API: ${action}`); }