diff --git a/src/workbench/browser/src/app/pages/api/history/eo-history.component.ts b/src/workbench/browser/src/app/pages/api/history/eo-history.component.ts index 5d162f0ae..726a6f500 100644 --- a/src/workbench/browser/src/app/pages/api/history/eo-history.component.ts +++ b/src/workbench/browser/src/app/pages/api/history/eo-history.component.ts @@ -35,7 +35,11 @@ export class HistoryComponent implements OnInit { } gotoTestHistory(data) { - this.message.send({ type: 'gotoApiTest', data }); + // this.message.send({ type: 'gotoApiTest', data }); + this.message.send({ + type: 'gotoApiTest', + data: { ...data, origin: { method: data.request.method.toUpperCase(), title: '测试历史' } }, + }); } clearAllHistory() { diff --git a/src/workbench/browser/src/app/pages/api/tab/api-tab.component.ts b/src/workbench/browser/src/app/pages/api/tab/api-tab.component.ts index 049979b65..ee8b21d24 100644 --- a/src/workbench/browser/src/app/pages/api/tab/api-tab.component.ts +++ b/src/workbench/browser/src/app/pages/api/tab/api-tab.component.ts @@ -234,10 +234,17 @@ export class ApiTabComponent implements OnInit, OnDestroy { this.appendOrSwitchTab('detail', inArg.data.origin); break; case 'detailOverview': { - console.log(inArg.data.origin); + // console.log(inArg.data.origin); this.appendOrSwitchTab('overview', inArg.data.origin); break; } + case 'gotoApiTest': + this.appendOrSwitchTab('test', inArg.data.origin); + // ! It is bad way for delay render detail of api history. + setTimeout(() => { + this.messageService.send({ type: 'renderHistory', data: inArg.data }); + }, 20); + break; case 'gotoEditApi': this.appendOrSwitchTab('edit', inArg.data.origin); break; diff --git a/src/workbench/browser/src/app/pages/api/tab/api-tab.service.ts b/src/workbench/browser/src/app/pages/api/tab/api-tab.service.ts index 6fee96248..fd6ae396b 100644 --- a/src/workbench/browser/src/app/pages/api/tab/api-tab.service.ts +++ b/src/workbench/browser/src/app/pages/api/tab/api-tab.service.ts @@ -4,7 +4,7 @@ import { AppModule } from '../../../app.module'; import { TabItem } from './tab.model'; @Injectable({ - providedIn:AppModule + providedIn: AppModule, }) export class ApiTabService { tabs: Array = []; @@ -30,13 +30,15 @@ export class ApiTabService { this.tabCache[inData.tab.uuid] = inData.data; } removeData(tabID) { - if (!this.tabCache.hasOwnProperty(tabID)) return; + if (!this.tabCache.hasOwnProperty(tabID)) { + return; + } delete this.tabCache[tabID]; } - destroy(){ + destroy() { this.saveTabData$.complete(); this.tabChange$.complete(); - this.tabs=[]; - this.tabCache={}; + this.tabs = []; + this.tabCache = {}; } } diff --git a/src/workbench/browser/src/app/pages/api/test/api-test.component.ts b/src/workbench/browser/src/app/pages/api/test/api-test.component.ts index 95df1004b..d568586cf 100644 --- a/src/workbench/browser/src/app/pages/api/test/api-test.component.ts +++ b/src/workbench/browser/src/app/pages/api/test/api-test.component.ts @@ -135,7 +135,7 @@ export class ApiTestComponent implements OnInit, OnDestroy { this.watchTabChange(); this.watchEnvChange(); this.messageService.get().subscribe(({ type, data }) => { - if (type === 'gotoApiTest') { + if (type === 'renderHistory') { this.restoreHistory(data); } });