在 LabelStudio 编辑器中出现了一个橙色到粉色的渐变遮罩,覆盖了整个标注界面。
这个遮罩是 LabelStudio 的 relations-overlay 组件,它是一个 SVG 覆盖层,用于显示关系标注的连接线。
相关文件:
web/libs/editor/src/components/InteractiveOverlays/RelationsOverlay.jsxweb/libs/editor/src/components/InteractiveOverlays/RelationsOverlay.module.scss问题原因:
在组件的样式文件中添加以下 CSS 规则,强制将 relations-overlay 和 lsf-container 的背景设置为透明:
// Fix for relations-overlay background (orange gradient issue)
:global(.relations-overlay) {
background: transparent !important;
fill: none !important;
}
:global(.lsf-container) {
background: transparent !important;
}
测试页面样式:
web/apps/lq_label/src/views/editor-test/editor-test.module.scss标注页面样式:
web/apps/lq_label/src/views/annotation-view/annotation-view.module.scss.relations-overlay 元素background 和 fill 属性为 transparent 或 none这是 LabelStudio 用于显示关系标注的组件:
const containerStyles = ["relations-overlay", styles.container];
return (
<svg
className={containerStyles.join(" ")}
ref={this.rootNode}
xmlns="http://www.w3.org/2000/svg"
style={style}
>
{/* SVG content */}
</svg>
);
:global() 选择器来覆盖全局样式!important 确保样式优先级最高background 和 fill 属性以确保完全透明如果将来遇到类似的样式问题:
使用浏览器开发者工具:
搜索源代码:
添加覆盖样式:
.module.scss 文件中添加全局样式覆盖:global() 选择器!important 提高优先级如果遇到其他 LabelStudio 样式问题,可以参考以下常见类名:
.lsf-wrapper - 编辑器主容器.lsf-editor - 编辑器内容区域.lsf-tabs-panel__body - 标签面板主体.lsf-panel-tabs__tab - 面板标签.lsf-sidepanels - 侧边栏面板.relations-overlay - 关系覆盖层(本次修复的问题).lsf-container - 容器元素所有这些类名都可以在 web/libs/editor 中找到对应的组件和样式定义。