feat: 1.统一右侧抽屉关闭按钮布局 2.统一 UI 组件为 Ant Design 移除 radix-ui、floating-ui 组件 3. 修复 ESLint 文件格式错误的问题
This commit is contained in:
@@ -161,16 +161,18 @@ const JSONEditor = ({
|
||||
}
|
||||
|
||||
// 只在外部值真正改变时更新,避免循环更新
|
||||
const currentObj = keyValueArrayToObject(keyValuePairs);
|
||||
if (JSON.stringify(parsed) !== JSON.stringify(currentObj)) {
|
||||
setKeyValuePairs(objectToKeyValueArray(parsed, keyValuePairs));
|
||||
}
|
||||
setKeyValuePairs((previous) => {
|
||||
const currentObj = keyValueArrayToObject(previous);
|
||||
return JSON.stringify(parsed) === JSON.stringify(currentObj)
|
||||
? previous
|
||||
: objectToKeyValueArray(parsed, previous);
|
||||
});
|
||||
setJsonError('');
|
||||
} catch (error) {
|
||||
console.log('JSON解析失败:', error.message);
|
||||
setJsonError(error.message);
|
||||
}
|
||||
}, [value]);
|
||||
}, [value, keyValueArrayToObject, objectToKeyValueArray]);
|
||||
|
||||
// 外部 value 变化时,若不在手动模式,则同步手动文本
|
||||
useEffect(() => {
|
||||
|
||||
@@ -38,7 +38,10 @@ const readBrand = (key, windowKey) => {
|
||||
|
||||
// 加载文案根据浏览器语言决定,避免 i18n 还没初始化时硬编码中文。
|
||||
const getLoadingText = () => {
|
||||
const lang = ((typeof navigator !== 'undefined' && navigator.language) || 'zh').toLowerCase();
|
||||
const lang = (
|
||||
(typeof navigator !== 'undefined' && navigator.language) ||
|
||||
'zh'
|
||||
).toLowerCase();
|
||||
return lang.startsWith('zh') ? '加载中...' : 'Loading...';
|
||||
};
|
||||
|
||||
|
||||
@@ -47,6 +47,29 @@ import { IconChevronDown, IconChevronUp } from '@/components/ui/icons';
|
||||
* @param {boolean} withCheckbox 是否启用前缀 Checkbox 来控制激活状态
|
||||
* @param {boolean} loading 是否处于加载状态
|
||||
*/
|
||||
const ConditionalTooltipText = ({ text, containerWidth }) => {
|
||||
const textRef = useRef(null);
|
||||
const [isOverflowing, setIsOverflowing] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const el = textRef.current;
|
||||
if (!el) return;
|
||||
setIsOverflowing(el.scrollWidth > el.clientWidth);
|
||||
}, [text, containerWidth]);
|
||||
|
||||
const textElement = (
|
||||
<span ref={textRef} className='sbg-ellipsis'>
|
||||
{text}
|
||||
</span>
|
||||
);
|
||||
|
||||
return isOverflowing ? (
|
||||
<Tooltip content={text}>{textElement}</Tooltip>
|
||||
) : (
|
||||
textElement
|
||||
);
|
||||
};
|
||||
|
||||
const SelectableButtonGroup = ({
|
||||
title,
|
||||
items = [],
|
||||
@@ -63,29 +86,6 @@ const SelectableButtonGroup = ({
|
||||
const [skeletonCount] = useState(12);
|
||||
const [containerRef, containerWidth] = useContainerWidth();
|
||||
|
||||
const ConditionalTooltipText = ({ text }) => {
|
||||
const textRef = useRef(null);
|
||||
const [isOverflowing, setIsOverflowing] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const el = textRef.current;
|
||||
if (!el) return;
|
||||
setIsOverflowing(el.scrollWidth > el.clientWidth);
|
||||
}, [text, containerWidth]);
|
||||
|
||||
const textElement = (
|
||||
<span ref={textRef} className='sbg-ellipsis'>
|
||||
{text}
|
||||
</span>
|
||||
);
|
||||
|
||||
return isOverflowing ? (
|
||||
<Tooltip content={text}>{textElement}</Tooltip>
|
||||
) : (
|
||||
textElement
|
||||
);
|
||||
};
|
||||
|
||||
// 基于容器宽度计算响应式列数和标签显示策略
|
||||
const getResponsiveConfig = () => {
|
||||
if (containerWidth <= 280) return { columns: 1, showTags: true }; // 极窄:1列+标签
|
||||
@@ -207,7 +207,10 @@ const SelectableButtonGroup = ({
|
||||
>
|
||||
<div className='sbg-content'>
|
||||
{item.icon && <span className='sbg-icon'>{item.icon}</span>}
|
||||
<ConditionalTooltipText text={item.label} />
|
||||
<ConditionalTooltipText
|
||||
text={item.label}
|
||||
containerWidth={containerWidth}
|
||||
/>
|
||||
{item.tagCount !== undefined && shouldShowTags && (
|
||||
<Tag
|
||||
className='sbg-tag'
|
||||
@@ -236,7 +239,10 @@ const SelectableButtonGroup = ({
|
||||
>
|
||||
<div className='sbg-content'>
|
||||
{item.icon && <span className='sbg-icon'>{item.icon}</span>}
|
||||
<ConditionalTooltipText text={item.label} />
|
||||
<ConditionalTooltipText
|
||||
text={item.label}
|
||||
containerWidth={containerWidth}
|
||||
/>
|
||||
{item.tagCount !== undefined && shouldShowTags && (
|
||||
<Tag
|
||||
className='sbg-tag'
|
||||
|
||||
Reference in New Issue
Block a user