Skip to content

Commit

Permalink
fix: open test history
Browse files Browse the repository at this point in the history
  • Loading branch information
kungfuboy committed Jun 29, 2022
1 parent 17252e6 commit 925c118
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 7 additions & 5 deletions src/workbench/browser/src/app/pages/api/tab/api-tab.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { AppModule } from '../../../app.module';
import { TabItem } from './tab.model';

@Injectable({
providedIn:AppModule
providedIn: AppModule,
})
export class ApiTabService {
tabs: Array<TabItem> = [];
Expand All @@ -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 = {};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
Expand Down

0 comments on commit 925c118

Please sign in to comment.