diff --git a/src/app/json-formatter/page.tsx b/src/app/json-formatter/page.tsx
deleted file mode 100644
index a328542..0000000
--- a/src/app/json-formatter/page.tsx
+++ /dev/null
@@ -1,76 +0,0 @@
-"use client";
-
-import { Button } from "@/components/ui/button";
-import { Textarea } from "@/components/ui/textarea";
-import { useState } from "react";
-import Link from "next/link";
-
-export default function JsonFormatterPage() {
- const [input, setInput] = useState("");
- const [output, setOutput] = useState("");
- const [error, setError] = useState("");
-
- const formatJson = () => {
- try {
- const formatted = JSON.stringify(JSON.parse(input), null, 2);
- setOutput(formatted);
- setError("");
- } catch (e: any) {
- setError("Invalid JSON: " + e.message);
- setOutput("");
- }
- };
-
- const copyToClipboard = () => {
- navigator.clipboard.writeText(output);
- };
-
- const clearText = () => {
- setInput("");
- setOutput("");
- setError("");
- };
-
- return (
-
-
-
- ← Back to Home
-
- JSON Formatter
-
-
-
-
-
-
-
-
-
-
-
- {error &&
{error}
}
-
- );
-}
diff --git a/src/app/rt-guide/board-form.tsx b/src/app/rt-guide/board-form.tsx
index 20c3910..f012605 100644
--- a/src/app/rt-guide/board-form.tsx
+++ b/src/app/rt-guide/board-form.tsx
@@ -18,7 +18,7 @@ import {
import { Separator } from "@/components/ui/separator";
import { Switch } from "@/components/ui/switch";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
-import { BoardData, TrainType } from "./types";
+import { BoardData, ThemeInfo, TrainType } from "./types";
interface BoardFormProps {
data: BoardData;
@@ -30,22 +30,38 @@ export function BoardForm({ data, setData }: BoardFormProps) {
setData({ ...data, statusBar: { ...data.statusBar, [field]: value } });
};
- const handleTrainChange = (index: number, field: string, value: any) => {
+ type TrainField =
+ | "platform"
+ | "arrival"
+ | "type"
+ | "destination.en"
+ | "destination.cn";
+
+ const handleTrainChange = (
+ index: number,
+ field: TrainField,
+ value: string | TrainType
+ ) => {
const newTrains = [...data.trains];
const trainToUpdate = { ...newTrains[index] };
if (field === "destination.en" || field === "destination.cn") {
- const [, subkey] = field.split(".");
- (trainToUpdate.destination as any)[subkey] = value;
+ const [, subkey] = field.split(".") as ["destination", "en" | "cn"];
+ trainToUpdate.destination[subkey] = value as string;
+ } else if (field === "type") {
+ trainToUpdate[field] = value as TrainType;
} else {
- (trainToUpdate as any)[field] = value;
+ trainToUpdate[field as "platform" | "arrival"] = value;
}
newTrains[index] = trainToUpdate;
setData({ ...data, trains: newTrains });
};
- const handleThemeChange = (field: string, value: string) => {
+ const handleThemeChange = (
+ field: keyof Omit | "trainTypeColors",
+ value: string | Record
+ ) => {
setData({ ...data, theme: { ...data.theme, [field]: value } });
};
@@ -265,11 +281,11 @@ export function BoardForm({ data, setData }: BoardFormProps) {
type="color"
value={data.theme.trainTypeColors[type]}
onChange={(e) => {
- const newColors = {
+ const newColors: Record = {
...data.theme.trainTypeColors,
[type]: e.target.value,
};
- handleThemeChange("trainTypeColors", newColors as any);
+ handleThemeChange("trainTypeColors", newColors);
}}
/>
diff --git a/src/app/rt-guide/display-board.tsx b/src/app/rt-guide/display-board.tsx
deleted file mode 100644
index e69de29..0000000
diff --git a/src/components/rt-guide/mtr-board-form.tsx b/src/components/rt-guide/mtr-board-form.tsx
index 909af70..dd68849 100644
--- a/src/components/rt-guide/mtr-board-form.tsx
+++ b/src/components/rt-guide/mtr-board-form.tsx
@@ -19,7 +19,7 @@ import { ColorPicker } from "@/components/ui/color-picker";
import { Separator } from "@/components/ui/separator";
import { Switch } from "@/components/ui/switch";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
-import { BoardData, TrainType } from "@/app/rt-guide/types";
+import { BoardData, ThemeInfo, TrainType } from "@/app/rt-guide/types";
interface MtrBoardFormProps {
data: BoardData;
@@ -31,22 +31,38 @@ export function MtrBoardForm({ data, setData }: MtrBoardFormProps) {
setData({ ...data, statusBar: { ...data.statusBar, [field]: value } });
};
- const handleTrainChange = (index: number, field: string, value: any) => {
+ type TrainField =
+ | "platform"
+ | "arrival"
+ | "type"
+ | "destination.en"
+ | "destination.cn";
+
+ const handleTrainChange = (
+ index: number,
+ field: TrainField,
+ value: string | TrainType
+ ) => {
const newTrains = [...data.trains];
const trainToUpdate = { ...newTrains[index] };
if (field === "destination.en" || field === "destination.cn") {
- const [, subkey] = field.split(".");
- (trainToUpdate.destination as any)[subkey] = value;
+ const [, subkey] = field.split(".") as ["destination", "en" | "cn"];
+ trainToUpdate.destination[subkey] = value as string;
+ } else if (field === "type") {
+ trainToUpdate[field] = value as TrainType;
} else {
- (trainToUpdate as any)[field] = value;
+ trainToUpdate[field as "platform" | "arrival"] = value;
}
newTrains[index] = trainToUpdate;
setData({ ...data, trains: newTrains });
};
- const handleThemeChange = (field: string, value: any) => {
+ const handleThemeChange = (
+ field: keyof Omit | "trainTypeColors",
+ value: string | Record
+ ) => {
setData({ ...data, theme: { ...data.theme, [field]: value } });
};
@@ -250,10 +266,10 @@ export function MtrBoardForm({ data, setData }: MtrBoardFormProps) {
(type) => (
{
const newColors = {
diff --git a/src/lib/tools.ts b/src/lib/tools.ts
index afb0efb..a7ec261 100644
--- a/src/lib/tools.ts
+++ b/src/lib/tools.ts
@@ -9,15 +9,5 @@ export const tools: Tool[] = [
title: "Rail Transit Guide",
description: "轨道交通导视生成器",
href: "/rt-guide",
- },
- {
- title: "URL Encoder/Decoder",
- description: "Encode or decode URLs and strings.",
- href: "/url-encoder",
- },
- {
- title: "Base64 Encoder/Decoder",
- description: "Encode or decode strings to and from Base64.",
- href: "/base64-encoder",
- },
+ }
];