fix: request body code real time

This commit is contained in:
buqiyuan 2022-08-04 16:30:27 +08:00
parent 669c8b1ac6
commit efc43a6a50
5 changed files with 16 additions and 11 deletions

View File

@ -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-', ''));
}
/**

View File

@ -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);
});
}

View File

@ -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?.();

View File

@ -18,8 +18,8 @@
(nzOnCancel)="handleCancel()">
<div *nzModalContent>
<pre class="eg" i18n>Import like this:<br />{{ eg }}</pre>
<eo-editor [(code)]="paramCode" [editorType]="contenTypeEditor" [hiddenList]="['type']"
[eventList]="['type', 'format', 'copy', 'search', 'replace']"></eo-editor>
<eo-monaco-editor [(code)]="paramCode" [editorType]="contenTypeEditor" [hiddenList]="['type']" [maxLine]="16"
[eventList]="['type', 'format', 'copy', 'search', 'replace']"></eo-monaco-editor>
</div>
<div *nzModalFooter style="text-align: left">
<button nz-button nzType="default" (click)="handleImport('mixin')" i18n>Replace Changed</button>

View File

@ -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],
})