diff --git a/src/app/electron-main/main.ts b/src/app/electron-main/main.ts
index fbd98fd8..678a5bd6 100644
--- a/src/app/electron-main/main.ts
+++ b/src/app/electron-main/main.ts
@@ -42,6 +42,8 @@ function createWindow(): BrowserWindow {
win = new BrowserWindow({
width: Math.round(size.width * 0.85),
height: Math.round(size.height * 0.85),
+ minWidth: 1280,
+ minHeight: 720,
useContentSize: true, // 这个要设置,不然计算显示区域尺寸不准
frame: os.type() === 'Darwin' ? true : false, //mac use default frame
webPreferences: {
diff --git a/src/workbench/browser/src/app/pages/api/group/tree/api-group-tree.component.ts b/src/workbench/browser/src/app/pages/api/group/tree/api-group-tree.component.ts
index f7c922a8..5a505b0a 100644
--- a/src/workbench/browser/src/app/pages/api/group/tree/api-group-tree.component.ts
+++ b/src/workbench/browser/src/app/pages/api/group/tree/api-group-tree.component.ts
@@ -160,30 +160,11 @@ export class ApiGroupTreeComponent implements OnInit, OnDestroy {
...(getExpandGroupByKey(this.apiGroup, this.route.snapshot.queryParams.uuid) || []),
];
}
- // 重新构建整个group
- async rebuildGroupTree(result) {
- this.storageInstance.apiData.clear();
- this.storageInstance.group.clear();
+ async createGroup({ name, projectID, content }) {
+ const groupID = await this.storageInstance.group.add({ name, projectID });
+ const result = content.apiData.map((it, index) => ({ ...it, groupID, uuid: Date.now() + index }));
await this.storageInstance.apiData.bulkAdd(result);
- const apiItems = {};
- this.treeItems = [];
- result.forEach((item: ApiData) => {
- delete item.updatedAt;
- apiItems[item.uuid] = item;
- this.treeItems.push({
- title: item.name,
- key: item.uuid.toString(),
- weight: item.weight || 0,
- parentID: item.groupID ? `group-${item.groupID}` : '0',
- method: item.method,
- isLeaf: true,
- });
- });
- this.apiDataItems = apiItems;
- this.messageService.send({ type: 'loadApi', data: this.apiDataItems });
- this.setSelectedKeys();
- this.generateGroupTreeData();
- this.restoreExpandStatus();
+ this.buildGroupTreeData();
}
/**
@@ -205,8 +186,7 @@ export class ApiGroupTreeComponent implements OnInit, OnDestroy {
break;
}
case 'importSuccess': {
- const { apiData } = JSON.parse(inArg.data);
- this.rebuildGroupTree(apiData);
+ this.createGroup({ projectID: 1, ...inArg.data });
}
}
});
@@ -349,7 +329,7 @@ export class ApiGroupTreeComponent implements OnInit, OnDestroy {
'groupBulkUpdate',
[
data.group.map((val) => {
- return { ...val, uuid: val.uuid.replace('group-',''), parentID: val.parentID.replace('group-','') };
+ return { ...val, uuid: val.uuid.replace('group-', ''), parentID: val.parentID.replace('group-', '') };
}),
],
(result: StorageRes) => {}
diff --git a/src/workbench/browser/src/app/shared/components/extension-select/extension-select.component.html b/src/workbench/browser/src/app/shared/components/extension-select/extension-select.component.html
index 67e57db5..49edc1ec 100644
--- a/src/workbench/browser/src/app/shared/components/extension-select/extension-select.component.html
+++ b/src/workbench/browser/src/app/shared/components/extension-select/extension-select.component.html
@@ -35,11 +35,12 @@
-
+
点击或直接拖拽文件至此区域
仅支持JSON格式的单个文件导入
+ {{ filename }}
diff --git a/src/workbench/browser/src/app/shared/components/extension-select/extension-select.component.ts b/src/workbench/browser/src/app/shared/components/extension-select/extension-select.component.ts
index 298dec60..8dcc83f4 100644
--- a/src/workbench/browser/src/app/shared/components/extension-select/extension-select.component.ts
+++ b/src/workbench/browser/src/app/shared/components/extension-select/extension-select.component.ts
@@ -20,6 +20,7 @@ export class ExtensionSelectComponent {
@Output() extensionChange = new EventEmitter();
@Output() currentOptionChange = new EventEmitter();
@Output() uploadChange = new EventEmitter();
+ filename = '';
selectExtension({ key, properties }) {
this.extensionChange.emit(key);
@@ -36,7 +37,8 @@ export class ExtensionSelectComponent {
parserFile = (file) =>
new Observable((observer: Observer) => {
- parserJsonFile(file).then((result) => {
+ parserJsonFile(file).then((result: { name: string }) => {
+ this.filename = result.name;
this.uploadChange.emit(result);
observer.complete();
});
diff --git a/src/workbench/browser/src/app/shared/components/import-api/import-api.component.ts b/src/workbench/browser/src/app/shared/components/import-api/import-api.component.ts
index 3e83e112..98601847 100644
--- a/src/workbench/browser/src/app/shared/components/import-api/import-api.component.ts
+++ b/src/workbench/browser/src/app/shared/components/import-api/import-api.component.ts
@@ -1,17 +1,42 @@
import { Component, OnInit } from '@angular/core';
-import { StorageRes, StorageResStatus } from 'eo/workbench/browser/src/app/shared/services/storage/index.model';
-import { EoMessageService } from 'eo/workbench/browser/src/app/eoui/message/eo-message.service';
-import { StorageService } from '../../../shared/services/storage';
import { FeatureType } from '../../types';
-import { parserProperties, getDefaultValue } from '../../../utils';
import { MessageService } from 'eo/workbench/browser/src/app/shared/services/message/message.service';
+// const optionList = [
+// {
+// value: 'import',
+// type: 'string',
+// default: '',
+// label: '直接导入',
+// description: '直接导入',
+// },
+// {
+// value: 'add',
+// type: 'string',
+// default: true,
+// label: '增量更新[推荐]',
+// description: '增量更新',
+// },
+// {
+// value: 'all',
+// type: 'string',
+// default: '',
+// label: '全量更新[慎用]',
+// description: '全量更新',
+// },
+// {
+// value: 'new',
+// type: 'string',
+// default: '',
+// label: '仅添加新 API',
+// description: '仅添加新 API',
+// },
+// ];
+
@Component({
selector: 'eo-import-api',
template: ` = [];
currentExtension = '';
- currentOption = '';
- optionList = [];
uploadData = null;
featureMap = window.eo.getFeature('apimanage.import');
- constructor(
- private storage: StorageService,
- private message: EoMessageService,
- private messageService: MessageService
- ) {}
+ constructor(private messageService: MessageService) {}
ngOnInit(): void {
this.featureMap?.forEach((data: FeatureType, key: string) => {
this.supportList.push({
@@ -37,39 +56,25 @@ export class ImportApiComponent implements OnInit {
});
});
{
- const { key, properties } = this.supportList.at(0);
+ const { key } = this.supportList.at(0);
this.currentExtension = key || '';
- this.optionList = parserProperties(properties || '');
- this.currentOption = getDefaultValue(this.optionList, 'value');
}
}
- getEoapiData() {
- return new Promise((resolve) => {
- this.storage.run('projectExport', [], (result: StorageRes) => {
- const isOk = result.status === StorageResStatus.success;
- resolve(isOk ? [result.data, null] : [null, true]);
- });
- });
- }
uploadChange(data) {
this.uploadData = data;
}
async submit(callback) {
- const [eoapiData, err]: any = await this.getEoapiData();
- if (err) {
- this.message.error('获取本地数据失败');
- return;
- }
// * this.currentExtension is extension's key, like 'eoapi-import-openapi'
const feature = this.featureMap.get(this.currentExtension);
const action = feature.action || null;
const module = window.eo.loadFeatureModule(this.currentExtension);
- const data = module[action](eoapiData, this.uploadData, this.currentOption);
+ const { name, content } = this.uploadData;
+ const data = module[action](content);
+ // console.log(JSON.stringify(data, null, 2));
this.messageService.send({
type: 'importSuccess',
- data: JSON.stringify(data),
+ data: { name, content: data },
});
- // console.log(JSON.stringify(data));
callback(true);
}
}
diff --git a/src/workbench/browser/src/app/shared/services/storage/IndexedDB/lib/index.ts b/src/workbench/browser/src/app/shared/services/storage/IndexedDB/lib/index.ts
index 29405231..68c9fd36 100644
--- a/src/workbench/browser/src/app/shared/services/storage/IndexedDB/lib/index.ts
+++ b/src/workbench/browser/src/app/shared/services/storage/IndexedDB/lib/index.ts
@@ -322,11 +322,11 @@ export class IndexedDBStorage extends Dexie implements StorageInterface {
}
apiDataLoadAllByGroupID(groupID: number | string): Observable