import { UrlPatternTip } from "@/components/tips/url-pattern-tip.tsx"; import { FormControl, FormDescription, FormField, FormItem, FormLabel } from "@/components/ui/form.tsx"; import { Input } from "@/components/ui/input.tsx"; import { Label } from "@/components/ui/label.tsx"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select.tsx"; import { Switch } from "@/components/ui/switch.tsx"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { FormSchema } from "@/types/schema.ts"; import { MainConfig } from "@/types/shell.ts"; import { JreTip } from "@/components/tips/jre-tip.tsx"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card.tsx"; import { cn } from "@/lib/utils.ts"; import { ArrowUpRightIcon, ServerIcon } from "lucide-react"; import { useState } from "react"; import { FormProvider, UseFormReturn } from "react-hook-form"; import { useTranslation } from "react-i18next"; const JDKVersion = [ { name: "Java6", value: "50" }, { name: "Java8", value: "52" }, { name: "Java9", value: "53" }, { name: "Java11", value: "55" }, { name: "Java17", value: "61" }, { name: "Java21", value: "65" }, ]; export function MainConfigCard({ mainConfig, form, servers, }: { mainConfig: MainConfig | undefined; form: UseFormReturn; servers?: string[]; }) { const [shellToolMap, setShellToolMap] = useState<{ [toolName: string]: string[] }>(); const [shellTools, setShellTools] = useState([ "Behinder", "Godzilla", "Command", "AntSword", "Suo5", "Neo-reGeorg", ]); const [shellTypes, setShellTypes] = useState([]); const shellTool = form.watch("shellTool"); const { t } = useTranslation(); const handleServerChange = (value: string) => { if (mainConfig) { const newShellToolMap = mainConfig[value]; setShellToolMap(newShellToolMap); const newShellTools = Object.keys(newShellToolMap); setShellTools(newShellTools); if (newShellTools.length > 0) { const firstTool = newShellTools[0]; setShellTypes(newShellToolMap[firstTool]); form.setValue("shellTool", firstTool); } else { setShellTypes([]); } if ( (value === "SpringWebFlux" || value === "XXLJOB") && Number.parseInt(form.getValues("targetJdkVersion") as string) < 52 ) { form.setValue("targetJdkVersion", "52"); } else { form.resetField("targetJdkVersion"); } form.resetField("bypassJavaModule"); form.resetField("shellTool"); form.resetField("shellType"); } }; const handleShellToolChange = (value: string) => { const resetCommand = () => { form.resetField("commandParamName"); }; const resetGodzilla = () => { form.resetField("godzillaKey"); form.resetField("godzillaPass"); form.resetField("godzillaHeaderName"); form.resetField("godzillaHeaderValue"); }; const resetBehinder = () => { form.resetField("behinderPass"); form.resetField("behinderHeaderName"); form.resetField("behinderHeaderValue"); }; if (shellToolMap) { setShellTypes(shellToolMap[value]); form.resetField("urlPattern"); form.resetField("shellType"); form.resetField("shellClassName"); form.resetField("injectorClassName"); if (value === "Godzilla") { resetGodzilla(); } else if (value === "Behinder") { resetBehinder(); } else if (value === "Command") { resetCommand(); } } form.setValue("shellTool", value); }; return ( {t("configs.main-config")}
( {t("mainConfig.server")} {t("tips.targetServerNotFound")}  {t("tips.targetServerRequest")} )} /> ( )} />
( {t("mainConfig.debug")} )} /> ( )} />
{ handleShellToolChange(v); }} className="w-full" > 3 ? "grid-flow-col" : `grid-cols-${shellTools.length}`)} > {shellTools.map((shellTool) => ( {shellTool} ))}
); } function ShellTypeFormField({ form, shellTypes }: { form: UseFormReturn; shellTypes: Array }) { const { t } = useTranslation(); return ( ( {t("mainConfig.shellMountType")} )} /> ); } function UrlPatternFormField({ form }: { form: UseFormReturn }) { const { t } = useTranslation(); return ( ( )} /> ); } function OptionalClassFormField({ form }: { form: UseFormReturn }) { const { t } = useTranslation(); return ( ( {t("mainConfig.shellClassName")} {t("optional")} )} /> ( {t("mainConfig.injectorClassName")} {t("optional")} )} /> ); } function BehinderTabContent({ form, shellTypes }: { form: UseFormReturn; shellTypes: Array }) { const { t } = useTranslation(); return (
( {t("shellToolConfig.behinderPass")} )} />
( {t("shellToolConfig.headerName")} )} /> ( {t("shellToolConfig.headerValue")} )} />
); } function GodzillaTabContent({ form, shellTypes }: { form: UseFormReturn; shellTypes: Array }) { const { t } = useTranslation(); return (
( {t("shellToolConfig.pass")} )} /> ( {t("shellToolConfig.key")} )} /> ( {t("shellToolConfig.headerName")} )} /> ( {t("shellToolConfig.headerValue")} )} />
); } function CommandTabContent({ form, shellTypes }: { form: UseFormReturn; shellTypes: Array }) { const { t } = useTranslation(); return (
( {t("shellToolConfig.paramName")} )} />
); } function AntSwordTabContent() { return (
WIP
); } function Suo5TabContent() { return (
WIP
); } function NeoreGeorgTabContent() { return (
WIP
); }