refactor: 将 formatFileSize 重命名为 formatBytes 并移至通用工具模块

This commit is contained in:
雨霖铃
2026-06-10 00:32:29 +08:00
parent 3f73adc015
commit 355a94d116
4 changed files with 8 additions and 28 deletions
+2 -2
View File
@@ -9,7 +9,7 @@
*/
import { Download } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { formatFileSize } from '@/utils/base64Converter';
import { formatBytes } from '@/utils/format';
import { useI18n } from '@/utils/chromeI18n';
interface DecodeResultPaperProps {
@@ -54,7 +54,7 @@ export default function DecodeResultPaper({
{t('inferredMimeType')}: {mimeType}
</span>
<span className="text-xs text-muted-foreground">
{t('decodedSize')}: {formatFileSize(blobSize)}
{t('decodedSize')}: {formatBytes(blobSize)}
</span>
</div>
@@ -27,7 +27,7 @@ describe('DecodeResultPaper 组件', () => {
expect(screen.getByText(/image\/png/)).toBeInTheDocument();
});
it('应通过 formatFileSize 渲染文件大小', () => {
it('应通过 formatBytes 渲染文件大小', () => {
render(<DecodeResultPaper {...{ ...defaultProps, blobSize: 1536 }} />);
expect(screen.getByText(/1\.5 KB/)).toBeInTheDocument();
});