From efc43a6a50d3b317adaddcd7e593f18b55b47d91 Mon Sep 17 00:00:00 2001 From: buqiyuan <1743369777@qq.com> Date: Thu, 4 Aug 2022 16:30:27 +0800 Subject: [PATCH] fix: request body code real time --- .../pages/api/group/tree/api-group-tree.component.ts | 3 ++- .../pages/api/test/body/api-test-body.component.ts | 4 ++-- .../monaco-editor/monaco-editor.component.ts | 12 ++++++++---- .../params-import/params-import.component.html | 4 ++-- .../components/params-import/params-import.module.ts | 4 ++-- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/workbench/browser/src/app/pages/api/group/tree/api-group-tree.component.ts b/src/workbench/browser/src/app/pages/api/group/tree/api-group-tree.component.ts index c508c4b28..35b18cfdb 100644 --- a/src/workbench/browser/src/app/pages/api/group/tree/api-group-tree.component.ts +++ b/src/workbench/browser/src/app/pages/api/group/tree/api-group-tree.component.ts @@ -312,6 +312,7 @@ export class ApiGroupTreeComponent implements OnInit, OnDestroy { const groupApiData: GroupApiDataModel = { group: [], api: [] }; if (children?.length) { const targetIndex = children.findIndex((n) => n.key === dragNode.key); + if (targetIndex === dragNode.origin.weight) { return; } @@ -340,7 +341,7 @@ export class ApiGroupTreeComponent implements OnInit, OnDestroy { this.updateoperateApiEvent(groupApiData); } - replaceGroupKey(key: string) { + private replaceGroupKey(key: string) { return Number(key.replace('group-', '')); } /** diff --git a/src/workbench/browser/src/app/pages/api/test/body/api-test-body.component.ts b/src/workbench/browser/src/app/pages/api/test/body/api-test-body.component.ts index 3e07f2c73..a7611eff7 100644 --- a/src/workbench/browser/src/app/pages/api/test/body/api-test-body.component.ts +++ b/src/workbench/browser/src/app/pages/api/test/body/api-test-body.component.ts @@ -67,8 +67,8 @@ export class ApiTestBodyComponent implements OnInit, OnChanges, AfterViewInit, O this.beforeChangeBodyByType(val[0]); }); this.initListConf(); - this.rawChange$.pipe(debounceTime(300), takeUntil(this.destroy$)).subscribe(() => { - this.modelChange.emit(this.model); + this.rawChange$.pipe(debounceTime(400), takeUntil(this.destroy$)).subscribe((code) => { + this.modelChange.emit(code); }); } diff --git a/src/workbench/browser/src/app/shared/components/monaco-editor/monaco-editor.component.ts b/src/workbench/browser/src/app/shared/components/monaco-editor/monaco-editor.component.ts index 222973add..3d3f6138d 100644 --- a/src/workbench/browser/src/app/shared/components/monaco-editor/monaco-editor.component.ts +++ b/src/workbench/browser/src/app/shared/components/monaco-editor/monaco-editor.component.ts @@ -193,11 +193,11 @@ export class EoMonacoEditorComponent implements AfterViewInit, OnInit, OnChanges }); this.codeEdtor.onDidChangeModelContent((e) => { - this.codeChange.emit(this.codeEdtor.getValue()); + this.handleChange(); }); this.codeEdtor.onDidBlurEditorText((e) => { - this.codeChange.emit(this.codeEdtor.getValue()); + this.handleBlur(); }); let prevHeight = 0; @@ -224,10 +224,14 @@ export class EoMonacoEditorComponent implements AfterViewInit, OnInit, OnChanges console.log('ace event', event, txt); } handleBlur() { - this.codeChange.emit(this.$$code); + Promise.resolve().then(() => { + this.codeChange.emit(this.$$code); + }); } handleChange() { - this.codeChange.emit(this.$$code); + Promise.resolve().then(() => { + this.codeChange.emit(this.$$code); + }); } rerenderEditor() { this.codeEdtor?.layout?.(); diff --git a/src/workbench/browser/src/app/shared/components/params-import/params-import.component.html b/src/workbench/browser/src/app/shared/components/params-import/params-import.component.html index 058397d7b..425be7079 100644 --- a/src/workbench/browser/src/app/shared/components/params-import/params-import.component.html +++ b/src/workbench/browser/src/app/shared/components/params-import/params-import.component.html @@ -18,8 +18,8 @@ (nzOnCancel)="handleCancel()">
Import like this:
{{ eg }}
- +
diff --git a/src/workbench/browser/src/app/shared/components/params-import/params-import.module.ts b/src/workbench/browser/src/app/shared/components/params-import/params-import.module.ts index b1b28579e..b501ff2a1 100644 --- a/src/workbench/browser/src/app/shared/components/params-import/params-import.module.ts +++ b/src/workbench/browser/src/app/shared/components/params-import/params-import.module.ts @@ -3,7 +3,7 @@ import { FormsModule } from '@angular/forms'; import { ParamsImportComponent } from './params-import.component'; -import { EouiModule } from '../../../eoui/eoui.module'; +import { SharedModule } from 'eo/workbench/browser/src/app/shared/shared.module'; import { NzDropDownModule } from 'ng-zorro-antd/dropdown'; import { NzModalModule } from 'ng-zorro-antd/modal'; @@ -12,7 +12,7 @@ import { EoIconparkIconModule } from 'eo/workbench/browser/src/app/eoui/iconpark @NgModule({ declarations: [ParamsImportComponent], - imports: [FormsModule, EoIconparkIconModule, NzDropDownModule, NzModalModule, NzButtonModule, EouiModule], + imports: [FormsModule, EoIconparkIconModule, NzDropDownModule, NzModalModule, NzButtonModule, SharedModule], exports: [ParamsImportComponent], schemas: [CUSTOM_ELEMENTS_SCHEMA], })