Skip to content

Commit d04127e

Browse files
committed
feat: enhance visualization options with dynamic highlight colors and add GitHub repository link
1 parent 220cb6f commit d04127e

File tree

1 file changed

+61
-28
lines changed

1 file changed

+61
-28
lines changed

packages/playground/app.vue

Lines changed: 61 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -106,49 +106,58 @@ const {
106106
closeSearch,
107107
} = useSearch(searchInputRef, chartRef);
108108
109-
onMounted(() => {
110-
const visOption: vis.Options = {
111-
physics: {
112-
solver: 'forceAtlas2Based',
113-
forceAtlas2Based: {
114-
gravitationalConstant: -100,
115-
},
109+
const highlightColor = computed(() => {
110+
return framework.value === 'vue'
111+
? '#42b883'
112+
: '#61dafb';
113+
});
114+
115+
const visOption = computed<vis.Options>(() => ({
116+
physics: {
117+
solver: 'forceAtlas2Based',
118+
forceAtlas2Based: {
119+
gravitationalConstant: -100,
116120
},
117-
groups: {
118-
used: {
119-
color: {
120-
border: '#3d7de4',
121-
background: '#9dc2f9',
122-
highlight: {
123-
border: '#3d7de4',
124-
background: '#9dc2f9',
125-
},
121+
},
122+
groups: {
123+
used: {
124+
color: {
125+
border: highlightColor.value,
126+
background: highlightColor.value,
127+
highlight: {
128+
border: highlightColor.value,
129+
background: highlightColor.value,
126130
},
127131
},
128-
normal: {
129-
color: {
132+
},
133+
normal: {
134+
color: {
135+
border: '#ccc',
136+
background: '#ddd',
137+
highlight: {
130138
border: '#ccc',
131139
background: '#ddd',
132-
highlight: {
133-
border: '#ccc',
134-
background: '#ddd',
135-
},
136140
},
137141
},
138142
},
139-
};
143+
},
144+
}));
145+
146+
const network = computed(() => {
147+
return new vis.Network(networkRef.value!, visData.value, visOption.value);
148+
});
140149
141-
const network = new vis.Network(networkRef.value!, visData.value, visOption);
150+
onMounted(() => {
142151
watch(visData, (val) => {
143-
network.setData(val);
152+
network.value.setData(val);
144153
});
145154
146155
watch(searchkey, (val) => {
147156
if (val) {
148157
// TODO: support fuzzy matching
149-
network.selectNodes(network.findNode(val), true);
150-
if (network.findNode(val).length > 0) {
151-
network.focus(network.findNode(val)[0], {
158+
network.value.selectNodes(network.value.findNode(val), true);
159+
if (network.value.findNode(val).length > 0) {
160+
network.value.focus(network.value.findNode(val)[0], {
152161
scale: 1.0,
153162
animation: {
154163
duration: 400,
@@ -340,6 +349,30 @@ const {
340349
>
341350
<span class="text-sm text-[#374151] font-medium">Auto Refresh</span>
342351
</label>
352+
353+
<div class="h-6 w-px bg-[#e5e7eb]" />
354+
355+
<!-- GitHub 仓库按钮 -->
356+
<a
357+
href="https://github.com/zcf0508/vue-hook-optimizer"
358+
target="_blank"
359+
rel="noopener noreferrer"
360+
class="
361+
px-4 py-2
362+
bg-white hover:bg-[#f3f4f6] active:bg-[#e5e7eb]
363+
text-[#374151] font-medium
364+
transition-all duration-200
365+
shadow-sm hover:shadow-md
366+
transform hover:scale-105 active:scale-95
367+
border border-[#e5e7eb] rounded-lg outline-none
368+
cursor-pointer
369+
flex items-center gap-2
370+
no-underline
371+
"
372+
>
373+
<span class="i-carbon:logo-github inline-block w-4 h-4" />
374+
GitHub
375+
</a>
343376
</div>
344377
<!-- 图表容器 -->
345378
<div class="flex-1 w-full relative bg-[#fafafa] min-h-0">

0 commit comments

Comments
 (0)