diff --git a/packages/core/src/types/types.ts b/packages/core/src/types/types.ts index c0b77cc..28dce5b 100644 --- a/packages/core/src/types/types.ts +++ b/packages/core/src/types/types.ts @@ -132,44 +132,6 @@ export type StorePropertyType = { | 'object'; }; -/* - * 服务函数的操作类型 - */ -export enum ESFOperationType { - ADD = 'add', - UPDATE = 'update', - DELETE = 'delete', -} - -/** - * 服务函数数据源类型 - */ -export enum ESFDataSourceType { - OvermindX = 'ox', - Custom = 'custom', -} - -/** - * 服务函数 HTTP Type - * 云音乐网关只支持 get 和 post - */ -export enum ESFHTTPMethodType { - GET = 'GET', - // PUT = 'PUT', - POST = 'POST', - // PATCH = 'PATCH', - // DELETE = 'DELETE', -} - -/** - * requestType - * headers: Content-Type - */ -export enum ESFHTTRequestType { - 'application/json' = 'json', - 'application/x-www-form-urlencoded' = 'x-www-form-urlencoded', -} - /** * 路由解析数据 */ diff --git a/packages/designer/src/sidebar/datasource-panel/interface-config.tsx b/packages/designer/src/sidebar/datasource-panel/interface-config.tsx index 5afae27..c07a159 100644 --- a/packages/designer/src/sidebar/datasource-panel/interface-config.tsx +++ b/packages/designer/src/sidebar/datasource-panel/interface-config.tsx @@ -1,6 +1,6 @@ import React, { useState, useEffect, useMemo } from 'react'; import { observer, useWorkspace } from '@music163/tango-context'; -import { Box, Link, css } from 'coral-system'; +import { Box, css } from 'coral-system'; import { Button, FormProps, Empty, Space, Dropdown } from 'antd'; import { PlayCircleOutlined } from '@ant-design/icons'; import { Form, InputCode, Menu, Panel, JsonView, Search } from '@music163/tango-ui'; @@ -12,14 +12,38 @@ import { logger, code2object, } from '@music163/tango-helpers'; -import { - ESFDataSourceType, - ESFOperationType, - ESFHTTPMethodType, - ESFHTTRequestType, -} from '@music163/tango-core'; import { useSandboxQuery } from '../../context'; +/* + * 服务函数的操作类型 + */ +enum ServiceFunctionOperationModeType { + ADD = 'add', + UPDATE = 'update', + DELETE = 'delete', +} + +/** + * 服务函数 HTTP Type + * 云音乐网关只支持 get 和 post + */ +enum ServiceFunctionMethodType { + GET = 'GET', + // PUT = 'PUT', + POST = 'POST', + // PATCH = 'PATCH', + // DELETE = 'DELETE', +} + +/** + * requestType + * headers: Content-Type + */ +enum ESFHTTRequestType { + 'application/json' = 'json', + 'application/x-www-form-urlencoded' = 'x-www-form-urlencoded', +} + /** * 将 api 路径转换为默认的驼峰方法名 */ @@ -47,28 +71,8 @@ type DataServiceViewProps = { onDelete?: (values: Record) => void; }; -// 判断是不是一个完整的 url 请求 -const VALID_REQUEST_URL_REG = /((http|https):)?\/\/([\w.]+\/?)\S*/; - -/** - * 根据 url 类型推断方法类型 - */ -export function inferServiceType(url?: string) { - // 删除的时候,也会走一下这个逻辑,兼容 - if (!url) return ESFDataSourceType.Custom; - // 如果是完整的,是 custom - if (VALID_REQUEST_URL_REG.test(url)) return ESFDataSourceType.Custom; - // 如果是 / 开头的,认为是 ox 的 - if (url.startsWith('/')) return ESFDataSourceType.OvermindX; - /** - * 这里预留出数据平台 fastX 的 - */ - // 默认是 ox 的 - return ESFDataSourceType.OvermindX; -} - // http 方法类型 -const httpMethods = Object.keys(ESFHTTPMethodType).map((key) => ({ +const httpMethods = Object.keys(ServiceFunctionMethodType).map((key) => ({ label: key, value: key, })); @@ -113,13 +117,7 @@ const DataSourceView = observer(({ onAdd, onUpdate, onDelete }: DataServiceViewP const isAddMode = !serviceKey; return ( - + { + onSubmit={(values, mode: ServiceFunctionOperationModeType) => { function shapeServiceValues(val: any) { const shapeValues = { ...val }; delete shapeValues.type; @@ -198,10 +195,10 @@ const DataSourceView = observer(({ onAdd, onUpdate, onDelete }: DataServiceViewP } // 移除掉不必要的属性 const data = shapeServiceValues(values); - if (mode === ESFOperationType.ADD) { + if (mode === ServiceFunctionOperationModeType.ADD) { workspace.addServiceFunction(data); onAdd && onAdd(values); - } else if (mode === ESFOperationType.UPDATE) { + } else if (mode === ServiceFunctionOperationModeType.UPDATE) { workspace.updateServiceFunction(data); onUpdate && onUpdate(values); } @@ -231,7 +228,7 @@ const DataSourceView = observer(({ onAdd, onUpdate, onDelete }: DataServiceViewP interface ServiceDetailFormProps extends FormProps { serviceKeys?: string[]; onCancel?: () => void; - onSubmit?: (values: any, mode: ESFOperationType) => void; + onSubmit?: (values: any, mode: ServiceFunctionOperationModeType) => void; } function ServiceDetailForm({ @@ -267,7 +264,12 @@ function ServiceDetailForm({ layout="horizontal" initialValues={initialValues} onFinish={(values) => { - onSubmit(values, isModifyMode ? ESFOperationType.UPDATE : ESFOperationType.ADD); + onSubmit( + values, + isModifyMode + ? ServiceFunctionOperationModeType.UPDATE + : ServiceFunctionOperationModeType.ADD, + ); setDisabled(true); }} {...formProps} @@ -345,18 +347,7 @@ function ServiceDetailForm({ - 提供格式化函数,对结果进行格式化。请参考 - - 云音乐接口规范 - - 。 - - } + tooltip="提供格式化函数,对结果进行格式化" validateTrigger="onBlur" rules={[ { diff --git a/packages/designer/src/sidebar/dependency-panel.tsx b/packages/designer/src/sidebar/dependency-panel.tsx index e4a6337..814d325 100644 --- a/packages/designer/src/sidebar/dependency-panel.tsx +++ b/packages/designer/src/sidebar/dependency-panel.tsx @@ -372,7 +372,7 @@ function RenderItem({ , ] : [ - + {!isUndefined(baseNeedUpgrade) && '已是最新'} , ] diff --git a/packages/designer/src/sidebar/sidebar.tsx b/packages/designer/src/sidebar/sidebar.tsx index 00336ad..be17afe 100644 --- a/packages/designer/src/sidebar/sidebar.tsx +++ b/packages/designer/src/sidebar/sidebar.tsx @@ -115,7 +115,12 @@ const INTERNAL_SIDEBAR_PANEL_MAP: Record = { }, }; -function BaseSidebarPanel({ panelWidth: defaultPanelWidth = 280, builtinPanelMap = INTERNAL_SIDEBAR_PANEL_MAP, footer, children }: SidebarProps) { +function BaseSidebarPanel({ + panelWidth: defaultPanelWidth = 280, + builtinPanelMap = INTERNAL_SIDEBAR_PANEL_MAP, + footer, + children, +}: SidebarProps) { const items = useMemo(() => { const ret: Record = {}; React.Children.forEach(children, (child) => { @@ -273,11 +278,10 @@ function SidebarPanelBarItem({ const expandPanelStyle = css` flex: 1; height: 100%; - display: flex; - flex-direction: column; background-color: var(--tango-colors-white); border-left: 1px solid var(--tango-colors-line-normal); position: relative; + overflow-y: auto; &.isFloat { position: absolute;