Skip to content

Commit f7962c0

Browse files
committed
style(documentation): 优化文档图节点和样式主题适配
- 根据当前主题判断是否为深色模式,调整节点填充颜色和描边颜色 - 修改背景色和边框颜色以适配浅色和深
1 parent 5240050 commit f7962c0

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

src/components/documentation/DocumentGraph.jsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ export function DocumentGraph({ currentDoc, backlinksMap, allDocuments, onNodeCl
9595
const isHovered = hoveredNode === node.id;
9696
const radius = node.isCenter ? 25 : 18;
9797

98+
// 判断当前主题是否为深色(只有dark主题是深色背景)
99+
const isDarkTheme = currentTheme === 'dark';
100+
98101
// 绘制节点圆圈
99102
ctx.beginPath();
100103
ctx.arc(node.x, node.y, radius, 0, 2 * Math.PI);
@@ -104,12 +107,12 @@ export function DocumentGraph({ currentDoc, backlinksMap, allDocuments, onNodeCl
104107
} else if (isHovered) {
105108
ctx.fillStyle = '#10b981';
106109
} else {
107-
// 使用浅色背景
108-
ctx.fillStyle = bgColor === '#000000' || bgColor === 'rgb(0, 0, 0)' ? '#444' : '#e5e7eb';
110+
// 根据主题使用不同的节点背景色
111+
ctx.fillStyle = isDarkTheme ? '#444' : '#f3f4f6';
109112
}
110113

111114
ctx.fill();
112-
ctx.strokeStyle = bgColor === '#000000' || bgColor === 'rgb(0, 0, 0)' ? '#666' : '#fff';
115+
ctx.strokeStyle = isDarkTheme ? '#666' : '#d1d5db';
113116
ctx.lineWidth = 2;
114117
ctx.stroke();
115118

src/components/documentation/DocumentGraph.module.css

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
top: 50%;
1313
left: 50%;
1414
transform: translate(-50%, -50%);
15-
z-index: 1000;
15+
z-index: 9999;
1616
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
1717
max-width: 90vw;
1818
max-height: 90vh;
@@ -123,7 +123,7 @@
123123
width: 10px;
124124
height: 10px;
125125
border-radius: 50%;
126-
border: 1px solid white;
126+
border: 1px solid var(--border-color);
127127
flex-shrink: 0;
128128
}
129129

@@ -146,8 +146,8 @@
146146
left: 0;
147147
right: 0;
148148
bottom: 0;
149-
background-color: rgba(0, 0, 0, 0.5);
150-
z-index: -1;
149+
background-color: rgba(0, 0, 0, 0.6);
150+
z-index: 9998;
151151
}
152152

153153
/* 响应式设计 */

0 commit comments

Comments
 (0)