Skip to content

Commit

Permalink
fix: create defualt mock when import new api
Browse files Browse the repository at this point in the history
  • Loading branch information
buqiyuan committed Aug 10, 2022
1 parent 7fdb906 commit f93c424
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { NzTreeComponent } from 'ng-zorro-antd/tree';
import { ModalService } from '../../../../shared/services/modal.service';
import { StorageService } from '../../../../shared/services/storage';
import { ElectronService } from '../../../../core/services';
import { IndexedDBStorage } from 'eo/workbench/browser/src/app/shared/services/storage/IndexedDB/lib/';
import { createMockObj, IndexedDBStorage } from 'eo/workbench/browser/src/app/shared/services/storage/IndexedDB/lib/';
import { ApiService } from 'eo/workbench/browser/src/app/pages/api/api.service';
@Component({
selector: 'eo-api-group-tree',
Expand Down Expand Up @@ -166,7 +166,11 @@ export class ApiGroupTreeComponent implements OnInit, OnDestroy {
async createGroup({ name, projectID, content }) {
const groupID = await this.storageInstance.group.add({ name: name.replace(/\.json$/, ''), projectID });
const result = content.apiData.map((it, index) => ({ ...it, groupID, uuid: Date.now() + index }));
await this.storageInstance.apiData.bulkAdd(result);
const apiDataKeys = await this.storageInstance.apiData.bulkAdd(result, { allKeys: true });
const apiData = result.map((n, i) =>
createMockObj(n, { name: $localize`Default Mock`, createWay: 'system', apiDataID: apiDataKeys.at(i) })
);
this.storageInstance.mock.bulkAdd(apiData);
this.buildGroupTreeData();
}

Expand Down

0 comments on commit f93c424

Please sign in to comment.