diff --git a/src/workbench/browser/src/app/pages/api/mock/api-mock.component.html b/src/workbench/browser/src/app/pages/api/mock/api-mock.component.html index 4d26f6371..7bec811d4 100644 --- a/src/workbench/browser/src/app/pages/api/mock/api-mock.component.html +++ b/src/workbench/browser/src/app/pages/api/mock/api-mock.component.html @@ -42,7 +42,7 @@ Response - diff --git a/src/workbench/browser/src/app/shared/components/monaco-editor/monaco-editor.component.ts b/src/workbench/browser/src/app/shared/components/monaco-editor/monaco-editor.component.ts index 69509a179..2b6a362e0 100644 --- a/src/workbench/browser/src/app/shared/components/monaco-editor/monaco-editor.component.ts +++ b/src/workbench/browser/src/app/shared/components/monaco-editor/monaco-editor.component.ts @@ -39,7 +39,7 @@ export class EoMonacoEditorComponent implements AfterViewInit, OnInit, OnChanges return; } try { - this.$$code = JSON.stringify(val); + this.$$code = typeof val === 'string' ? val : JSON.stringify(val); } catch { this.$$code = String(val); } diff --git a/src/workbench/browser/src/app/shared/components/setting/common/about.component.ts b/src/workbench/browser/src/app/shared/components/setting/common/about.component.ts index d07d09206..739e8616c 100644 --- a/src/workbench/browser/src/app/shared/components/setting/common/about.component.ts +++ b/src/workbench/browser/src/app/shared/components/setting/common/about.component.ts @@ -122,7 +122,7 @@ export class AboutComponent implements OnInit { } getSystemInfo() { - const systemInfo = this.electron.ipcRenderer.sendSync('get-system-info'); - return systemInfo; + const systemInfo = this.electron.ipcRenderer?.sendSync('get-system-info'); + return systemInfo || {}; } } diff --git a/src/workbench/browser/src/app/shared/components/setting/common/data-storage.component.ts b/src/workbench/browser/src/app/shared/components/setting/common/data-storage.component.ts index 937c8a880..496836052 100644 --- a/src/workbench/browser/src/app/shared/components/setting/common/data-storage.component.ts +++ b/src/workbench/browser/src/app/shared/components/setting/common/data-storage.component.ts @@ -14,6 +14,7 @@ import { NzMessageService } from 'ng-zorro-antd/message'; formControlName="eoapi-common.dataStorage" i18n-nzPlaceHolder="@@DataSource" nzPlaceHolder="Data Storage" + (ngModelChange)="handleSelectDataStorage($event)" > @@ -92,6 +93,15 @@ export class DataStorageComponent implements OnInit, OnChanges { } } + handleSelectDataStorage(val) { + if (!this.electronService.isElectron && val === 'http') { + this.validateForm.controls['eoapi-common.dataStorage'].setValue('local'); + return this.message.error( + $localize`Only the client can connect to the remote server. You need to download the client first.` + ); + } + } + /** * 测试远程服务器地址是否可用 */ diff --git a/src/workbench/browser/src/app/shared/components/setting/eoapi-settings/extenstion-settings.json b/src/workbench/browser/src/app/shared/components/setting/eoapi-settings/extenstion-settings.json deleted file mode 100644 index 36c618c7e..000000000 --- a/src/workbench/browser/src/app/shared/components/setting/eoapi-settings/extenstion-settings.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "private": true, - "name": "eoapi-extensions", - "version": "0.0.1", - "moduleName": "插件", - "moduleID": "eoapi-extensions", - "author": "eoapi", - "publisher": "eoapi", - "features": { - "configuration": [] - } -} diff --git a/src/workbench/browser/src/app/shared/components/setting/eoapi-settings/index.ts b/src/workbench/browser/src/app/shared/components/setting/eoapi-settings/index.ts deleted file mode 100644 index 1d78f124b..000000000 --- a/src/workbench/browser/src/app/shared/components/setting/eoapi-settings/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -import extenstionSettings from './extenstion-settings.json'; - -export type eoapiSettingsKey = keyof typeof eoapiSettings; - -export const eoapiSettings = { - /** 功能设置 */ - 'eoapi-extensions': extenstionSettings, -} as const; - -export default eoapiSettings; diff --git a/src/workbench/browser/src/app/shared/components/setting/eoapi-settings/types.ts b/src/workbench/browser/src/app/shared/components/setting/eoapi-settings/types.ts deleted file mode 100644 index fcc85dcf1..000000000 --- a/src/workbench/browser/src/app/shared/components/setting/eoapi-settings/types.ts +++ /dev/null @@ -1,36 +0,0 @@ -export type JSONSchemaType = 'string' | 'number' | 'integer' | 'boolean' | 'null' | 'array' | 'object'; - -/** 设置模块实体 */ -export type TOCEntry = { - id: string; - label: string; - order?: number; - children?: TOCEntry[]; - settings?: Array; -}; - -export type Setting = {}; - -export type ConfigurationProperty = { - [prop: string]: { - /** 配置项的值类型 */ - type?: JSONSchemaType | JSONSchemaType[]; - /** 枚举,用于下拉框 */ - enum?: any[]; - /** 用于对枚举项的说明 */ - enumDescriptions?: string[]; - /** 配置项默认值 */ - default?: any; - /** 配置项描述 */ - description?: string; - }; -}; - -export type ConfigurationNode = { - id?: string; - order?: number; - type?: string | string[]; - title?: string; - description?: string; - properties?: ConfigurationProperty; -}; diff --git a/src/workbench/browser/src/app/shared/components/setting/setting.component.ts b/src/workbench/browser/src/app/shared/components/setting/setting.component.ts index 21d4336f2..84aa2a61a 100644 --- a/src/workbench/browser/src/app/shared/components/setting/setting.component.ts +++ b/src/workbench/browser/src/app/shared/components/setting/setting.component.ts @@ -1,15 +1,13 @@ import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; -import { FormBuilder, FormGroup, Validators } from '@angular/forms'; +import { FormGroup } from '@angular/forms'; import { SelectionModel } from '@angular/cdk/collections'; import { FlatTreeControl } from '@angular/cdk/tree'; import { NzTreeFlatDataSource, NzTreeFlattener } from 'ng-zorro-antd/tree-view'; -import { eoapiSettings } from './eoapi-settings/'; import { Message, MessageService } from '../../../shared/services/message'; -import { Subject, takeUntil, debounceTime } from 'rxjs'; +import { Subject, takeUntil } from 'rxjs'; import { NzMessageService } from 'ng-zorro-antd/message'; import { RemoteService } from 'eo/workbench/browser/src/app/shared/services/remote/remote.service'; import { SettingService } from 'eo/workbench/browser/src/app/core/services/settings/settings.service'; -import { Router } from '@angular/router'; import { debounce } from 'eo/workbench/browser/src/app/utils'; interface TreeNode { diff --git a/src/workbench/browser/src/app/shared/services/storage/http/lib/baseUrl.service.ts b/src/workbench/browser/src/app/shared/services/storage/http/lib/baseUrl.service.ts index 9fd4e4e40..de4f7d978 100644 --- a/src/workbench/browser/src/app/shared/services/storage/http/lib/baseUrl.service.ts +++ b/src/workbench/browser/src/app/shared/services/storage/http/lib/baseUrl.service.ts @@ -2,6 +2,7 @@ import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest, HttpResponse } fr import { Injectable } from '@angular/core'; import { SettingService } from 'eo/workbench/browser/src/app/core/services/settings/settings.service'; import { filter, map, Observable } from 'rxjs'; +import { uniqueSlash } from '../../../../../utils/api'; const protocolReg = new RegExp('^(http|https)://'); // implements StorageInterface @@ -10,7 +11,7 @@ export class BaseUrlInterceptor extends SettingService implements HttpIntercepto intercept(req: HttpRequest, next: HttpHandler): Observable> { const { url = '', token = '' } = this.getConfiguration('eoapi-common.remoteServer') || {}; req = req.clone({ - url: protocolReg.test(req.url) ? req.url : url + req.url, + url: uniqueSlash(protocolReg.test(req.url) ? req.url : url + req.url), headers: req.headers.append('x-api-key', token), }); diff --git a/src/workbench/browser/src/app/utils/api.ts b/src/workbench/browser/src/app/utils/api.ts index 2c62facdd..ec04cbd45 100644 --- a/src/workbench/browser/src/app/utils/api.ts +++ b/src/workbench/browser/src/app/utils/api.ts @@ -4,4 +4,7 @@ * @param url * @returns */ -export const getRest: (url: string) => string[] = (url) => [...url.replace(/{{(.*?)}}/g, '').matchAll(/{(.*?)}/g)].map((val) => val[1]); +export const getRest: (url: string) => string[] = (url) => + [...url.replace(/{{(.*?)}}/g, '').matchAll(/{(.*?)}/g)].map((val) => val[1]); + +export const uniqueSlash = (path: string) => path.replace(/(?