|
@@ -1,4 +1,4 @@
|
|
-import React, { useEffect, useRef } from "react";
|
|
|
|
|
|
+import React, { useEffect, useMemo, useRef } from "react";
|
|
import { register } from "@antv/x6-react-shape";
|
|
import { register } from "@antv/x6-react-shape";
|
|
import { Graph, Node } from "@antv/x6";
|
|
import { Graph, Node } from "@antv/x6";
|
|
import type { ColumnItem, TableItemType } from "@/type";
|
|
import type { ColumnItem, TableItemType } from "@/type";
|
|
@@ -11,13 +11,10 @@ function TableNode({ node, graph }: { node: Node; graph: Graph }) {
|
|
const [showEdit, setShowEdit] = React.useState(false);
|
|
const [showEdit, setShowEdit] = React.useState(false);
|
|
const [_tabActiveKey, setTabActiveKey] =
|
|
const [_tabActiveKey, setTabActiveKey] =
|
|
useSessionStorageState("tabs-active-key");
|
|
useSessionStorageState("tabs-active-key");
|
|
- const [_active, setTableActive] = useSessionStorageState('table-active');
|
|
|
|
- const [playModeEnable] = useSessionStorageState(
|
|
|
|
- "playModeEnable",
|
|
|
|
- {
|
|
|
|
- listenStorageChange: true,
|
|
|
|
- }
|
|
|
|
- );
|
|
|
|
|
|
+ const [_active, setTableActive] = useSessionStorageState("table-active");
|
|
|
|
+ const [playModeEnable] = useSessionStorageState("playModeEnable", {
|
|
|
|
+ listenStorageChange: true,
|
|
|
|
+ });
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
const container = containerRef.current;
|
|
const container = containerRef.current;
|
|
@@ -85,7 +82,7 @@ function TableNode({ node, graph }: { node: Node; graph: Graph }) {
|
|
id: item.id + "_port1",
|
|
id: item.id + "_port1",
|
|
group: "columnPort",
|
|
group: "columnPort",
|
|
args: {
|
|
args: {
|
|
- y: 42 + 16 + index * 27,
|
|
|
|
|
|
+ y: 44 + 16 + index * 27,
|
|
},
|
|
},
|
|
attrs: {
|
|
attrs: {
|
|
circle: {
|
|
circle: {
|
|
@@ -145,21 +142,27 @@ function TableNode({ node, graph }: { node: Node; graph: Graph }) {
|
|
setTableActive(node.id);
|
|
setTableActive(node.id);
|
|
};
|
|
};
|
|
|
|
|
|
- const tableName = table.langNameList?.find((item) => item.lang === "zh-CN")?.value;
|
|
|
|
|
|
+ const tableName = useMemo(() => {
|
|
|
|
+ return table.langNameList?.find((item) => item.name === "zh-CN")?.value;
|
|
|
|
+ }, [table]);
|
|
|
|
|
|
const ColumnItem = ({ record }: { record: ColumnItem }) => {
|
|
const ColumnItem = ({ record }: { record: ColumnItem }) => {
|
|
const type = DATA_TYPE_OPTIONS.find((item) => item.value === record.type);
|
|
const type = DATA_TYPE_OPTIONS.find((item) => item.value === record.type);
|
|
- const columnName = record.langNameList?.find((item) => item.lang === "zh-CN")?.value;
|
|
|
|
|
|
+ const columnName = record.langNameList?.find(
|
|
|
|
+ (item) => item.name === "zh-CN"
|
|
|
|
+ )?.value;
|
|
return (
|
|
return (
|
|
<div
|
|
<div
|
|
className="w-full flex py-4px px-8px"
|
|
className="w-full flex py-4px px-8px"
|
|
onMouseUp={() => handleColumnMouseUp(record)}
|
|
onMouseUp={() => handleColumnMouseUp(record)}
|
|
>
|
|
>
|
|
<span className="flex-1 truncate flex items-center justify-between">
|
|
<span className="flex-1 truncate flex items-center justify-between">
|
|
- <span className="flex items-center">
|
|
|
|
- <span className=" w-6px h-6px rounded-full mr-4px inline-block cursor-pointer" />
|
|
|
|
- {record.schemaName}
|
|
|
|
- {columnName ? `(${columnName})` : ""}
|
|
|
|
|
|
+ <span className="flex items-center truncate">
|
|
|
|
+ <span className=" w-6px h-6px rounded-full mr-4px shrink-0 inline-block cursor-pointer" />
|
|
|
|
+ <span className="flex-1 truncate">
|
|
|
|
+ {record.schemaName}
|
|
|
|
+ {columnName ? `(${columnName})` : ""}
|
|
|
|
+ </span>
|
|
</span>
|
|
</span>
|
|
<span>
|
|
<span>
|
|
{record.isUnique ? (
|
|
{record.isUnique ? (
|
|
@@ -209,7 +212,9 @@ function TableNode({ node, graph }: { node: Node; graph: Graph }) {
|
|
"
|
|
"
|
|
>
|
|
>
|
|
<div className="truncate flex-1">
|
|
<div className="truncate flex-1">
|
|
- <span className="text-12px font-normal">{table.parentBusinessTableId && '[子]'}</span>
|
|
|
|
|
|
+ <span className="text-12px font-normal">
|
|
|
|
+ {table.parentBusinessTableId && "[子]"}
|
|
|
|
+ </span>
|
|
{table.schemaName}({tableName})
|
|
{table.schemaName}({tableName})
|
|
</div>
|
|
</div>
|
|
{showEdit && !playModeEnable && (
|
|
{showEdit && !playModeEnable && (
|