Skip to content

Commit

Permalink
fix: api test long text response blank
Browse files Browse the repository at this point in the history
  • Loading branch information
scarqin committed Apr 21, 2022
1 parent 028b8cc commit e481d90
Show file tree
Hide file tree
Showing 11 changed files with 88 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export class ApiDetailComponent implements OnInit {
}
getApiByUuid(id: number) {
this.storage.run('apiDataLoad', [id], (result: StorageHandleResult) => {
console.log(result,id)
if (result.status === StorageHandleStatus.success) {
['requestBody', 'responseBody'].forEach((tableName) => {
if (['xml', 'json'].includes(result.data[`${tableName}Type`])) {
Expand Down
49 changes: 29 additions & 20 deletions src/workbench/browser/src/app/pages/api/edit/api-edit.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,25 @@ import { debounceTime, take, takeUntil, pairwise, filter } from 'rxjs/operators'
import { MessageService } from '../../../shared/services/message';
import { StorageService } from '../../../shared/services/storage';

import { Group, ApiData, RequestProtocol, RequestMethod, ApiEditRest, StorageHandleResult, StorageHandleStatus } from '../../../../../../../platform/browser/IndexedDB';
import {
Group,
ApiData,
RequestProtocol,
RequestMethod,
ApiEditRest,
StorageHandleResult,
StorageHandleStatus,
} from '../../../../../../../platform/browser/IndexedDB';
import { ApiTabService } from '../tab/api-tab.service';

import { objectToArray } from '../../../utils';
import { getRest } from '../../../utils/api';
import { treeToListHasLevel, listToTree, listToTreeHasLevel, getExpandGroupByKey } from '../../../utils/tree/tree.utils';
import {
treeToListHasLevel,
listToTree,
listToTreeHasLevel,
getExpandGroupByKey,
} from '../../../utils/tree/tree.utils';
import { ApiParamsNumPipe } from '../../../shared/pipes/api-param-num.pipe';
@Component({
selector: 'eo-api-edit-edit',
Expand Down Expand Up @@ -68,7 +81,8 @@ export class ApiEditComponent implements OnInit, OnDestroy {
});
treeItems.sort((a, b) => a.weight - b.weight);
}
listToTree(treeItems, this.groups, '-1');
listToTree(treeItems, this.groups, '0');
console.log(treeItems, this.groups);
this.afterInitGroup();
});
}
Expand Down Expand Up @@ -230,7 +244,7 @@ export class ApiEditComponent implements OnInit, OnDestroy {
* Expand Select Group
*/
private expandGroup() {
this.expandKeys=getExpandGroupByKey(this.apiGroup,this.apiData.groupID.toString())
this.expandKeys = getExpandGroupByKey(this.apiGroup, this.apiData.groupID.toString());
}
/**
* Init basic form,such as url,protocol,method
Expand All @@ -257,24 +271,19 @@ export class ApiEditComponent implements OnInit, OnDestroy {
}

private editApi(formData) {
if (formData.uuid) {
this.storage.run('apiDataUpdate', [formData, this.apiData.uuid], (result: StorageHandleResult) => {
const busEvent = formData.uuid ? 'editApi' : 'addApi';
const title = busEvent === 'editApi' ? '编辑成功' : '新增成功';
this.storage.run(
busEvent === 'editApi' ? 'apiDataUpdate' : 'apiDataCreate',
[formData, this.apiData.uuid],
(result: StorageHandleResult) => {
if (result.status === StorageHandleStatus.success) {
this.message.success('编辑成功');
this.messageService.send({ type: 'editApi', data: result.data });
this.message.success(title);
this.messageService.send({ type: `${busEvent}Success`, data: result.data });
} else {
this.message.success('编辑失败');
this.message.success('失败');
}
});
} else {
this.storage.run('apiDataCreate', [formData], (result: StorageHandleResult) => {
if (result.status === StorageHandleStatus.success) {
this.message.success('新增成功');
this.messageService.send({ type: 'addApi', data: result.data });
} else {
this.message.success('新增失败');
}
});
}
}
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
border-bottom-color: var(--MAIN_BG);
.ant-tabs-tab-btn {
color: var(--MAIN_TEXT);
text-shadow: none;
}
}
.ant-tabs-tab-btn {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ export class ApiTestComponent implements OnInit, OnDestroy {
* Receive Test Server Message
*/
private receiveMessage(message) {
console.log(message)
let tmpHistory = {
general: message.general,
request: message.report.request,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
<div class="eo_navbar f_row f_js_ac">
<img class="logo" src="assets/images/logo.svg" />
<div class="can_be_click f_row_ac right_btn_container">
<div class="mr10" *ngIf="!isElectron">
<span nz-dropdown [nzDropdownMenu]="download">
<i nz-icon nzType="cloud-download" nzTheme="outline"></i>
</span>
<nz-dropdown-menu #download="nzDropdownMenu">
<ul nz-menu nzSelectable>
<ng-container *ngFor="let item of resourceInfo; let index = index">
<a [href]="item.link" nz-menu-item>{{ item.name }}</a>
<li nz-menu-divider *ngIf="index !== resourceInfo.length - 1"></li>
</ng-container>
</ul>
</nz-dropdown-menu>
</div>
<!-- <span (click)="openApp(item.moduleID)" *ngFor="let item of getModules()" >&nbsp;{{ item.moduleName }}&nbsp;</span> -->
<span class="help mr10" nz-dropdown (nzVisibleChange)="changeHelpVisible($event)" [nzDropdownMenu]="menu">
<span class="mr10" nz-dropdown (nzVisibleChange)="changeHelpVisible($event)" [nzDropdownMenu]="menu">
<i nz-icon nzType="question-circle" nzTheme="outline"></i>
</span>
<nz-dropdown-menu #menu="nzDropdownMenu">
<ul nz-menu nzSelectable>
<li nz-menu-divider></li>
<a href="https://eoapi.io/" target="_blank" nz-menu-item>产品文档</a>
<li nz-menu-divider></li>
<a href="https://github.com/eolinker/eoapi/issues/new" target="_blank" nz-menu-item>问题反馈</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@
width: 120px;
margin-left: 10px;
}
.help {
display: flex;
font-size: 22px;
cursor: pointer;
}
.tips_wrap {
position: relative;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { ElectronService } from '../../../core/services';
import { ModuleInfo } from '../../../../../../../platform/node/extension-manager';
import { ModuleInfo } from '../../../../../../../platform/node/extension-manager';
@Component({
selector: 'eo-navbar',
templateUrl: './navbar.component.html',
Expand All @@ -11,9 +11,40 @@ export class NavbarComponent implements OnInit {
isElectron: boolean = false;
OS_TYPE = navigator.platform.toLowerCase();
modules: Map<string, ModuleInfo>;
resourceInfo = [
{
id: 'win',
name: 'Windows 客户端',
icon: 'windows',
keyword: 'Setup',
suffix: 'exe',
link: '',
},
{
id: 'mac',
name: 'macOS 客户端',
icon: 'mac',
suffix: 'dmg',
link: '',
},
];

constructor(private electron: ElectronService) {
this.isElectron = this.electron.isElectron;
console.log(this.electron.ipcRenderer)
}
getInstaller() {
fetch('https://api.github.com/repos/eolinker/eoapi/releases')
.then((response) => response.json())
.then((data) => {
this.resourceInfo.forEach((item) => {
let assetItem = data[0].assets.find(
(asset) =>
asset.browser_download_url.slice(-item.suffix.length) === item.suffix &&
(!item.keyword || asset.browser_download_url.includes(item.keyword))
);
item.link = assetItem.browser_download_url;
});
});
}
changeHelpVisible(visible) {
window.eo.toogleViewZIndex(visible);
Expand Down Expand Up @@ -47,6 +78,6 @@ export class NavbarComponent implements OnInit {
}

openApp(moduleID: string) {
window.eo.openApp({moduleID: moduleID});
window.eo.openApp({ moduleID: moduleID });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class SidebarComponent implements OnInit, OnDestroy {
destroy = false;
isElectron: boolean = false;
moduleID: string = '@eo-core-apimanger';
modules: Array<ModuleInfo|any>;
modules: Array<ModuleInfo | any>;
constructor(private electron: ElectronService, private sidebar: SidebarService) {
this.isElectron = this.electron.isElectron;
this.isCollapsed = this.sidebar.getCollapsed();
Expand All @@ -40,15 +40,16 @@ export class SidebarComponent implements OnInit, OnDestroy {
}

ngOnInit(): void {
let defaultModule = { moduleName: 'API', moduleID: '@eo-core-apimanger', logo: 'icon-api', route: 'home/api/test' };
if (this.isElectron) {
// TODO change app to blank page
this.modules =[{ moduleName: 'API', moduleID: '@eo-core-apimanger', logo: 'icon-api',route:'home/api/test' },...Array.from(window.eo.getSideModuleList())]
this.modules = [defaultModule, ...Array.from(window.eo.getSideModuleList())];
this.electron.ipcRenderer.on('moduleUpdate', (event, args) => {
console.log('get moduleUpdate');
this.modules = window.eo.getSideModuleList();
});
} else {
this.modules =[];
this.modules = [defaultModule];
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/workbench/browser/src/assets/theme/antd.less
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,6 @@ p {
background-color: @theme-color;
color: #fff;
}
.ant-tabs-tab-btn{
text-shadow: none;
}
2 changes: 1 addition & 1 deletion src/workbench/browser/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8" />
<title>EOAPI</title>
<title>Eoapi</title>
<base href="/" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/x-icon" href="assets/icons/icon.ico" />
Expand Down
1 change: 1 addition & 0 deletions src/workbench/browser/src/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ body {
overflow-y: scroll;
}
}

1 comment on commit e481d90

@vercel
Copy link

@vercel vercel bot commented on e481d90 Apr 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

eoapi-test-main – ./

eoapi-test-main-git-main-eolinker.vercel.app
eoapi-test-main.vercel.app
eoapi-test-main-eolinker.vercel.app

Please sign in to comment.