|
|
@@ -622,9 +622,11 @@
|
|
|
fetchGraphAnalysis,
|
|
|
fetchGraphCallDetail,
|
|
|
fetchGraphHistory,
|
|
|
+ fetchGraphHistoryContent,
|
|
|
fetchGraphNodeDetail,
|
|
|
fetchGraphTransDetail,
|
|
|
resolveGraphRespondentsFromRouteQuery,
|
|
|
+ saveGraphHistoryContent,
|
|
|
} from '../../api/analysis';
|
|
|
import { getPersons } from '@/person/api/personApi';
|
|
|
import { BasicModal } from '@/core/components/Modal';
|
|
|
@@ -6292,9 +6294,8 @@
|
|
|
)}`;
|
|
|
};
|
|
|
|
|
|
- const normalizeHistoryItem = (item: GraphHistoryItem, index: number): LayoutSnapshot | null => {
|
|
|
+ const normalizeHistoryItem = (item: GraphHistoryItem, index: number, payload: string): LayoutSnapshot | null => {
|
|
|
const id = String(item.id || item.filePath || item.path || `history-${index}`);
|
|
|
- const payload = String(item.graphData || item.graphJson || item.content || item.data || '');
|
|
|
if (!id || !payload) return null;
|
|
|
return {
|
|
|
id,
|
|
|
@@ -6308,6 +6309,20 @@
|
|
|
};
|
|
|
};
|
|
|
|
|
|
+ /** 历史列表接口只返回 id/名称/路径,快照内容需要按历史 ID 从服务端文件读取 */
|
|
|
+ const resolveGraphHistoryPayload = async (item: GraphHistoryItem): Promise<string> => {
|
|
|
+ const inline = String(item.graphData || item.graphJson || item.content || item.data || '');
|
|
|
+ if (inline) return inline;
|
|
|
+ const historyId = item.id;
|
|
|
+ if (!historyId) return '';
|
|
|
+ try {
|
|
|
+ return String((await fetchGraphHistoryContent(String(historyId))) || '');
|
|
|
+ } catch (error) {
|
|
|
+ console.error('load g6 graph history content failed', error);
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
const fetchSavedLayouts = async () => {
|
|
|
historyLoading.value = true;
|
|
|
try {
|
|
|
@@ -6321,8 +6336,12 @@
|
|
|
: Array.isArray(result?.data)
|
|
|
? result.data
|
|
|
: [];
|
|
|
- savedLayouts.value = rawList
|
|
|
- .map((item: GraphHistoryItem, index: number) => normalizeHistoryItem(item, index))
|
|
|
+ const normalized = await Promise.all(
|
|
|
+ rawList.map(async (item: GraphHistoryItem, index: number) =>
|
|
|
+ normalizeHistoryItem(item, index, await resolveGraphHistoryPayload(item)),
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ savedLayouts.value = normalized
|
|
|
.filter((item: LayoutSnapshot | null): item is LayoutSnapshot => Boolean(item))
|
|
|
.slice(0, MAX_HISTORY_SNAPSHOTS);
|
|
|
} catch (error) {
|
|
|
@@ -6363,16 +6382,20 @@
|
|
|
try {
|
|
|
saveActiveCanvasState();
|
|
|
const payload = serializeGraph();
|
|
|
- await createGraphHistory({
|
|
|
- ...routeGraphQuery.value,
|
|
|
+ // 只把元数据放进创建请求;整份图谱 JSON 走 POST body 单独保存。
|
|
|
+ // 之前把 payload 拼进 GET 参数,URL 超出 Tomcat 请求头上限(431/解析失败)。
|
|
|
+ const created = await createGraphHistory({
|
|
|
graphHisName: name,
|
|
|
name,
|
|
|
graphName: name,
|
|
|
- content: payload,
|
|
|
- graphData: payload,
|
|
|
nodeCount: graphStats.nodes,
|
|
|
edgeCount: graphStats.edges,
|
|
|
});
|
|
|
+ const historyId = created?.id ?? created?.data?.id;
|
|
|
+ if (!historyId) {
|
|
|
+ throw new Error('未获取到关系图历史ID');
|
|
|
+ }
|
|
|
+ await saveGraphHistoryContent(String(historyId), payload);
|
|
|
if (activeGraphCanvas.value) {
|
|
|
activeGraphCanvas.value.label = name;
|
|
|
activeGraphCanvas.value.lastSavedAt = getCurrentDateTimeLabel();
|