Files
MemShellParty/web/app/components/memshell/results/jar-result.tsx
T
2026-04-26 21:33:15 +08:00

59 lines
1.8 KiB
TypeScript

import type { MemShellResult } from "@/types/memshell";
import { ScrollTextIcon } from "lucide-react";
import { useTranslation } from "react-i18next";
import { Button } from "@/components/ui/button";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Separator } from "@/components/ui/separator";
import { downloadBytes, formatBytes } from "@/lib/utils";
export function JarResult({
packMethod,
packResult,
generateResult,
}: Readonly<{
packMethod: string;
packResult: string;
generateResult?: MemShellResult;
}>) {
const { t } = useTranslation();
return (
<Card>
<CardHeader>
<CardTitle className="text-md flex items-center gap-2">
<ScrollTextIcon className="h-5" />
<span>{t("common:usage")}</span>
</CardTitle>
</CardHeader>
<CardContent>
<ol className="list-inside list-decimal space-y-4 text-sm">
<li className="flex items-center justify-between">
<span>
{t("common:download")} {packMethod}Shell.jar ({formatBytes(atob(packResult).length)})
</span>
<Button
size="sm"
variant="outline"
className="w-28"
type="button"
onClick={() =>
downloadBytes(
packResult,
undefined,
`${generateResult?.shellConfig.server}${generateResult?.shellConfig.shellTool}MemShell`,
)
}
>
{t("common:download")}
</Button>
</li>
<Separator />
<li>{t("memshell:tips.download-jar")}</li>
<li>{t("memshell:tips.trigger-injector-class-loading")}</li>
</ol>
</CardContent>
</Card>
);
}