Skip to content

Commit 87165bc

Browse files
committed
claude 0226 plan
1 parent aec9c12 commit 87165bc

2 files changed

Lines changed: 53 additions & 40 deletions

File tree

frontend/packages/flow-pc/flow-pc-design/src/components/design-editor/node-components/strategy/node-title.tsx

Lines changed: 43 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useState, useMemo, useRef } from 'react';
2-
import { Button, Space } from 'antd';
2+
import { Form, Button, Space } from 'antd';
33
import { EditOutlined } from '@ant-design/icons';
44
import { Field, FieldRenderProps } from '@flowgram.ai/fixed-layout-editor';
55
import { GroovyVariableService } from '@/services/groovy-variable-service';
@@ -64,47 +64,50 @@ export const NodeTitleStrategy: React.FC = () => {
6464

6565
return (
6666
<>
67-
<div style={{ width: '100%' }}>
68-
<Field
69-
name="NodeTitleStrategy.script"
70-
render={({ field: { value, onChange } }: FieldRenderProps<any>) => {
71-
// 保存 onChange 回调到 ref
72-
onChangeRef.current = onChange;
67+
<Form style={{ width: '100%' }} layout="vertical">
68+
<Form.Item label="节点标题">
69+
<Field
70+
name="NodeTitleStrategy.script"
71+
render={(props: FieldRenderProps<any>) => {
72+
const { value, onChange } = props.field;
73+
// 保存 onChange 回调到 ref
74+
onChangeRef.current = onChange;
7375

74-
// 更新显示的脚本值(当编辑器状态改变时)
75-
if (value !== displayScript) {
76-
setDisplayScript(value || '');
77-
}
76+
// 更新显示的脚本值(当编辑器状态改变时)
77+
if (value !== displayScript) {
78+
setDisplayScript(value || '');
79+
}
7880

79-
return (
80-
<Space.Compact style={{ width: '100%' }}>
81-
<div
82-
style={{
83-
flex: 1,
84-
padding: '4px 11px',
85-
backgroundColor: value ? '#fff' : '#fafafa',
86-
border: '1px solid #d9d9d9',
87-
borderRadius: '6px 0 0 6px',
88-
color: value ? 'rgba(0,0,0,0.88)' : 'rgba(0,0,0,0.25)',
89-
whiteSpace: 'nowrap',
90-
overflow: 'hidden',
91-
textOverflow: 'ellipsis',
92-
}}
93-
>
94-
{renderPreview(value)}
95-
</div>
96-
<Button
97-
icon={<EditOutlined />}
98-
onClick={handleOpenConfig}
99-
style={{ borderRadius: '0 6px 6px 0' }}
100-
>
101-
编辑
102-
</Button>
103-
</Space.Compact>
104-
);
105-
}}
106-
/>
107-
</div>
81+
return (
82+
<Space.Compact style={{ width: '100%' }}>
83+
<div
84+
style={{
85+
flex: 1,
86+
padding: '4px 11px',
87+
backgroundColor: value ? '#fff' : '#fafafa',
88+
border: '1px solid #d9d9d9',
89+
borderRadius: '6px 0 0 6px',
90+
color: value ? 'rgba(0,0,0,0.88)' : 'rgba(0,0,0,0.25)',
91+
whiteSpace: 'nowrap',
92+
overflow: 'hidden',
93+
textOverflow: 'ellipsis',
94+
}}
95+
>
96+
{renderPreview(value)}
97+
</div>
98+
<Button
99+
icon={<EditOutlined />}
100+
onClick={handleOpenConfig}
101+
style={{ borderRadius: '0 6px 6px 0' }}
102+
>
103+
编辑
104+
</Button>
105+
</Space.Compact>
106+
);
107+
}}
108+
/>
109+
</Form.Item>
110+
</Form>
108111

109112
{showConfigModal && (
110113
<TitleConfigModal

frontend/packages/flow-pc/flow-pc-design/src/utils/title-syntax-converter.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,16 @@ export class TitleSyntaxConverter {
8585
try {
8686
let result = groovyCode.trim();
8787

88+
// 特殊处理:检查是否为默认的 legacy 脚本
89+
// 格式: def run(request){return '你有一条待办'}
90+
if (this.isDefaultLegacyScript(result)) {
91+
// 提取 return 语句中的字符串
92+
const match = result.match(/return\s+['"]([^'"]*)['"]/);
93+
if (match && match[1]) {
94+
return match[1];
95+
}
96+
}
97+
8898
// 检查是否有 @TITLE 注释
8999
if (!result.includes(TITLE_COMMENT)) {
90100
return null; // 无法解析

0 commit comments

Comments
 (0)