Merge branch 'shiy' into awen-dev

This commit is contained in:
2025-04-08 16:55:24 +08:00
52 changed files with 14755 additions and 1679 deletions
+5 -2
View File
@@ -8,6 +8,7 @@ interface StatusDotProps {
className?: string;
size?: 'default' | 'sm' | 'lg';
pulse?: boolean;
align?: 'left' | 'center' | 'right';
}
export function StatusDot({
@@ -15,7 +16,8 @@ export function StatusDot({
text,
className = '',
size = 'default',
pulse = false
pulse = false,
align = 'left'
}: StatusDotProps) {
// 如果status是布尔值,则转换为对应的状态类型
const statusType = typeof status === 'boolean'
@@ -32,9 +34,10 @@ export function StatusDot({
const sizeClass = size !== 'default' ? `status-dot-${size}` : '';
const pulseClass = pulse ? 'status-dot-pulse' : '';
const alignClass = align === 'center' ? 'justify-center' : align === 'right' ? 'justify-end' : 'justify-start';
return (
<span className={`status-dot-with-text ${className}`}>
<span className={`status-dot-with-text ${alignClass} ${className}`}>
<span className={`status-dot status-dot-${statusType} ${sizeClass} ${pulseClass}`}></span>
<span className="status-dot-text">{statusText}</span>
</span>
+11 -9
View File
@@ -12,6 +12,7 @@ interface UploadAreaProps {
mainText?: string;
tipText?: ReactNode;
disabled?: boolean;
shouldPreventFileSelect?: boolean;
}
export interface UploadAreaRef {
@@ -31,7 +32,8 @@ export const UploadArea = forwardRef<UploadAreaRef, UploadAreaProps>(({
buttonText = "选择文件",
mainText = "点击或拖拽文件到此区域上传",
tipText = "",
disabled = false
disabled = false,
shouldPreventFileSelect = false
}, ref) => {
const fileInputRef = useRef<HTMLInputElement>(null);
const [isDragOver, setIsDragOver] = useState(false);
@@ -48,10 +50,10 @@ export const UploadArea = forwardRef<UploadAreaRef, UploadAreaProps>(({
}));
const handleClick = useCallback(() => {
if (!disabled && fileInputRef.current) {
if (!disabled && !shouldPreventFileSelect && fileInputRef.current) {
fileInputRef.current.click();
}
}, [disabled]);
}, [disabled, shouldPreventFileSelect]);
const handleFileChange = useCallback(() => {
if (fileInputRef.current?.files?.length) {
@@ -61,10 +63,10 @@ export const UploadArea = forwardRef<UploadAreaRef, UploadAreaProps>(({
const handleDragOver = useCallback((e: React.DragEvent<HTMLDivElement>) => {
e.preventDefault();
if (!disabled) {
if (!disabled && !shouldPreventFileSelect) {
setIsDragOver(true);
}
}, [disabled]);
}, [disabled, shouldPreventFileSelect]);
const handleDragLeave = useCallback(() => {
setIsDragOver(false);
@@ -74,17 +76,17 @@ export const UploadArea = forwardRef<UploadAreaRef, UploadAreaProps>(({
e.preventDefault();
setIsDragOver(false);
if (!disabled && e.dataTransfer.files.length > 0) {
if (!disabled && !shouldPreventFileSelect && e.dataTransfer.files.length > 0) {
onFilesSelected(e.dataTransfer.files);
}
}, [disabled, onFilesSelected]);
}, [disabled, shouldPreventFileSelect, onFilesSelected]);
const handleKeyDown = useCallback((e: React.KeyboardEvent<HTMLDivElement>) => {
if ((e.key === 'Enter' || e.key === ' ') && !disabled) {
if ((e.key === 'Enter' || e.key === ' ') && !disabled && !shouldPreventFileSelect) {
e.preventDefault();
handleClick();
}
}, [handleClick, disabled]);
}, [handleClick, disabled, shouldPreventFileSelect]);
return (
<div