mirror of
https://github.com/ReaJason/MemShellParty.git
synced 2026-09-21 22:50:42 +08:00
style: lint
This commit is contained in:
@@ -3,7 +3,10 @@ import { GenerateResult } from "@/types/shell";
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Button } from "../ui/button";
|
import { Button } from "../ui/button";
|
||||||
|
|
||||||
export function JarResult({ packResult, generateResult }: Readonly<{ packResult: string; generateResult?: GenerateResult }>) {
|
export function JarResult({
|
||||||
|
packResult,
|
||||||
|
generateResult,
|
||||||
|
}: Readonly<{ packResult: string; generateResult?: GenerateResult }>) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center justify-center">
|
<div className="flex items-center justify-center">
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { GenerateResult } from "@/types/shell";
|
import { GenerateResult } from "@/types/shell";
|
||||||
import { TFunction } from "i18next";
|
import { TFunction } from "i18next";
|
||||||
import { Fragment } from "react/jsx-runtime";
|
|
||||||
import { CodeViewer } from "../code-viewer";
|
import { CodeViewer } from "../code-viewer";
|
||||||
import { AgentResult } from "./agent";
|
import { AgentResult } from "./agent";
|
||||||
import { JarResult } from "./jar-result";
|
import { JarResult } from "./jar-result";
|
||||||
|
|||||||
@@ -27,11 +27,11 @@ export function downloadBytes(base64String: string, className?: string, jarName?
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function formatBytes(bytes: number) {
|
export function formatBytes(bytes: number) {
|
||||||
if (bytes === 0) return '0 Bytes';
|
if (bytes === 0) return "0 Bytes";
|
||||||
if (Number.isNaN(bytes) || !Number.isFinite(bytes)) return 'N/A';
|
if (Number.isNaN(bytes) || !Number.isFinite(bytes)) return "N/A";
|
||||||
|
|
||||||
const k = 1024;
|
const k = 1024;
|
||||||
const sizes = ['Bytes', 'KB', 'MB']; // Add more units like GB, TB if needed
|
const sizes = ["Bytes", "KB", "MB"]; // Add more units like GB, TB if needed
|
||||||
|
|
||||||
if (bytes < k) {
|
if (bytes < k) {
|
||||||
return `${bytes.toFixed(0)} ${sizes[0]}`; // Bytes, no decimal
|
return `${bytes.toFixed(0)} ${sizes[0]}`; // Bytes, no decimal
|
||||||
@@ -40,10 +40,10 @@ export function formatBytes(bytes: number) {
|
|||||||
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||||
|
|
||||||
// Prefer MB if KB value is 1000 or more, or if it's already in MB (i >= 2)
|
// Prefer MB if KB value is 1000 or more, or if it's already in MB (i >= 2)
|
||||||
if (i >= 2 || (bytes / k ** 1) >= 1000) {
|
if (i >= 2 || bytes / k ** 1 >= 1000) {
|
||||||
const mbValue = Number.parseFloat((bytes / k ** 2).toFixed(2));
|
const mbValue = Number.parseFloat((bytes / k ** 2).toFixed(2));
|
||||||
return `${mbValue} ${sizes[2]}`;
|
return `${mbValue} ${sizes[2]}`;
|
||||||
}
|
}
|
||||||
const kbValue = Number.parseFloat((bytes / k ** 1).toFixed(1));
|
const kbValue = Number.parseFloat((bytes / k ** 1).toFixed(1));
|
||||||
return `${kbValue} ${sizes[1]}`;
|
return `${kbValue} ${sizes[1]}`;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user