Skip to content

Commit 4350407

Browse files
committed
style(web): format code
1 parent 9a1df0a commit 4350407

40 files changed

+551
-308
lines changed

web/biome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"formatter": {
2222
"enabled": true,
2323
"indentStyle": "space",
24-
"includes": ["!**/test/snapshots/**/*"]
24+
"indentWidth": 2
2525
},
2626
"linter": {
2727
"enabled": true,

web/bun.lockb

32 Bytes
Binary file not shown.

web/copy-build.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
1+
import {
2+
existsSync,
3+
mkdirSync,
4+
readdirSync,
5+
readFileSync,
6+
rmSync,
7+
writeFileSync,
8+
} from "node:fs";
29
import { cp } from "node:fs/promises";
310
import { join, resolve } from "node:path";
411

@@ -44,7 +51,9 @@ async function main() {
4451
const INDEX_DEST = join(TEMPLATES_DIR, "index.html");
4552

4653
if (!existsSync(INDEX_SRC)) {
47-
console.error(`Error: ${INDEX_SRC} does not exist. Make sure you built the frontend project first.`);
54+
console.error(
55+
`Error: ${INDEX_SRC} does not exist. Make sure you built the frontend project first.`,
56+
);
4857
process.exit(1);
4958
}
5059

web/src/components/code-viewer.tsx

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,30 @@
1-
import type {VariantProps} from "class-variance-authority";
2-
import {Check, Copy} from "lucide-react";
3-
import {type HTMLProps, type ReactNode, useCallback, useEffect, useState} from "react";
4-
import {CopyToClipboard} from "react-copy-to-clipboard";
5-
import {useTranslation} from "react-i18next";
6-
import {PrismLight as SyntaxHighlighter} from "react-syntax-highlighter";
1+
import type { VariantProps } from "class-variance-authority";
2+
import { Check, Copy } from "lucide-react";
3+
import {
4+
type HTMLProps,
5+
type ReactNode,
6+
useCallback,
7+
useEffect,
8+
useState,
9+
} from "react";
10+
import { CopyToClipboard } from "react-copy-to-clipboard";
11+
import { useTranslation } from "react-i18next";
12+
import { PrismLight as SyntaxHighlighter } from "react-syntax-highlighter";
713
import java from "react-syntax-highlighter/dist/esm/languages/prism/java";
8-
import {materialDark} from "react-syntax-highlighter/dist/esm/styles/prism";
9-
import {toast} from "sonner";
10-
import {Button, type buttonVariants} from "@/components/ui/button";
11-
import {cn} from "@/lib/utils";
14+
import { materialDark } from "react-syntax-highlighter/dist/esm/styles/prism";
15+
import { toast } from "sonner";
16+
import { Button, type buttonVariants } from "@/components/ui/button";
17+
import { cn } from "@/lib/utils";
1218

1319
SyntaxHighlighter.registerLanguage("java", java);
1420
interface CopyButtonProps extends React.ComponentProps<"button"> {
1521
value: string;
1622
src?: string;
1723
}
1824

19-
export function CopyButton({ value }: Readonly<CopyButtonProps & VariantProps<typeof buttonVariants>>) {
25+
export function CopyButton({
26+
value,
27+
}: Readonly<CopyButtonProps & VariantProps<typeof buttonVariants>>) {
2028
const [hasCopied, setHasCopied] = useState(false);
2129
const { t } = useTranslation();
2230

@@ -60,12 +68,18 @@ export default function CodeViewer({
6068
showLineNumbers = true,
6169
wrapLongLines = true,
6270
}: Readonly<CodeViewerProps>) {
63-
const lineProps: lineTagPropsFunction | HTMLProps<HTMLElement> | undefined = wrapLongLines
64-
? { style: { overflowWrap: "break-word", whiteSpace: "pre-wrap" } }
65-
: undefined;
71+
const lineProps: lineTagPropsFunction | HTMLProps<HTMLElement> | undefined =
72+
wrapLongLines
73+
? { style: { overflowWrap: "break-word", whiteSpace: "pre-wrap" } }
74+
: undefined;
6675
return (
6776
<div className="rounded-lg border">
68-
<div className={cn("flex items-center border-b p-2 justify-end", header && "justify-between")}>
77+
<div
78+
className={cn(
79+
"flex items-center border-b p-2 justify-end",
80+
header && "justify-between",
81+
)}
82+
>
6983
{header}
7084
<div className="flex items-center gap-2">
7185
{button}

web/src/components/copyable-field.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ interface CopyableFieldProps {
1212
text?: string;
1313
}
1414

15-
export function CopyableField({ label, value, text }: Readonly<CopyableFieldProps>) {
15+
export function CopyableField({
16+
label,
17+
value,
18+
text,
19+
}: Readonly<CopyableFieldProps>) {
1620
const [hasCopied, setHasCopied] = useState(false);
1721
const { t } = useTranslation();
1822

@@ -40,8 +44,18 @@ export function CopyableField({ label, value, text }: Readonly<CopyableFieldProp
4044
<Label className="text-sm text-muted-foreground">{label}</Label>
4145
{value && (
4246
<CopyToClipboard text={value} onCopy={handleCopy}>
43-
<Button variant="ghost" size="icon" type="button" className="h-8 w-8" disabled={hasCopied}>
44-
{hasCopied ? <Check className="h-4 w-4" /> : <Copy className="h-4 w-4" />}
47+
<Button
48+
variant="ghost"
49+
size="icon"
50+
type="button"
51+
className="h-8 w-8"
52+
disabled={hasCopied}
53+
>
54+
{hasCopied ? (
55+
<Check className="h-4 w-4" />
56+
) : (
57+
<Copy className="h-4 w-4" />
58+
)}
4559
</Button>
4660
</CopyToClipboard>
4761
)}

web/src/components/magicui/line-shadow-text.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import {type MotionProps, motion } from "motion/react";
2-
import {cn} from "@/lib/utils";
1+
import { type MotionProps, motion } from "motion/react";
2+
import { cn } from "@/lib/utils";
33

4-
interface LineShadowTextProps extends Omit<React.HTMLAttributes<HTMLElement>, keyof MotionProps>, MotionProps {
4+
interface LineShadowTextProps
5+
extends Omit<React.HTMLAttributes<HTMLElement>, keyof MotionProps>,
6+
MotionProps {
57
shadowColor?: string;
68
as?: React.ElementType;
79
}

web/src/components/magicui/rainbow-button.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import {Slot} from "@radix-ui/react-slot";
2-
import {cva, type VariantProps} from "class-variance-authority";
1+
import { Slot } from "@radix-ui/react-slot";
2+
import { cva, type VariantProps } from "class-variance-authority";
33
import React from "react";
4-
import {cn} from "@/lib/utils";
4+
import { cn } from "@/lib/utils";
55

66
const rainbowButtonVariants = cva(
77
cn(

web/src/components/memshell/main-config-card.tsx

Lines changed: 55 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,56 @@
11
import {
2-
ArrowUpRightIcon,
3-
AxeIcon,
4-
CommandIcon,
5-
NetworkIcon,
6-
ServerIcon,
7-
ShieldOffIcon,
8-
SwordIcon,
9-
WaypointsIcon,
10-
ZapIcon,
2+
ArrowUpRightIcon,
3+
AxeIcon,
4+
CommandIcon,
5+
NetworkIcon,
6+
ServerIcon,
7+
ShieldOffIcon,
8+
SwordIcon,
9+
WaypointsIcon,
10+
ZapIcon,
1111
} from "lucide-react";
12-
import {type JSX, useCallback, useEffect, useId, useState} from "react";
13-
import {FormProvider, type UseFormReturn} from "react-hook-form";
14-
import {useTranslation} from "react-i18next";
15-
import {AntSwordTabContent} from "@/components/memshell/tabs/antsword-tab";
16-
import {BehinderTabContent} from "@/components/memshell/tabs/behinder-tab";
17-
import {CommandTabContent} from "@/components/memshell/tabs/command-tab";
12+
import { type JSX, useCallback, useEffect, useState } from "react";
13+
import { FormProvider, type UseFormReturn } from "react-hook-form";
14+
import { useTranslation } from "react-i18next";
15+
import { AntSwordTabContent } from "@/components/memshell/tabs/antsword-tab";
16+
import { BehinderTabContent } from "@/components/memshell/tabs/behinder-tab";
17+
import { CommandTabContent } from "@/components/memshell/tabs/command-tab";
1818
import CustomTabContent from "@/components/memshell/tabs/custom-tab";
19-
import {GodzillaTabContent} from "@/components/memshell/tabs/godzilla-tab";
20-
import {NeoRegTabContent} from "@/components/memshell/tabs/neoreg-tab";
21-
import {Suo5TabContent} from "@/components/memshell/tabs/suo5-tab";
22-
import {Card, CardContent, CardHeader, CardTitle} from "@/components/ui/card.tsx";
19+
import { GodzillaTabContent } from "@/components/memshell/tabs/godzilla-tab";
20+
import { NeoRegTabContent } from "@/components/memshell/tabs/neoreg-tab";
21+
import { Suo5TabContent } from "@/components/memshell/tabs/suo5-tab";
2322
import {
24-
FormControl,
25-
FormDescription,
26-
FormField,
27-
FormFieldItem,
28-
FormFieldLabel,
29-
FormItem,
30-
FormLabel,
31-
FormMessage,
23+
Card,
24+
CardContent,
25+
CardHeader,
26+
CardTitle,
27+
} from "@/components/ui/card.tsx";
28+
import {
29+
FormControl,
30+
FormDescription,
31+
FormField,
32+
FormFieldItem,
33+
FormFieldLabel,
34+
FormItem,
35+
FormLabel,
36+
FormMessage,
3237
} from "@/components/ui/form.tsx";
33-
import {Label} from "@/components/ui/label.tsx";
34-
import {Select, SelectContent, SelectItem, SelectTrigger, SelectValue} from "@/components/ui/select.tsx";
35-
import {Switch} from "@/components/ui/switch.tsx";
36-
import {Tabs, TabsList, TabsTrigger} from "@/components/ui/tabs";
37-
import {type MainConfig, type ServerConfig, ShellToolType} from "@/types/memshell";
38-
import type {MemShellFormSchema} from "@/types/schema.ts";
38+
import { Label } from "@/components/ui/label.tsx";
39+
import {
40+
Select,
41+
SelectContent,
42+
SelectItem,
43+
SelectTrigger,
44+
SelectValue,
45+
} from "@/components/ui/select.tsx";
46+
import { Switch } from "@/components/ui/switch.tsx";
47+
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
48+
import {
49+
type MainConfig,
50+
type ServerConfig,
51+
ShellToolType,
52+
} from "@/types/memshell";
53+
import type { MemShellFormSchema } from "@/types/schema.ts";
3954

4055
const shellToolIcons: Record<ShellToolType, JSX.Element> = {
4156
[ShellToolType.Behinder]: <ShieldOffIcon className="h-4 w-4" />,
@@ -79,7 +94,9 @@ export default function MainConfigCard({
7994
const shellTool = form.watch("shellTool");
8095
const { t } = useTranslation();
8196

82-
const [serverVersionOptions, setServerVersionOptions] = useState(defaultServerVersionOptions);
97+
const [serverVersionOptions, setServerVersionOptions] = useState(
98+
defaultServerVersionOptions,
99+
);
83100

84101
// 处理一下 shellTypes 由于 server 或 shellTool 变更时无法正常为 form.shellType 赋值的问题
85102
useEffect(() => {
@@ -95,7 +112,10 @@ export default function MainConfigCard({
95112
setShellToolMap(newShellToolMap);
96113

97114
const newShellTools = Object.keys(newShellToolMap);
98-
setShellTools([...newShellTools.map((tool) => tool as ShellToolType), ShellToolType.Custom]);
115+
setShellTools([
116+
...newShellTools.map((tool) => tool as ShellToolType),
117+
ShellToolType.Custom,
118+
]);
99119

100120
const currentShellTool = form.getValues("shellTool");
101121

@@ -233,10 +253,6 @@ export default function MainConfigCard({
233253
[form, servers, shellToolMap],
234254
);
235255

236-
const debugId = useId();
237-
const bypassId = useId();
238-
const shrinkId = useId();
239-
240256
return (
241257
<FormProvider {...form}>
242258
<Card>

web/src/components/memshell/package-config-card.tsx

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
1-
import {PackageIcon} from "lucide-react";
2-
import {useEffect, useState} from "react";
3-
import {FormProvider, type UseFormReturn} from "react-hook-form";
4-
import {useTranslation} from "react-i18next";
5-
import {Card, CardContent, CardHeader, CardTitle} from "@/components/ui/card.tsx";
6-
import {FormControl, FormField, FormItem, FormLabel} from "@/components/ui/form.tsx";
7-
import {RadioGroup, RadioGroupItem} from "@/components/ui/radio-group.tsx";
8-
import type {PackerConfig} from "@/types/memshell";
9-
import type {MemShellFormSchema} from "@/types/schema.ts";
1+
import { PackageIcon } from "lucide-react";
2+
import { useEffect, useState } from "react";
3+
import { FormProvider, type UseFormReturn } from "react-hook-form";
4+
import { useTranslation } from "react-i18next";
5+
import {
6+
Card,
7+
CardContent,
8+
CardHeader,
9+
CardTitle,
10+
} from "@/components/ui/card.tsx";
11+
import {
12+
FormControl,
13+
FormField,
14+
FormItem,
15+
FormLabel,
16+
} from "@/components/ui/form.tsx";
17+
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group.tsx";
18+
import type { PackerConfig } from "@/types/memshell";
19+
import type { MemShellFormSchema } from "@/types/schema.ts";
1020

1121
type Option = {
1222
name: string;
@@ -49,7 +59,10 @@ export default function PackageConfigCard({
4959

5060
setOptions(mappedOptions);
5161
const currentValue = form.getValues("packingMethod");
52-
if (filteredOptions.length > 0 && (!currentValue || !filteredOptions.includes(currentValue))) {
62+
if (
63+
filteredOptions.length > 0 &&
64+
(!currentValue || !filteredOptions.includes(currentValue))
65+
) {
5366
form.setValue("packingMethod", filteredOptions[0]);
5467
}
5568
}, [form, packerConfig, server, shellType, t]);
@@ -78,7 +91,10 @@ export default function PackageConfigCard({
7891
className="grid grid-cols-2 md:grid-cols-3"
7992
>
8093
{options.map(({ name, value }) => (
81-
<FormItem key={value} className="flex items-center space-x-3 space-y-0">
94+
<FormItem
95+
key={value}
96+
className="flex items-center space-x-3 space-y-0"
97+
>
8298
<FormControl>
8399
<RadioGroupItem value={value} id={value} />
84100
</FormControl>
@@ -96,7 +112,9 @@ export default function PackageConfigCard({
96112
) : (
97113
<div className="flex items-center justify-center p-4 space-x-2">
98114
<div className="h-4 w-4 animate-spin rounded-full border-2 border-primary border-t-transparent" />
99-
<span className="text-sm text-muted-foreground">{t("loading")}</span>
115+
<span className="text-sm text-muted-foreground">
116+
{t("loading")}
117+
</span>
100118
</div>
101119
)}
102120
</CardContent>

web/src/components/memshell/quick-usage.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import { ScrollTextIcon } from "lucide-react";
22
import { useTranslation } from "react-i18next";
3-
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card.tsx";
3+
import {
4+
Card,
5+
CardContent,
6+
CardHeader,
7+
CardTitle,
8+
} from "@/components/ui/card.tsx";
49

510
export function QuickUsage() {
611
const { t } = useTranslation();

0 commit comments

Comments
 (0)