diff --git a/web/app/dashboard/config/page.tsx b/web/app/dashboard/config/page.tsx index 31ab26e..83317a7 100644 --- a/web/app/dashboard/config/page.tsx +++ b/web/app/dashboard/config/page.tsx @@ -82,7 +82,8 @@ export default function ConfigPage() { extensionMap: {} as Record, sizeThreshold: 0, maxSize: 0, - sizeUnit: 'MB' as 'B' | 'KB' | 'MB' | 'GB', + sizeThresholdUnit: 'MB' as 'B' | 'KB' | 'MB' | 'GB', + maxSizeUnit: 'MB' as 'B' | 'KB' | 'MB' | 'GB', }) const [fixedPathDialogOpen, setFixedPathDialogOpen] = useState(false) const [editingFixedPath, setEditingFixedPath] = useState(null) @@ -101,7 +102,8 @@ export default function ConfigPage() { defaultTarget: string; sizeThreshold: number; maxSize: number; - sizeUnit: 'B' | 'KB' | 'MB' | 'GB'; + sizeThresholdUnit: 'B' | 'KB' | 'MB' | 'GB'; + maxSizeUnit: 'B' | 'KB' | 'MB' | 'GB'; } | null>(null); const [deletingPath, setDeletingPath] = useState(null) @@ -222,7 +224,8 @@ export default function ConfigPage() { extensionMap: {}, sizeThreshold: 0, maxSize: 0, - sizeUnit: 'MB', + sizeThresholdUnit: 'MB', + maxSizeUnit: 'MB', }) } }) @@ -257,7 +260,7 @@ export default function ConfigPage() { if (!config) return const data = editingPathData || newPathData - const { path, defaultTarget, sizeThreshold, maxSize, sizeUnit } = data + const { path, defaultTarget, sizeThreshold, maxSize, sizeThresholdUnit, maxSizeUnit } = data if (!path || !defaultTarget) { toast({ @@ -269,8 +272,8 @@ export default function ConfigPage() { } // 转换大小为字节 - const sizeThresholdBytes = convertToBytes(sizeThreshold, sizeUnit) - const maxSizeBytes = convertToBytes(maxSize, sizeUnit) + const sizeThresholdBytes = convertToBytes(sizeThreshold, sizeThresholdUnit) + const maxSizeBytes = convertToBytes(maxSize, maxSizeUnit) // 验证阈值 if (maxSizeBytes > 0 && sizeThresholdBytes >= maxSizeBytes) { @@ -308,7 +311,8 @@ export default function ConfigPage() { extensionMap: {}, sizeThreshold: 0, maxSize: 0, - sizeUnit: 'MB', + sizeThresholdUnit: 'MB', + maxSizeUnit: 'MB', }) } @@ -547,7 +551,8 @@ export default function ConfigPage() { extensionMap: {}, sizeThreshold: 0, maxSize: 0, - sizeUnit: 'MB', + sizeThresholdUnit: 'MB', + maxSizeUnit: 'MB', }) setPathDialogOpen(true) } @@ -667,18 +672,19 @@ export default function ConfigPage() { defaultTarget: target, sizeThreshold: 0, maxSize: 0, - sizeUnit: 'MB' + sizeThresholdUnit: 'MB', + maxSizeUnit: 'MB' }) } else { - const sizeThreshold = target.SizeThreshold || 0 - const maxSize = target.MaxSize || 0 - const { value, unit } = convertBytesToUnit(sizeThreshold) + const { value: thresholdValue, unit: thresholdUnit } = convertBytesToUnit(target.SizeThreshold || 0) + const { value: maxValue, unit: maxUnit } = convertBytesToUnit(target.MaxSize || 0) setEditingPathData({ path, defaultTarget: target.DefaultTarget, - sizeThreshold: value, - maxSize: maxSize, - sizeUnit: unit + sizeThreshold: thresholdValue, + maxSize: maxValue, + sizeThresholdUnit: thresholdUnit, + maxSizeUnit: maxUnit }) } setPathDialogOpen(true) @@ -809,18 +815,18 @@ export default function ConfigPage() { /> { const unit = e.target.value as 'B' | 'KB' | 'MB' | 'GB' if (editingPathData) { setEditingPathData({ ...editingPathData, - sizeUnit: unit, + maxSizeUnit: unit, }) } else { setNewPathData({ ...newPathData, - sizeUnit: unit, + maxSizeUnit: unit, }) } }} @@ -892,7 +898,8 @@ export default function ConfigPage() { 路径 默认目标 - 大小阈值 + 最小阈值 + 最大阈值 扩展名映射 操作 @@ -905,78 +912,70 @@ export default function ConfigPage() { {typeof target === 'string' ? target : target.DefaultTarget} - {typeof target === 'object' && target.SizeThreshold ? ( - - {formatBytes(target.SizeThreshold)} - - ) : '-'} - - - {typeof target === 'object' && target.ExtensionMap ? ( -
- - - - 扩展名 - 目标地址 - 操作 - - - - {Object.entries(target.ExtensionMap).map(([ext, url]) => ( - - {ext} - - {truncateUrl(url)} - - -
- - -
-
-
- ))} -
-
-
- -
-
- ) : ( -
- + {typeof target === 'object' && ( +
+
最小: {target.SizeThreshold ? formatBytes(target.SizeThreshold) : '-'}
+
最大: {target.MaxSize ? formatBytes(target.MaxSize) : '-'}
)} + + {typeof target === 'object' && target.ExtensionMap && Object.keys(target.ExtensionMap).length > 0 ? ( + + + + 扩展名 + 目标地址 + 操作 + + + + {Object.entries(target.ExtensionMap).map(([ext, url]) => ( + + {ext} + + {truncateUrl(url)} + + +
+ + +
+
+
+ ))} +
+
+ ) : ( +
+ 暂无扩展名映射 +
+ )} +
+ +
+