feat(flow): 添加动态API路由支持通过流程code执行
refactor(engine): 优化节点执行耗时记录 fix(db): 修正结果模式获取逻辑忽略connection.mode style(i18n): 统一节点描述和输出模式选项的国际化 test(flow): 新增测试流程定义文件 refactor(react): 简化开发环境日志降噪处理
This commit is contained in:
@ -5,7 +5,7 @@
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import { FlowNodeRegistry } from '@flowgram.ai/free-layout-editor';
|
||||
import { FlowNodeRegistry, I18n } from '@flowgram.ai/free-layout-editor';
|
||||
|
||||
import { useIsSidebar, useNodeRenderContext } from '../../hooks';
|
||||
import { FormTitleDescription, FormWrapper } from './styles';
|
||||
@ -21,7 +21,11 @@ export function FormContent(props: { children?: React.ReactNode }) {
|
||||
return (
|
||||
<FormWrapper>
|
||||
<>
|
||||
{isSidebar && <FormTitleDescription>{registry.info?.description}</FormTitleDescription>}
|
||||
{isSidebar && (
|
||||
<FormTitleDescription>
|
||||
{I18n.t((registry.info?.description as any) || '')}
|
||||
</FormTitleDescription>
|
||||
)}
|
||||
{(expanded || isSidebar) && props.children}
|
||||
</>
|
||||
</FormWrapper>
|
||||
|
||||
@ -39,10 +39,18 @@ export function TitleInput(props: {
|
||||
onBlur={() => updateTitleEdit(false)}
|
||||
/>
|
||||
) : (
|
||||
// 对默认的 Start/End 标题进行按需本地化显示
|
||||
<Text ellipsis={{ showTooltip: true }}>{
|
||||
value === 'Start' || value === 'End' ? I18n.t(value as any) : (value as any)
|
||||
}</Text>
|
||||
// 对默认的 Start/End 标题进行按需本地化显示(大小写与首尾空白规整)
|
||||
<Text ellipsis={{ showTooltip: true }}>
|
||||
{(() => {
|
||||
const raw = (value ?? '') as string;
|
||||
const norm = raw.trim().toLowerCase();
|
||||
if (norm === 'start' || norm === 'end') {
|
||||
const key = norm === 'start' ? 'Start' : 'End';
|
||||
return I18n.t(key as any);
|
||||
}
|
||||
return value as any;
|
||||
})()}
|
||||
</Text>
|
||||
)}
|
||||
<Feedback errors={fieldState?.errors} />
|
||||
</div>
|
||||
|
||||
@ -415,9 +415,20 @@ export function useEditorProps(
|
||||
'SQL': 'SQL',
|
||||
'Params': '参数',
|
||||
'Output Key': '输出键',
|
||||
},
|
||||
'en-US': {},
|
||||
},
|
||||
// ==== DB Node: Output Mode and options ====
|
||||
'Output Mode': '输出模式',
|
||||
'Rows': '行数组',
|
||||
'First Row': '首行对象',
|
||||
'Affected Rows': '影响行数',
|
||||
},
|
||||
'en-US': {
|
||||
// ==== DB Node: Output Mode and options ====
|
||||
'Output Mode': 'Output Mode',
|
||||
'Rows': 'Rows',
|
||||
'First Row': 'First Row',
|
||||
'Affected Rows': 'Affected Rows',
|
||||
},
|
||||
},
|
||||
},
|
||||
plugins: () => [
|
||||
/**
|
||||
|
||||
@ -186,9 +186,9 @@ export const FormRender = ({ form }: FormRenderProps<any>) => {
|
||||
onChange={(v) => field.onChange(v as string)}
|
||||
style={{ width: 200 }}
|
||||
optionList={[
|
||||
{ label: 'rows', value: 'rows' },
|
||||
{ label: 'first', value: 'first' },
|
||||
{ label: 'affected', value: 'affected' },
|
||||
{ label: I18n.t('Rows'), value: 'rows' },
|
||||
{ label: I18n.t('First Row'), value: 'first' },
|
||||
{ label: I18n.t('Affected Rows'), value: 'affected' },
|
||||
]}
|
||||
/>
|
||||
)}
|
||||
|
||||
@ -24,7 +24,7 @@ export const EndNodeRegistry: FlowNodeRegistry = {
|
||||
info: {
|
||||
icon: iconEnd,
|
||||
description:
|
||||
I18n.t('The final node of the workflow, used to return the result information after the workflow is run.'),
|
||||
I18n.t('流程结束节点,用于返回流程运行后的结果信息。'),
|
||||
},
|
||||
/**
|
||||
* Render node via formMeta
|
||||
|
||||
@ -25,7 +25,7 @@ export const StartNodeRegistry: FlowNodeRegistry = {
|
||||
info: {
|
||||
icon: iconStart,
|
||||
description:
|
||||
I18n.t('The starting node of the workflow, used to set the information needed to initiate the workflow.'),
|
||||
I18n.t('流程开始节点,用于设置启动流程所需的信息。'),
|
||||
},
|
||||
/**
|
||||
* Render node via formMeta
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* React 18 兼容性补丁 + 开发期告警修复
|
||||
* - 解决第三方库使用旧版 ReactDOM.render API 的问题
|
||||
* - 在开发环境下拦截并剔除部分第三方库会误透传到原生 DOM 的非标准属性
|
||||
* - 在开发环境下提供最小化的日志降噪(不再篡改 React.createElement,以避免 ESM 导入赋值报错)
|
||||
*/
|
||||
import * as ReactDOM from 'react-dom/client'
|
||||
import * as React from 'react'
|
||||
@ -33,41 +33,6 @@ export function setupReact18Polyfill() {
|
||||
}
|
||||
}
|
||||
|
||||
// 开发环境:剔除被第三方库误透传到原生 DOM 的非标准属性,防止 React 告警
|
||||
export function setupDevSanitizeDOMProps() {
|
||||
if (!import.meta.env.DEV) return
|
||||
const ANY_REACT = React as any
|
||||
// 避免重复打补丁
|
||||
if (ANY_REACT.__patched_createElement__) return
|
||||
|
||||
const origCreateElement = React.createElement as any
|
||||
const STRIP_KEYS = new Set(['localeCode', 'defaultCurrency', 'showCurrencySymbol'])
|
||||
|
||||
const patchedCreateElement = (type: any, props: any, ...children: any[]) => {
|
||||
if (typeof type === 'string' && props && typeof props === 'object') {
|
||||
let mutated = false
|
||||
const nextProps: any = {}
|
||||
for (const key in props) {
|
||||
if (Object.prototype.hasOwnProperty.call(props, key)) {
|
||||
if (STRIP_KEYS.has(key)) {
|
||||
mutated = true
|
||||
continue
|
||||
}
|
||||
nextProps[key] = props[key]
|
||||
}
|
||||
}
|
||||
return origCreateElement(type, mutated ? nextProps : props, ...children)
|
||||
}
|
||||
return origCreateElement(type, props, ...children)
|
||||
}
|
||||
|
||||
;(React as any).createElement = patchedCreateElement
|
||||
ANY_REACT.__patched_createElement__ = true
|
||||
if (typeof console !== 'undefined' && console.debug) {
|
||||
console.debug('[DEV] React.createElement patched to sanitize DOM props')
|
||||
}
|
||||
}
|
||||
|
||||
// 开发环境:抑制特定第三方库产生的已知无害告警(仅字符串匹配,不影响其他日志)
|
||||
export function setupDevConsoleSuppression() {
|
||||
if (!import.meta.env.DEV) return
|
||||
@ -88,10 +53,8 @@ export function setupDevConsoleSuppression() {
|
||||
})
|
||||
.join(' ')
|
||||
|
||||
const hitsReactUnrecognized = joined.includes('React does not recognize the')
|
||||
const hitsKnownKeys = joined.includes('localeCode') || joined.includes('defaultCurrency') || joined.includes('showCurrencySymbol')
|
||||
|
||||
if (hitsReactUnrecognized && hitsKnownKeys) return true
|
||||
// 常见的第三方库误传非标准 DOM 属性引发的 React 告警
|
||||
if (joined.includes('React does not recognize the')) return true
|
||||
if (joined.includes('[DOM] Input elements should have autocomplete attributes')) return true
|
||||
return false
|
||||
} catch {
|
||||
@ -121,6 +84,6 @@ export function setupDevConsoleSuppression() {
|
||||
export function setupReactDevFixes() {
|
||||
if (!import.meta.env.DEV) return
|
||||
setupReact18Polyfill()
|
||||
setupDevSanitizeDOMProps()
|
||||
// 注意:不再对 React.createElement 打补丁,避免 ESM 导入不可变导致的构建错误
|
||||
setupDevConsoleSuppression()
|
||||
}
|
||||
Reference in New Issue
Block a user