mirror of
https://github.com/ReaJason/MemShellParty.git
synced 2026-09-22 07:00:43 +08:00
1. 将枚举 Server 改为字符串常量,使得 memshell 和 probeshell 都能共用 2. 移除 memshell 模块直接内置在 generator 中 3. 通用类从 memshell 移动至 javaweb 下,命名修改,增加辨识度
61 lines
2.2 KiB
TypeScript
61 lines
2.2 KiB
TypeScript
import {ChevronDown, ChevronUp, Settings} from "lucide-react";
|
|
import {Fragment, useId, useState} from "react";
|
|
import {FormProvider, type UseFormReturn} from "react-hook-form";
|
|
import {useTranslation} from "react-i18next";
|
|
import {Button} from "@/components/ui/button";
|
|
import {FormField, FormFieldItem, FormFieldLabel} from "@/components/ui/form.tsx";
|
|
import {Input} from "@/components/ui/input.tsx";
|
|
import type {MemShellFormSchema} from "@/types/schema.ts";
|
|
|
|
export function OptionalClassFormField({ form }: Readonly<{ form: UseFormReturn<MemShellFormSchema> }>) {
|
|
const { t } = useTranslation();
|
|
const [showAdvanced, setShowAdvanced] = useState(false);
|
|
const shellClassNameId = useId();
|
|
const injectClassNameId = useId();
|
|
return (
|
|
<Fragment>
|
|
<div className="pt-2">
|
|
<Button
|
|
type="button"
|
|
variant="outline"
|
|
size="sm"
|
|
onClick={() => setShowAdvanced(!showAdvanced)}
|
|
className="flex items-center gap-2"
|
|
>
|
|
<Settings className="h-4 w-4" />
|
|
{t("classNameOptions")}
|
|
{showAdvanced ? <ChevronUp className="h-4 w-4" /> : <ChevronDown className="h-4 w-4" />}
|
|
</Button>
|
|
</div>
|
|
{showAdvanced && (
|
|
<FormProvider {...form}>
|
|
<FormField
|
|
control={form.control}
|
|
name="shellClassName"
|
|
render={({ field }) => (
|
|
<FormFieldItem>
|
|
<FormFieldLabel htmlFor={shellClassNameId}>
|
|
{t("mainConfig.shellClassName")} {t("optional")}
|
|
</FormFieldLabel>
|
|
<Input id={shellClassNameId} {...field} placeholder={t("placeholders.input")} />
|
|
</FormFieldItem>
|
|
)}
|
|
/>
|
|
<FormField
|
|
control={form.control}
|
|
name="injectorClassName"
|
|
render={({ field }) => (
|
|
<FormFieldItem>
|
|
<FormFieldLabel htmlFor={injectClassNameId}>
|
|
{t("mainConfig.injectorClassName")} {t("optional")}
|
|
</FormFieldLabel>
|
|
<Input id={injectClassNameId} {...field} placeholder={t("placeholders.input")} />
|
|
</FormFieldItem>
|
|
)}
|
|
/>
|
|
</FormProvider>
|
|
)}
|
|
</Fragment>
|
|
);
|
|
}
|