Skip to content

Commit

Permalink
fix: some bug
Browse files Browse the repository at this point in the history
  • Loading branch information
buqiyuan committed Sep 21, 2022
1 parent f61ab5a commit 9c6e968
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 22 deletions.
7 changes: 5 additions & 2 deletions src/platform/node/mock-server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { BrowserView, ipcMain } from 'electron';
import type { Server } from 'http';
import type { AddressInfo } from 'net';
import { Configuration } from 'eo/platform/node/configuration/lib';
import Store from 'electron-store';
const store = new Store();

const protocolReg = new RegExp('^/(http|https)://');
// Solve object circular reference problem
Expand Down Expand Up @@ -94,9 +96,9 @@ export class MockServer {
* start mock server
* @param port mock server port
*/
async start(view: BrowserView, port = 3040) {
async start(view: BrowserView, port = store.get('mock_port') || 3040) {
this.view = view;
portfinder.basePort = port;
portfinder.basePort = Number(port);
// Use portfinder for port detection. If the port is found to be occupied, the port will be incremented by 1.
const _port = await portfinder.getPortPromise();

Expand All @@ -105,6 +107,7 @@ export class MockServer {
.listen(_port, () => {
const { port } = this.server.address() as AddressInfo;
this.mockUrl = `http://127.0.0.1:${port}`;
store.set('mock_port', port);
console.log(`mock service is started:${this.mockUrl}`);
resolve(this.mockUrl);
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
</ng-template>
<ng-template #other>
<eo-monaco-editor class="mt20" [autoFormat]="true" [(code)]="model.body" [config]="{ readOnly: true }"
[isBase64]="['longText', 'stream'].includes(model.responseType)"
[eventList]="['type', 'format', 'copy', 'search']"></eo-monaco-editor>
</ng-template>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
</nz-descriptions-item>
</nz-descriptions>
</nz-tab>
<nz-tab i18n-nzTitle nzTitle="ChangeLog">
<nz-tab *ngIf="changeLog" i18n-nzTitle nzTitle="ChangeLog">
<!-- <h1>Change Log</h1>
<p>All notable changes to this project will be documented in this file.</p>
<h2>[12.0.1] - 2022-03-03</h2> -->
Expand Down Expand Up @@ -96,4 +96,4 @@ <h2>[12.0.1] - 2022-03-03</h2> -->
</ul>
</nz-dropdown-menu>
</ng-container>
</nz-modal>
</nz-modal>
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export class ExtensionDetailComponent implements OnInit {
if (this.extensionDetail?.features?.configuration) {
this.nzSelectedIndex = ~~this.route.snapshot.queryParams.tab;
}
this.fetchChangelog(this.language.systemLanguage);
}

async fetchChangelog(locale = '') {
Expand All @@ -101,7 +102,7 @@ export class ExtensionDetailComponent implements OnInit {
} else if (!locale && response.status === 404) {
try {
// const result = await fetch(`https://eoapi.eolinker.com/npm/${this.extensionDetail.name}`, {
const result = await fetch(`https://regi3stry.npmjs.org/${this.extensionDetail.name}`, {
const result = await fetch(`https://registry.npmjs.org/${this.extensionDetail.name}`, {
headers: {
// if fullmeta
// accept: ' application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,8 @@
</div>
<div *ngFor="let item of envList" class="flex items-center justify-between p-2 env-item">
<span class="flex-1 name" (click)="handleEditEnv(item.uuid)">{{ item.name }}</span>
<a
nz-popconfirm
i18n-nzPopconfirmTitle
nzPopconfirmTitle="Are you sure you want to delete?"
(nzOnConfirm)="handleDeleteEnv($event, item.uuid)"
class="delete-btn"
>
<a nz-popconfirm i18n-nzPopconfirmTitle nzPopconfirmTitle="Are you sure you want to delete?"
(nzOnConfirm)="handleDeleteEnv($event, item.uuid)" class="delete-btn">
<eo-iconpark-icon name="delete"> </eo-iconpark-icon>
</a>
</div>
Expand All @@ -38,20 +33,19 @@
<input nz-input name="hostUri" type="text" [(ngModel)]="envInfo.hostUri" />
</nz-form-control>
</nz-form-item>
<p class="mb-[8px]" i18n>Environment variable: API Documentation/Test can use {{ varName }} to refer to the environment variable</p>
<eo-table
[(model)]="envInfo.parameters"
[columns]="envListColumns"
[dataModel]="{ name: '', value: '', description: '' }"
>
<p class="mb-[8px]" i18n>Environment variable: API Documentation/Test can use {{ varName }} to refer to the
environment variable</p>
<eo-table [(model)]="envInfo.parameters" [columns]="envListColumns"
[dataModel]="{ name: '', value: '', description: '' }">
<ng-template cell="action" let-scope="scope" let-index="index">
<eo-iconpark-icon class="cursor-pointer" name="delete"> </eo-iconpark-icon>
<eo-iconpark-icon class="cursor-pointer" name="delete" (click)="handleDeleteParams(index)">
</eo-iconpark-icon>
</ng-template>
</eo-table>
</form>
</div>
</section>
<div *nzModalFooter class="px-2 footer">
<div *nzModalFooter class=" px-2 footer">
<button nz-button nzType="primary" (click)="handleSaveEnv(activeUuid)" i18n>Save</button>
<button nz-button nzType="default" (click)="handleCancel()" i18n>Cancel</button>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ const eventHash = new Map()
export class EoMonacoEditorComponent implements AfterViewInit, OnInit, OnChanges, OnDestroy {
@Input() eventList: EventType[] = [];
@Input() hiddenList: string[] = [];
@Input() set isBase64(val) {
this.$$isBase64 = val;
if (val) {
this.setCode(window.atob(this.$$code));
}
}
@Input() set code(val) {
this.setCode(val);
}
Expand All @@ -56,6 +62,7 @@ export class EoMonacoEditorComponent implements AfterViewInit, OnInit, OnChanges
@Input() completions = [];
@Output() codeChange = new EventEmitter<string>();
$$code = '';
$$isBase64 = false;
isFirstFormat = true;
codeEdtor: editor.IStandaloneCodeEditor;
completionItemProvider: monaco.IDisposable;
Expand Down Expand Up @@ -174,7 +181,7 @@ export class EoMonacoEditorComponent implements AfterViewInit, OnInit, OnChanges

let code = '';
try {
if (isBase64(val)) {
if (this.$$isBase64) {
code = window.atob(val);
} else {
code = JSON.stringify(typeof val === 'string' ? JSON.parse(val) : val, null, 4);
Expand Down
4 changes: 3 additions & 1 deletion src/workbench/browser/src/app/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,15 @@ export const eoDeepCopy = (obj) => {

throw new Error("Unable to copy obj! Its type isn't supported.");
};
//判断是否为base64转码过的字符串
const exg = new RegExp('^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)$');

export function isBase64(str) {
if (str === '' || str.trim() === '') {
return false;
}
try {
return window.btoa(window.atob(str)) === str;
return exg.test(str);
} catch (err) {
return false;
}
Expand Down

0 comments on commit 9c6e968

Please sign in to comment.