Merge branch 'main' of github.com:eolinker/eoapi

This commit is contained in:
夜鹰 2022-09-14 12:02:12 +08:00
commit de69436ba0
13 changed files with 24 additions and 117 deletions

View File

@ -35,13 +35,11 @@
"@ngxs/store": "3.7.4",
"ajv": "8.11.0",
"angular": "1.8.2",
"brace": "0.11.1",
"js-beautify": "1.14.4",
"lodash-es": "4.17.21",
"markdown-it": "13.0.1",
"monaco-editor": "0.33.0",
"ng-zorro-antd": "13.3.2",
"ngx-ace-wrapper": "12.0.0",
"qs": "6.11.0",
"rxjs": "7.5.5",
"socket.io-client": "4.5.1",

View File

@ -1,50 +0,0 @@
.eo-editor {
min-height: var(--eo-editor-height, 70px);
}
.button_list {
border: 1px solid var(--BORDER);
border-top-left-radius: 3px;
border-top-right-radius: 3px;
width: 100%;
display: flex;
font-size: 12px;
align-items: center;
padding-left: 10px;
nz-select {
width: 90px;
}
.btn {
display: inline-flex;
align-items: center;
height: 30px;
padding: 10px;
cursor: pointer;
background-color: var(--MAIN_BG);
color: var(--MAIN_TEXT);
&:hover {
color: var(--BLUE_NORMAL);
}
> i {
margin: 0 5px;
}
}
}
:host ::ng-deep {
height: 100%;
& > div {
height: 100%;
}
.ace_editor {
min-height: inherit !important;
}
.ace-editor {
height: calc(100% - 52px);
min-height: inherit;
overflow: auto;
&::-webkit-scrollbar {
width: 0;
}
}
}

View File

@ -2,8 +2,6 @@ import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { AceModule, ACE_CONFIG, AceConfigInterface } from 'ngx-ace-wrapper';
import { NzTableModule } from 'ng-zorro-antd/table';
import { NzButtonModule } from 'ng-zorro-antd/button';
import { NzInputModule } from 'ng-zorro-antd/input';
@ -18,16 +16,9 @@ import { EoIconparkIconModule } from 'eo/workbench/browser/src/app/eoui/iconpark
const antdModules = [NzTableModule, NzButtonModule, NzInputModule, NzSelectModule];
const DEFAULT_ACE_CONFIG: AceConfigInterface = {};
@NgModule({
declarations: [EoTableComponent, EoMessageComponent, CellDirective],
imports: [CommonModule, FormsModule, AceModule, EoIconparkIconModule, ...antdModules],
imports: [CommonModule, FormsModule, EoIconparkIconModule, ...antdModules],
exports: [EoTableComponent, EoMessageComponent, CellDirective],
providers: [
{
provide: ACE_CONFIG,
useValue: DEFAULT_ACE_CONFIG,
},
],
})
export class EouiModule {}

View File

@ -5,20 +5,18 @@
</tr>
</thead>
<tbody>
<tr *ngFor="let body of model; let i = index" >
<tr *ngFor="let body of model; let i = index">
<ng-container *ngFor="let cell of columns; let $i = index">
<td >
<td [width]="cell.width">
<input *ngIf="cell.isEdit" type="text" [(ngModel)]="body[cell['key']]" (input)="handleChange($event)" />
<span *ngIf="!cell.isEdit">{{ body[cell['key']] }}</span>
<!-- share scope if columns include [slot] -->
<ng-container *ngIf="slotMap[cell.slot]">
<ng-template
[ngTemplateOutlet]="slotMap[cell.slot]"
[ngTemplateOutletContext]="{ scope: body, index: i }"
></ng-template>
<ng-template [ngTemplateOutlet]="slotMap[cell.slot]" [ngTemplateOutletContext]="{ scope: body, index: i }">
</ng-template>
</ng-container>
</td>
</ng-container>
</tr>
</tbody>
</table>
</table>

View File

