Commit 5770bb5b by 李伟康

refactor(ApprovalChainPreview): 重构审批链预览组件布局,优化连接线渲染

提取统一的连接线颜色工具函数,使用flex布局替代绝对定位优化代码结构,调整节点内部排版
1 parent fcc0d0da
Pipeline #362 for 5770bb5b failed in 0 seconds
......@@ -80,18 +80,17 @@ function NodeIcon({ status, index }: NodeIconProps) {
);
}
const lineColor = (status: ChainNodeStatus) => (status === 'done' ? '#16A34A' : '#E5E7EB');
function NodeLine({ status }: { status: ChainNodeStatus }) {
const bg = status === 'done' ? '#16A34A' : '#E5E7EB';
return (
<div
style={{
position: 'absolute',
top: 15,
left: '70%',
width: '60%',
flex: 1,
height: 2,
background: bg,
zIndex: 0,
background: lineColor(status),
alignSelf: 'flex-start',
marginTop: 15,
}}
/>
);
......@@ -161,65 +160,72 @@ export function ApprovalChainPreview({
}
>
<div style={{ display: 'flex', padding: '20px 8px 8px' }}>
{finalNodes.map((n, i) => (
<div
key={i}
style={{
flex: 1,
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
position: 'relative',
}}
>
{i < finalNodes.length - 1 && <NodeLine status={n.status} />}
{finalNodes.map((n, i) => {
const prev = finalNodes[i - 1];
const hasLeft = i > 0;
const hasRight = i < finalNodes.length - 1;
return (
<div
key={i}
style={{
position: 'relative',
zIndex: 1,
flex: 1,
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
alignItems: 'flex-start',
}}
>
<NodeIcon status={n.status} index={i} />
<div style={{ flex: 1 }}>{hasLeft && <NodeLine status={prev.status} />}</div>
<div
style={{
marginTop: 14,
fontSize: 14,
fontWeight: 600,
color:
n.status === 'active' ? '#2B5CE6' : n.status === 'done' ? '#16A34A' : '#6B7280',
textAlign: 'center',
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
flex: 'none',
}}
>
{n.title}
</div>
<div
style={{
marginTop: 4,
fontSize: 12,
color: '#9CA3AF',
textAlign: 'center',
}}
>
{n.subtitle}
</div>
{n.time && (
<NodeIcon status={n.status} index={i} />
<div
style={{
marginTop: 14,
fontSize: 14,
fontWeight: 600,
color:
n.status === 'active'
? '#2B5CE6'
: n.status === 'done'
? '#16A34A'
: '#6B7280',
textAlign: 'center',
}}
>
{n.title}
</div>
<div
style={{
marginTop: 4,
fontSize: 11,
color: '#C7CDD6',
fontSize: 12,
color: '#9CA3AF',
textAlign: 'center',
}}
>
{n.time}
{n.subtitle}
</div>
)}
{n.time && (
<div
style={{
marginTop: 4,
fontSize: 11,
color: '#C7CDD6',
textAlign: 'center',
}}
>
{n.time}
</div>
)}
</div>
<div style={{ flex: 1 }}>{hasRight && <NodeLine status={n.status} />}</div>
</div>
</div>
))}
);
})}
</div>
</UCard>
);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!