mirror of
https://github.com/ReaJason/MemShellParty.git
synced 2026-09-23 15:31:53 +08:00
refactor(ui): separate each component into single file
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
import { GenerateResult } from "@/types/shell";
|
||||
import { TFunction } from "i18next";
|
||||
import { Fragment } from "react/jsx-runtime";
|
||||
import { CodeViewer } from "../code-viewer";
|
||||
import { AgentResult } from "./agent";
|
||||
import { JarResult } from "./jar-result";
|
||||
import { MultiPackResult } from "./multi-packer";
|
||||
|
||||
export function ResultComponent({
|
||||
packResult,
|
||||
allPackResults,
|
||||
packMethod,
|
||||
t,
|
||||
generateResult,
|
||||
}: {
|
||||
packResult: string | undefined;
|
||||
allPackResults: Map<string, string> | undefined;
|
||||
packMethod: string;
|
||||
t: TFunction;
|
||||
generateResult?: GenerateResult;
|
||||
}) {
|
||||
const showCode = packMethod === "JSP";
|
||||
const isAgent = packMethod.startsWith("Agent");
|
||||
const isJar = packMethod === "Jar";
|
||||
if (allPackResults) {
|
||||
return <MultiPackResult allPackResults={allPackResults} packMethod={packMethod} t={t} />;
|
||||
}
|
||||
|
||||
if (isAgent) {
|
||||
return <AgentResult packResult={packResult ?? ""} generateResult={generateResult} />;
|
||||
}
|
||||
if (isJar) {
|
||||
return <JarResult packResult={packResult ?? ""} generateResult={generateResult} />;
|
||||
}
|
||||
if (!isAgent && !isJar) {
|
||||
return (
|
||||
<Fragment>
|
||||
<CodeViewer
|
||||
code={packResult ?? ""}
|
||||
header={
|
||||
<div className="flex items-center justify-between text-xs gap-2">
|
||||
<span>
|
||||
{t("packageConfig.title")}:{packMethod}
|
||||
</span>
|
||||
<span className="text-muted-foreground">({packResult?.length})</span>
|
||||
</div>
|
||||
}
|
||||
wrapLongLines={!showCode}
|
||||
showLineNumbers={showCode}
|
||||
language={showCode ? "java" : "text"}
|
||||
height={350}
|
||||
/>
|
||||
</Fragment>
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
Reference in New Issue
Block a user