perf: tab select

This commit is contained in:
renqian805 2022-08-03 21:54:34 +08:00
parent 19a41fc0b0
commit 5424fecb10
3 changed files with 11 additions and 7 deletions

View File

@ -99,7 +99,7 @@
<div class="bottom_container scroll_container" bottom>
<!-- Response -->
<nz-tabset [nzTabBarStyle]="{ 'padding-left': '10px' }" [(nzSelectedIndex)]="tabIndexRes" [nzAnimated]="false"
class="mt-2.5 response_container">
class="mt-2.5 response_container" (nzSelectChange)="handleBottomTabSelect($event)">
<nz-tab i18n-nzTitle nzTitle="Response">
<eo-api-test-result-response [model]="testResult?.response"></eo-api-test-result-response>
</nz-tab>
@ -109,7 +109,8 @@
</nz-tab>
</div>
<nz-tab i18n-nzTitle nzTitle="Body" [nzForceRender]="true">
<eo-api-test-result-request-body *ngIf="tabIndexRes === 2" [model]="testResult.request?.requestBody|| ''">
<eo-api-test-result-request-body *ngIf="tabIndexRes === 2 || isRequestBodyLoaded"
[model]="testResult.request?.requestBody|| ''">
</eo-api-test-result-request-body>
</nz-tab>
<nz-tab i18n-nzTitle nzTitle="Request Headers">

View File

@ -66,6 +66,7 @@ export class ApiTestComponent implements OnInit, OnDestroy {
status: 'start' | 'testing' | 'tested' = 'start';
waitSeconds = 0;
tabIndexRes = 0;
isRequestBodyLoaded = false;
testResult: any = {
response: {},
request: {},
@ -199,6 +200,11 @@ export class ApiTestComponent implements OnInit, OnDestroy {
localStorage.setItem(API_TEST_DRAG_TOP_HEIGHT_KEY, leftEl.style.height);
}
}
handleBottomTabSelect(tab) {
if (tab.index === 2) {
this.isRequestBodyLoaded = true;
}
}
private test() {
this.scriptCache = {
beforeScript: this.beforeScript,

View File

@ -1,17 +1,14 @@
import { Component, OnInit, Input, OnChanges, AfterViewInit } from '@angular/core';
import { Component, OnInit, Input, OnChanges } from '@angular/core';
@Component({
selector: 'eo-api-test-result-request-body',
templateUrl: './api-test-result-request-body.component.html',
styleUrls: ['./api-test-result-request-body.component.scss'],
})
export class ApiTestResultRequestBodyComponent implements OnInit, OnChanges, AfterViewInit {
export class ApiTestResultRequestBodyComponent implements OnInit, OnChanges {
@Input() model: { name: string; type: string; value: string }[] | string | any;
modelType: string;
constructor() {}
ngAfterViewInit(): void {
console.log('???????');
}
ngOnInit(): void {}
ngOnChanges(changes) {