diff --git a/src/init/i18n/locales/BritishEnglish.json b/src/init/i18n/locales/BritishEnglish.json index a0716ea..7625722 100644 --- a/src/init/i18n/locales/BritishEnglish.json +++ b/src/init/i18n/locales/BritishEnglish.json @@ -7,7 +7,12 @@ "navigation": { "home": "Home", "about": "About", - "contact": "Contact" + "contact": "Contact", + "tools": "Tools", + "jsonProcessing": "JSON Processing", + "dailyTools": "Daily Tools", + "expandToolsMenu": "Expand tools menu", + "collapseToolsMenu": "Collapse tools menu" }, "language": { "switch": "Switch Language", diff --git a/src/init/i18n/locales/SimplifiedChinese.json b/src/init/i18n/locales/SimplifiedChinese.json index 79a79ed..0712c82 100644 --- a/src/init/i18n/locales/SimplifiedChinese.json +++ b/src/init/i18n/locales/SimplifiedChinese.json @@ -7,7 +7,12 @@ "navigation": { "home": "首页", "about": "关于", - "contact": "联系" + "contact": "联系", + "tools": "工具", + "jsonProcessing": "JSON 处理", + "dailyTools": "日常小工具", + "expandToolsMenu": "展开工具菜单", + "collapseToolsMenu": "收起工具菜单" }, "language": { "switch": "切换语言", diff --git a/src/layout/tools-layout/index.tsx b/src/layout/tools-layout/index.tsx new file mode 100644 index 0000000..b3f13f0 --- /dev/null +++ b/src/layout/tools-layout/index.tsx @@ -0,0 +1,133 @@ +import { useMemo, useState } from "react" +import { Link, NavLink, Outlet } from "react-router-dom" +import { useTranslation } from "react-i18next" +import dayjs from "dayjs" +import LanguageSwitcher from "@/components/language-switcher" + +export default function ToolsLayout() { + const today = useMemo(() => dayjs(), []) + const { t } = useTranslation() + const [collapsed, setCollapsed] = useState(false) + + const toolGroups = useMemo( + () => [ + { + title: t("navigation.jsonProcessing"), + items: [ + { to: "/json-viewer", label: t("home.jsonViewer"), shortLabel: "JV" }, + { to: "/json-grid", label: t("home.jsonGrid"), shortLabel: "JG" }, + ], + }, + { + title: t("navigation.dailyTools"), + items: [{ to: "/bmi-calculator", label: t("home.bmiCalculator"), shortLabel: "BMI" }], + }, + ], + [t] + ) + + return ( +
+
+
+
+
+

{t("app.title")}

+
+
+ + +
+
+
+
+ +
+
+ + +
+ +
+
+
+ + +
+ ) +} diff --git a/src/router/index.tsx b/src/router/index.tsx index 3ef5798..30f6f85 100644 --- a/src/router/index.tsx +++ b/src/router/index.tsx @@ -2,6 +2,7 @@ import { ComponentType } from "react" import { createBrowserRouter } from "react-router-dom" import ErrorPage from "@/components/error-page" import HeroLayout from "@/layout/hero-layout" +import ToolsLayout from "@/layout/tools-layout" function lazy }>(importer: () => Promise) { return async () => { @@ -27,6 +28,21 @@ const router = createBrowserRouter( index: true, lazy: lazy(() => import("@/page/home")), }, + { + path: "about", + lazy: lazy(() => import("@/page/about")), + }, + { + path: "contact", + lazy: lazy(() => import("@/page/contact")), + }, + ], + }, + { + path: "/", + element: , + errorElement: , + children: [ { path: "json-viewer", lazy: lazy(() => import("@/page/json-viewer")), @@ -39,14 +55,6 @@ const router = createBrowserRouter( path: "bmi-calculator", lazy: lazy(() => import("@/page/bmi-calculator")), }, - { - path: "about", - lazy: lazy(() => import("@/page/about")), - }, - { - path: "contact", - lazy: lazy(() => import("@/page/contact")), - }, ], }, ],