Skip to content

Commit d812041

Browse files
authored
Merge branch 'main' into main
2 parents 757c2cd + d917c20 commit d812041

File tree

2 files changed

+69
-45
lines changed

2 files changed

+69
-45
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project>
22
<!-- See https://aka.ms/dotnet/msbuild/customize for more details on customizing your build -->
33
<PropertyGroup>
4-
<Version>0.1.29</Version>
4+
<Version>0.1.30</Version>
55
<SKVersion>1.17.1</SKVersion>
66
</PropertyGroup>
77
</Project>

src/GraphRag.Net.Web/Pages/Graph/Graph.razor

Lines changed: 68 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -8,58 +8,82 @@
88
</div>
99

1010
<script>
11-
const app = new Vue({
12-
el: '#app',
13-
data: {
14-
message: 'Hello Vue!',
15-
graphOptions: {
16-
defaultJunctionPoint: 'border'
17-
// 这里可以参考"Graph 图谱"中的参数进行设置
18-
}
19-
},
20-
mounted() {
21-
this.showRelationGraph();
22-
},
23-
methods: {
24-
showRelationGraph() {
11+
window.onload = function () {
12+
initializeVueApp();
13+
};
14+
function initializeVueApp() {
15+
let app = new Vue({
16+
el: '#app',
17+
data: {
18+
message: 'Hello Vue!',
19+
graphOptions: {
20+
defaultJunctionPoint: 'border'
21+
// 这里可以参考"Graph 图谱"中的参数进行设置
22+
}
23+
},
24+
mounted() {
25+
this.showRelationGraph();
26+
},
27+
methods: {
28+
showRelationGraph() {
2529
26-
debugger;
27-
console.log('ref:btn:', this.$refs.btn);
28-
console.log('ref:', this.$refs.seeksRelationGraph);
29-
const url = new URL(window.location.href);
30+
debugger;
31+
console.log('ref:btn:', this.$refs.btn);
32+
console.log('ref:', this.$refs.seeksRelationGraph);
33+
const url = new URL(window.location.href);
3034
31-
// 获取查询字符串部分
32-
const queryString = url.search;
35+
// 获取查询字符串部分
36+
const queryString = url.search;
3337
34-
// 解析查询字符串为一个 URLSearchParams 对象
35-
const urlParams = new URLSearchParams(queryString);
38+
// 解析查询字符串为一个 URLSearchParams 对象
39+
const urlParams = new URLSearchParams(queryString);
3640
37-
// 获取参数的值,例如 'index'
38-
const index = urlParams.get('index');
39-
fetch('/api/GraphDemo/GetAllGraphs?index=' + index)
40-
.then(response => {
41-
if (!response.ok) {
42-
throw new Error('网络响应不成功,状态码:' + response.status);
43-
}
44-
return response.json(); // 或者 response.json() 取决于你的响应内容类型
45-
})
46-
.then(data => {
47-
// 请求成功,处理响应数据
48-
console.log(data);
49-
this.$refs.seeksRelationGraph.setJsonData(data, (seeksRGGraph) => {
50-
// 这些写上当图谱初始化完成后需要执行的代码
41+
// 获取参数的值,例如 'index'
42+
const index = urlParams.get('index');
43+
fetch('/api/GraphDemo/GetAllGraphs?index=' + index)
44+
.then(response => {
45+
if (!response.ok) {
46+
throw new Error('网络响应不成功,状态码:' + response.status);
47+
}
48+
return response.json(); // 或者 response.json() 取决于你的响应内容类型
49+
})
50+
.then(data => {
51+
// 请求成功,处理响应数据
52+
console.log(data);
53+
this.$refs.seeksRelationGraph.setJsonData(data, (seeksRGGraph) => {
54+
// 这些写上当图谱初始化完成后需要执行的代码
55+
});
56+
})
57+
.catch(error => {
58+
// 处理错误
59+
console.error('请求出错:', error);
5160
});
52-
})
53-
.catch(error => {
54-
// 处理错误
55-
console.error('请求出错:', error);
56-
});
61+
}
5762
}
58-
}
59-
})
63+
})
64+
}
6065
</script>
6166

6267
@code
6368
{
64-
69+
[Inject]
70+
protected IJSRuntime _jsRuntime { get; set; }
71+
72+
protected override async Task OnAfterRenderAsync(bool firstRender)
73+
{
74+
if (firstRender)
75+
{
76+
// 确保所有脚本加载完成后,调用初始化 Vue 的 JavaScript 函数
77+
await Task.Delay(500); // 短暂延时
78+
79+
try
80+
{
81+
await _jsRuntime.InvokeVoidAsync("initializeVueApp");
82+
}
83+
catch (Exception ex)
84+
{
85+
Console.WriteLine(ex.Message);
86+
}
87+
}
88+
}
6589
}

0 commit comments

Comments
 (0)