Router.tsx 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. import * as React from "react";
  2. import { Routes, Route, Outlet, Link, createBrowserRouter } from "react-router-dom";
  3. import Layout from "@/components/Layout/Layout";
  4. // import Home from "@/pages/Home/Home";
  5. import About from "@/pages/About/About";
  6. import Finder from "@/pages/Finder/Finder";
  7. import Setting from "@/pages/Setting/Setting";
  8. import FileSort from "@/pages/FileSort/FileSort";
  9. import FileClear from "@/pages/FileClear/FileClear";
  10. import DuplicateFileIndex from "@/pages/DuplicateFile/Index";
  11. import DuplicateFile from "@/pages/DuplicateFile/DuplicateFile";
  12. import CalculateDuplicateFiles from "@/pages/DuplicateFile/CalculateDuplicateFiles";
  13. import DuplicateFileInfo from "@/pages/DuplicateFile/FileInfo";
  14. /* export default function Router() {
  15. return (
  16. <Routes>
  17. <Route path="/" element={<Layout />}>
  18. <Route index element={<DuplicateFileIndex />} />
  19. <Route path={"about"} element={<About />} />
  20. <Route path={"finder"} element={<Finder />} />
  21. <Route path={"setting"} element={<Setting />} />
  22. <Route path={"home"} element={<Home />} />
  23. <Route path={"file-sort"} element={<FileSort />} />
  24. <Route path={"file-clear"} element={<FileClear />} />
  25. <Route path={"duplicate-file"} element={<DuplicateFileIndex />} >
  26. <Route index element={<DuplicateFile />} />
  27. <Route path={"info"} element={<DuplicateFileInfo />} />
  28. </Route>
  29. </Route>
  30. </Routes>
  31. );
  32. } */
  33. const router = createBrowserRouter([
  34. {
  35. path: "/",
  36. id: "root",
  37. element: <Layout />,
  38. /*
  39. // loader: rootLoader,
  40. 每个路由都可以定义一个“加载器”函数,以便在路由元素呈现之前向路由元素提供数据。
  41. loader: async () => {
  42. return fakeDb.from("teams").select("*");
  43. },
  44. */
  45. children: [
  46. {
  47. path: "",
  48. element: <DuplicateFileIndex />,
  49. children: [
  50. {
  51. path: "",
  52. element: <DuplicateFile />,
  53. },
  54. {
  55. path: "info/:fileId",
  56. element: <DuplicateFileInfo />,
  57. },
  58. {
  59. path: "calculate/:fileId",
  60. element: <CalculateDuplicateFiles />,
  61. }
  62. ]
  63. },
  64. {
  65. path: "about",
  66. element: <About />,
  67. },
  68. {
  69. path: "finder",
  70. element: <Finder />,
  71. },
  72. {
  73. path: "setting",
  74. element: <Setting />,
  75. },
  76. {
  77. path: "file-sort",
  78. element: <FileSort />,
  79. },
  80. {
  81. path: "file-clear",
  82. element: <FileClear />,
  83. }
  84. // {
  85. // path: "duplicate-file",
  86. // element: <DuplicateFileIndex />,
  87. // children: [
  88. // {
  89. // path: "",
  90. // element: <DuplicateFile />,
  91. // },
  92. // {
  93. // path: "info/:fileId",
  94. // element: <DuplicateFileInfo />,
  95. // }
  96. // ]
  97. // },
  98. ],
  99. },
  100. ], {
  101. future: {
  102. // Normalize `useNavigation()`/`useFetcher()` `formMethod` to uppercase
  103. v7_normalizeFormMethod: true,
  104. },
  105. });
  106. export default router