refactor: rename

1. 将枚举 Server 改为字符串常量,使得 memshell 和 probeshell 都能共用
2. 移除 memshell 模块直接内置在 generator 中
3. 通用类从 memshell 移动至 javaweb 下,命名修改,增加辨识度
This commit is contained in:
ReaJason
2025-08-13 23:53:40 +08:00
parent a513e44c96
commit b2c614eea4
354 changed files with 1094 additions and 1387 deletions
+10 -10
View File
@@ -11,16 +11,16 @@ import ShellResult from "@/components/memshell/shell-result";
import {Button} from "@/components/ui/button";
import {Form} from "@/components/ui/form.tsx";
import {env} from "@/config.ts";
import {type ShellFormSchema, shellFormSchema, useYupValidationResolver} from "@/types/schema.ts";
import {
type APIErrorResponse,
type GenerateResponse,
type GenerateResult,
type MainConfig,
type MemShellGenerateResponse,
type MemShellResult,
type PackerConfig,
type ServerConfig,
ShellToolType,
} from "@/types/shell.ts";
} from "@/types/memshell";
import {type MemShellFormSchema, memShellFormSchema, useYupValidationResolver} from "@/types/schema.ts";
import {transformToPostData} from "@/utils/transformer.ts";
export default function MemShellPage() {
@@ -52,7 +52,7 @@ export default function MemShellPage() {
const { t } = useTranslation();
const form = useForm({
resolver: useYupValidationResolver(shellFormSchema, t),
resolver: useYupValidationResolver(memShellFormSchema, t),
defaultValues: {
server: urlParams.server ?? "Tomcat",
serverVersion: urlParams.serverVersion ?? "unknown",
@@ -79,15 +79,15 @@ export default function MemShellPage() {
const [packResult, setPackResult] = useState<string | undefined>();
const [allPackResults, setAllPackResults] = useState<Map<string, string> | undefined>();
const [generateResult, setGenerateResult] = useState<GenerateResult>();
const [generateResult, setGenerateResult] = useState<MemShellResult>();
const [packMethod, setPackMethod] = useState<string>("");
const [isActionPending, startTransition] = useTransition();
const onSubmit = async (data: ShellFormSchema) => {
const onSubmit = async (data: MemShellFormSchema) => {
startTransition(async () => {
try {
const postData = transformToPostData(data);
const response = await fetch(`${env.API_URL}/generate`, {
const response = await fetch(`${env.API_URL}/memshell/generate`, {
method: "POST",
headers: {
"Content-Type": "application/json",
@@ -101,8 +101,8 @@ export default function MemShellPage() {
return;
}
const result = (await response.json()) as GenerateResponse;
setGenerateResult(result.generateResult);
const result = (await response.json()) as MemShellGenerateResponse;
setGenerateResult(result.memShellResult);
setPackResult(result.packResult);
setAllPackResults(result.allPackResults);
setPackMethod(data.packingMethod);
@@ -4,20 +4,20 @@ import { useState, useTransition } from "react";
import { useForm } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { toast } from "sonner";
import MainConfigCard from "@/components/probe/main-config-card";
import PackageConfigCard from "@/components/probe/package-config-card";
import ShellResult from "@/components/probe/shell-result";
import MainConfigCard from "@/components/probeshell/main-config-card";
import PackageConfigCard from "@/components/probeshell/package-config-card";
import ShellResult from "@/components/probeshell/shell-result";
import { Button } from "@/components/ui/button";
import {
Form,
} from "@/components/ui/form";
import { env } from "@/config";
import type { ProbeGenerateResponse, ProbeGenerateResult } from "@/types/probe";
import { type ProbeFormSchema, probeFormSchema, useYupValidationProbeResolver } from "@/types/schema";
import type { APIErrorResponse, PackerConfig, ServerConfig } from "@/types/shell";
import type { APIErrorResponse, PackerConfig, ServerConfig } from "@/types/memshell";
import type { ProbeShellGenerateResponse, ProbeShellResult } from "@/types/probeshell";
import { type ProbeShellFormSchema, probeShellFormSchema, useYupValidationProbeResolver } from "@/types/schema";
import { transformToProbePostData } from "@/utils/transformer";
export default function ProbeGenerator() {
export default function ProbeShellGenerator() {
const { data: serverConfig } = useQuery<ServerConfig>({
queryKey: ["serverConfig"],
queryFn: async () => {
@@ -36,8 +36,8 @@ export default function ProbeGenerator() {
const { t } = useTranslation();
const form = useForm<ProbeFormSchema>({
resolver: useYupValidationProbeResolver(probeFormSchema, t),
const form = useForm<ProbeShellFormSchema>({
resolver: useYupValidationProbeResolver(probeShellFormSchema, t),
defaultValues: {
probeMethod: "Sleep",
probeContent: "Server",
@@ -52,11 +52,11 @@ export default function ProbeGenerator() {
const [packResult, setPackResult] = useState<string | undefined>();
const [allPackResults, setAllPackResults] = useState<Map<string, string> | undefined>();
const [generateResult, setGenerateResult] = useState<ProbeGenerateResult>();
const [generateResult, setGenerateResult] = useState<ProbeShellResult>();
const [packMethod, setPackMethod] = useState<string>("");
const [isActionPending, startTransition] = useTransition();
const onSubmit = async (data: ProbeFormSchema) => {
const onSubmit = async (data: ProbeShellFormSchema) => {
startTransition(async () => {
try {
const postData = transformToProbePostData(data);
@@ -74,8 +74,8 @@ export default function ProbeGenerator() {
return;
}
const result = (await response.json()) as ProbeGenerateResponse;
setGenerateResult(result.probeResult);
const result = (await response.json()) as ProbeShellGenerateResponse;
setGenerateResult(result.probeShellResult);
setPackResult(result.packResult);
setAllPackResults(result.allPackResults);
setPackMethod(data.packingMethod);