Toggle navigation
Toggle navigation
This project
Loading...
Sign in
万朱浩
/
Venue-Ops
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
马一丁
2025-12-19 14:51:24 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
1ec27af127f19a6650cbb39d758d3d1e56dcea01
1ec27af1
1 parent
df349867
Add automatic refresh functionality to GraphRAG in full-screen mode
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
5 deletions
templates/graph_viewer.html
templates/graph_viewer.html
View file @
1ec27af
...
...
@@ -578,23 +578,31 @@
let
allNodes
=
[];
let
allEdges
=
[];
let
reportId
=
{{
report_id
|
tojson
if
report_id
else
'null'
}};
let
graphReady
=
false
;
let
graphPollTimer
=
null
;
const
GRAPH_POLL_INTERVAL
=
4000
;
// 初始化
document
.
addEventListener
(
'DOMContentLoaded'
,
()
=>
{
loadGraphData
();
startGraphPolling
();
setupEventListeners
();
});
// 加载图谱数据
async
function
loadGraphData
()
{
showLoading
(
true
);
async
function
loadGraphData
(
options
=
{})
{
const
{
fromPoll
=
false
}
=
options
;
// 仅在首次或未加载成功时展示大遮罩
if
(
!
graphReady
||
!
fromPoll
)
{
showLoading
(
true
);
}
try
{
const
url
=
reportId
?
`
/
api
/
graph
/
$
{
reportId
}
`
:
'/api/graph/latest'
;
const
response
=
await
fetch
(
url
);
const
response
=
await
fetch
(
url
,
{
cache
:
'no-store'
}
);
const
data
=
await
response
.
json
();
if
(
data
.
success
&&
data
.
graph
)
{
...
...
@@ -604,18 +612,39 @@
updateStats
(
data
.
graph
.
stats
);
renderGraph
();
showLoading
(
false
);
showEmpty
(
false
);
graphReady
=
true
;
stopGraphPolling
();
}
else
{
showEmpty
(
true
);
if
(
!
graphReady
)
{
showEmpty
(
true
);
}
showLoading
(
false
);
}
}
catch
(
error
)
{
console
.
error
(
'加载图谱失败:'
,
error
);
showToast
(
'加载图谱失败: '
+
error
.
message
);
showEmpty
(
true
);
if
(
!
graphReady
)
{
showEmpty
(
true
);
}
showLoading
(
false
);
}
}
function
startGraphPolling
()
{
if
(
graphPollTimer
)
return
;
graphPollTimer
=
setInterval
(()
=>
{
loadGraphData
({
fromPoll
:
true
});
},
GRAPH_POLL_INTERVAL
);
}
function
stopGraphPolling
()
{
if
(
graphPollTimer
)
{
clearInterval
(
graphPollTimer
);
graphPollTimer
=
null
;
}
}
// 渲染图谱
function
renderGraph
()
{
const
container
=
document
.
getElementById
(
'network'
);
...
...
Please
register
or
login
to post a comment