|
@@ -3,7 +3,7 @@ import {
|
|
|
CloseOutlined,
|
|
|
SendOutlined,
|
|
|
CaretDownOutlined,
|
|
|
- LoadingOutlined
|
|
|
+ LoadingOutlined,
|
|
|
} from "@ant-design/icons";
|
|
|
import { Button, Tooltip, Input, Form, Dropdown, message } from "antd";
|
|
|
import type { DropDownProps } from "antd";
|
|
@@ -99,7 +99,8 @@ export default function AICreator(props: {
|
|
|
const onSubmit = () => {
|
|
|
if (input.trim()) {
|
|
|
onRequest(
|
|
|
- `设计一个${graphType}, 返回图形json数据, 具体需求描述:${input}`,
|
|
|
+ `#角色:你是一个系统设计助手,根据需求部分的描述用流程图工具为用户生成${graphType}图形的json数据,不需要返回其他内容。
|
|
|
+#需求:${input}`,
|
|
|
undefined,
|
|
|
input
|
|
|
);
|
|
@@ -199,10 +200,10 @@ export default function AICreator(props: {
|
|
|
}
|
|
|
}
|
|
|
// 从边线中提取文本
|
|
|
- if(cell.isEdge()) {
|
|
|
+ if (cell.isEdge()) {
|
|
|
(cell.labels || []).forEach((label) => {
|
|
|
const labelText = (label?.attrs?.label?.text as string)?.trim();
|
|
|
- if(labelText) {
|
|
|
+ if (labelText) {
|
|
|
if (!labelMap[labelText]) {
|
|
|
labelMap[labelText] = [
|
|
|
{ cell: cell.id, key: "label", cellType: cell.shape },
|
|
@@ -224,10 +225,10 @@ export default function AICreator(props: {
|
|
|
// 替换节点文本内容
|
|
|
const handleReplace = (labelMap: LabelMap, data: Record<string, string>) => {
|
|
|
const keyMap: Record<string, string> = data;
|
|
|
- if(Array.isArray(data)) {
|
|
|
- data.forEach(item => {
|
|
|
- keyMap[item.original] = item.value
|
|
|
- })
|
|
|
+ if (Array.isArray(data)) {
|
|
|
+ data.forEach((item) => {
|
|
|
+ keyMap[item.original] = item.value;
|
|
|
+ });
|
|
|
}
|
|
|
Object.keys(keyMap).forEach((key) => {
|
|
|
if (labelMap[key]) {
|
|
@@ -241,16 +242,20 @@ export default function AICreator(props: {
|
|
|
} else if (cell?.isEdge()) {
|
|
|
// 设置边线文本
|
|
|
const labels = cell.getLabels();
|
|
|
- cell.setLabels(labels.map(item => {
|
|
|
- return {
|
|
|
- ...item,
|
|
|
- attrs: {
|
|
|
- label: {
|
|
|
- text: keyMap?.[(item.attrs?.label?.text as string)?.trim()] || item.attrs?.label?.text
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }))
|
|
|
+ cell.setLabels(
|
|
|
+ labels.map((item) => {
|
|
|
+ return {
|
|
|
+ ...item,
|
|
|
+ attrs: {
|
|
|
+ label: {
|
|
|
+ text:
|
|
|
+ keyMap?.[(item.attrs?.label?.text as string)?.trim()] ||
|
|
|
+ item.attrs?.label?.text,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ };
|
|
|
+ })
|
|
|
+ );
|
|
|
}
|
|
|
});
|
|
|
}
|
|
@@ -365,7 +370,7 @@ export default function AICreator(props: {
|
|
|
const data = JSON.stringify(Object.keys(labelMap));
|
|
|
let result = "";
|
|
|
onRequest(
|
|
|
- `翻译成${lang === 'en' ? '英文' : '中文'},需要翻译的数据:${data}`,
|
|
|
+ `翻译成${lang === "en" ? "英文" : "中文"},需要翻译的数据:${data}`,
|
|
|
{
|
|
|
onUpdate: (data) => {
|
|
|
result += data.answer;
|
|
@@ -485,7 +490,7 @@ export default function AICreator(props: {
|
|
|
<Button
|
|
|
type="primary"
|
|
|
shape="circle"
|
|
|
- icon={<LoadingOutlined/>}
|
|
|
+ icon={<LoadingOutlined />}
|
|
|
onClick={handleStop}
|
|
|
></Button>
|
|
|
</Tooltip>
|