@ -2,6 +2,8 @@ table.eo-table {
width: 100%;
border-radius: 3px 3px 0 0;
border: 1px solid #f1f1f1;
table-layout: fixed;
border-collapse: separate;
thead {
height: 40px;
background-color: #fafafa;

View File

@ -1,6 +1,5 @@
import {
Component,
OnChanges,
AfterContentInit,
Input,
QueryList,
@ -9,7 +8,6 @@ import {
Output,
EventEmitter,
OnInit,
ViewChild,
} from '@angular/core';
import { CellDirective } from './cell.directive';
import { isEmptyValue } from '../../../utils/index';
@ -37,6 +35,7 @@ export class EoTableComponent implements OnInit, AfterContentInit {
@Input() columns: Column[] = [];
@Input() dataModel: {} = {};
@Input() rules: [] = [];
@Input() hideEmptyLine = false;
@Output() modelChange = new EventEmitter<any>();
// * about share scope
@ -50,7 +49,7 @@ export class EoTableComponent implements OnInit, AfterContentInit {
@Input() set model(value) {
this.modelData = (value ?? []).flat(Infinity);
const emptyList = this.modelData.filter(isEmptyValue);
if (emptyList.length === 0) {
if (!this.hideEmptyLine && emptyList.length === 0) {
// * If has no empty line, then add a new line.
this.modelData = this.modelData.concat([JSON.parse(JSON.stringify(this.dataModel))]);
}

View File

@ -2,21 +2,21 @@
<button nz-button nzType="primary" (click)="addOrEditModal()" i18n>Add Mock</button>
<div class="mt-[20px]">
<eo-table [(model)]="mocklList" [columns]="mockListColumns" [dataModel]="{ name: '', value: '', description: '' }">
<eo-table [(model)]="mocklList" [columns]="mockListColumns" [hideEmptyLine]="true">
<ng-template cell="name" let-scope="scope" let-index="index">
<div class=" w-[120px]">{{ scope.name }}</div>
</ng-template>
<ng-template cell="url" let-scope="scope" let-index="index">
<span i18n-nzTooltipTitle nzTooltipTitle="Click to Copy" nzTooltipPlacement="top" nz-tooltip
(click)="copyText(scope.url)">
{{ scope.url }}
<span nz-typography nzEllipsis [nzContent]="scope.url"> </span>
</span>
</ng-template>
<ng-template cell="createWay" let-scope="scope" let-index="index">
<span>{{ createWayMap[scope.createWay] }}</span>
</ng-template>
<ng-template cell="action" let-scope="scope" let-index="index">
<div class="flex justify-evenly">
<div class="flex">
<a nz-button nzType="link" *ngIf="scope.name || scope.url" (click)="addOrEditModal(index)" i18n>
{{ scope.createWay === 'system' ? 'Preview' : 'Edit' }}</a>
<a nz-button nzType="link" *ngIf="(scope.name || scope.url) && scope.createWay !== 'system'" nz-popconfirm

View File

@ -40,8 +40,8 @@ export class ApiMockComponent implements OnInit {
mockListColumns = [
{ title: $localize`Name`, slot: 'name', width: '20%' },
{ title: $localize`Created Type`, slot: 'createWay', width: '18%' },
{ title: 'URL', slot: 'url', width: '50%' },
{ title: '', slot: 'action', width: '15%', fixed: true },
{ title: 'URL', slot: 'url', width: '42%' },
{ title: '', slot: 'action', width: '20%', fixed: true },
];
/** 当前被编辑的mock */
currentEditMock: ApiMockEntity;

View File

@ -126,10 +126,11 @@
</nz-tab>
</nz-tabset>
<ng-template #extraTemplate>
<div *ngIf="model.responseTabIndex === 0" class="px-[10px]">
<div *ngIf="model.responseTabIndex === 0" class="py-[6px] px-[12px] flex items-center">
<!-- <span nz-icon nzType="download" nzTheme="outline">下载</span> -->
<a nz-button nzType="link" [disabled]="isEmpty(model.testResult?.response)" (click)="downloadFile()"
i18n>Download</a>
<eo-iconpark-icon name="download" *ngIf="!isEmpty(model.testResult?.response)" class="cursor-pointer"
(click)="downloadFile()">
</eo-iconpark-icon>
</div>
</ng-template>
<div id="test-response"></div>

View File

@ -64,7 +64,7 @@ if (isElectron) {
} else {
const browserType = getBrowserType(getSettings()?.['eoapi-language']);
descriptions.push(
...Object.entries(browserType).map(([key, value]) => ({
...Object.entries<string>(browserType).map(([key, value]) => ({
id: key,
label: key.replace(/^\S/, (s) => s.toUpperCase()),
value,

View File

@ -108,7 +108,7 @@ export function getBrowserType(lang: 'zh-Hans' | 'en-US' = 'en-US') {
{
内核: engine, // 内核: webkit gecko presto trident
内核版本: engineVs, // 内核版本
平台: platform, // 平台: desktop mobile
// 平台: platform, // 平台: desktop mobile
载体: supporter, // 载体: chrome safari firefox opera iexplore edge
载体版本: supporterVs, // 载体版本
系统: system, // 系统: windows macos linux android ios
@ -125,7 +125,7 @@ export function getBrowserType(lang: 'zh-Hans' | 'en-US' = 'en-US') {
{
engine, // 内核: webkit gecko presto trident
engineVs, // 内核版本
platform, // 平台: desktop mobile
// platform, // 平台: desktop mobile
supporter, // 载体: chrome safari firefox opera iexplore edge
supporterVs, // 载体版本
system, // 系统: windows macos linux android ios

View File

@ -6,8 +6,8 @@
<title>Eoapi - Easy & Open Source API Ecosystem</title>
<base href="/" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script async
src="https://lf1-cdn-tos.bytegoofy.com/obj/iconpark/icons_12799_48.a333dbb15379f97f5491d623c96b2dd1.js"></script>
<script
src="https://lf1-cdn-tos.bytegoofy.com/obj/iconpark/icons_12799_49.1a0eb5927e4cfcf49e6bb90ace3b5979.js"></script>
<link rel="icon" type="image/x-icon" href="assets/icons/icon.ico" />
</head>
<!-- Angular Cli need for node modules -->

View File

@ -2702,11 +2702,6 @@ accepts@~1.3.4, accepts@~1.3.5, accepts@~1.3.8:
mime-types "~2.1.34"
negotiator "0.6.3"
ace-builds@^1.4.0:
version "1.8.1"
resolved "https://registry.npmmirror.com/ace-builds/-/ace-builds-1.8.1.tgz#5d318fa13d7e6ea947f8a50e42c570c573b29529"
integrity sha512-wjEQ4khMQYg9FfdEDoOtqdoHwcwFL48H0VB3te5b5A3eqHwxsTw8IX6+xzfisgborIb8dYU+1y9tcmtGFrCPIg==
acorn-globals@^4.1.0:
version "4.3.4"
resolved "https://registry.npmmirror.com/acorn-globals/-/acorn-globals-4.3.4.tgz#9fa1926addc11c97308c4e66d7add0d40c3272e7"
@ -3520,18 +3515,6 @@ brace-expansion@^2.0.1:
dependencies:
balanced-match "^1.0.0"
brace-extra@^0.9.0:
version "0.9.0"
resolved "https://registry.npmmirror.com/brace-extra/-/brace-extra-0.9.0.tgz#ce18e93a07b8f6ed9e17e79799c5f7bcd90443d6"
integrity sha512-FqtEfrZc7f+w63Knlxvv3VeIME6EJp1v4fKVdlh7w2Fgqab3JozWr9for/hVnKsgT3USIPu8brvbs0zK88tPfQ==
dependencies:
w3c-blob "0.0.1"
brace@0.11.1, brace@^0.11.0:
version "0.11.1"
resolved "https://registry.npmmirror.com/brace/-/brace-0.11.1.tgz#4896fcc9d544eef45f4bb7660db320d3b379fe58"
integrity sha512-Fc8Ne62jJlKHiG/ajlonC4Sd66Pq68fFwK4ihJGNZpGqboc324SQk+lRvMzpPRuJOmfrJefdG8/7JdWX4bzJ2Q==
braces@^3.0.2, braces@~3.0.2:
version "3.0.2"
resolved "https://registry.npmmirror.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107"
@ -9257,16 +9240,6 @@ ng-zorro-antd@13.3.2:
date-fns "^2.16.1"
tslib "^2.3.0"
ngx-ace-wrapper@12.0.0:
version "12.0.0"
resolved "https://registry.npmmirror.com/ngx-ace-wrapper/-/ngx-ace-wrapper-12.0.0.tgz#d0e87794e0ac67c813c1865886181f397666d750"
integrity sha512-iamy+c6aO1Lw/c0NgvU6iBknKUj8BpBflZB34vvlyV+GwWFkze+CtJ8M3RBHj95yIGu8JhiWjB0uqHhiLj+N9Q==
dependencies:
ace-builds "^1.4.0"
brace "^0.11.0"
brace-extra "^0.9.0"
tslib "^2.3.0"
nice-napi@^1.0.2:
version "1.0.2"
resolved "https://registry.npmmirror.com/nice-napi/-/nice-napi-1.0.2.tgz#dc0ab5a1eac20ce548802fc5686eaa6bc654927b"
@ -13327,11 +13300,6 @@ void-elements@^2.0.0:
resolved "https://registry.npmmirror.com/void-elements/-/void-elements-2.0.1.tgz#c066afb582bb1cb4128d60ea92392e94d5e9dbec"
integrity sha512-qZKX4RnBzH2ugr8Lxa7x+0V6XD9Sb/ouARtiasEQCHB1EVU4NXtmHsDDrx1dO4ne5fc3J6EW05BP1Dl0z0iung==
w3c-blob@0.0.1:
version "0.0.1"
resolved "https://registry.npmmirror.com/w3c-blob/-/w3c-blob-0.0.1.tgz#b0cd352a1a50f515563420ffd5861f950f1d85b8"
integrity sha512-fKfmCyRd0A/tSLt0zPR2716jAkoysa4+2nA2ip6ytr6fs1I9Tml2aXb28w8ljUjUutT23Zn7Vyc2GQM5w3rtWA==
w3c-hr-time@^1.0.1:
version "1.0.2"
resolved "https://registry.npmmirror.com/w3c-hr-time/-/w3c-hr-time-1.0.2.tgz#0a89cdf5cc15822df9c360543676963e0cc308cd"