Skip to content

Commit

Permalink
fix router
Browse files Browse the repository at this point in the history
  • Loading branch information
AxyLm committed Jul 8, 2024
1 parent 9c4cf94 commit 6a0d570
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 7 deletions.
16 changes: 16 additions & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[build]
publish="./dist"
base = "."


[[redirects]]
from = "/*"
to = "/index.html"
status = 200

[[headers]]
for = "/*"
[headers.values]
X-Frame-Options = "sameorigin"
Referrer-Policy = "no-referrer"
X-Content-Type-Options = "nosniff"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"react-dom": "^18.2.0",
"react-hook-form": "^7.51.3",
"react-qr-code": "^2.0.15",
"react-router-dom": "^6.24.1",
"react-router-dom": "^6.15.0",
"sonner": "^1.4.41",
"tailwind-merge": "^2.3.0",
"tailwindcss-animate": "^1.0.7",
Expand Down
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions src/app/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Layout from '@/app/layout'
import { Home } from 'lucide-react'
import { Routes, Route } from 'react-router-dom'
import MnemonicGeneration from '@/app/pages/mnemonic-generation'
import QrCode from '@/app/pages/generate-qrcode'
Expand All @@ -10,7 +9,7 @@ function App() {
<Routes>
<Route path="/" element={<Layout />}>
<Route index element={<MnemonicGeneration />} />
<Route path="qr" element={<QrCode />} />
<Route path="/qr" element={<QrCode />} />
<Route path="*" element={<MnemonicGeneration />} />
</Route>
</Routes>
Expand Down
28 changes: 28 additions & 0 deletions src/app/router.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { createBrowserRouter, createRoutesFromElements, Route } from 'react-router-dom'
import Layout from '@/app/layout'
import MnemonicGeneration from '@/app/pages/mnemonic-generation'
import QrCode from '@/app/pages/generate-qrcode'

const router = createBrowserRouter([
{
path: '/',
Component: Layout,
children: [
{
index: true,
Component: MnemonicGeneration,
},
{
path: 'qr',
Component: QrCode,

},
{
path: 'deferred',
Component: MnemonicGeneration,
},
],
},
])

export { router }
10 changes: 7 additions & 3 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ import './app/style/global.css'
import './app/style/dark.less'
import React from 'react'
import ReactDOM from 'react-dom/client'
import { HashRouter, RouterProvider } from 'react-router-dom'
import App from './app/App'
import { BrowserRouter } from "react-router-dom";
import { router } from './app/router'

ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<BrowserRouter>
{/* <HashRouter>
<App />
</BrowserRouter>
</HashRouter> */}

<RouterProvider router={router} />

</React.StrictMode>
)

0 comments on commit 6a0d570

Please sign in to comment.