fix nav eleements confuse
This commit is contained in:
parent
22a76efc1f
commit
530d172f0b
1847
package-lock.json
generated
1847
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -14,12 +14,12 @@
|
|||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"description": "",
|
"description": "",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@brojs/cli": "^1.3.0",
|
"@brojs/cli": "1.8.4",
|
||||||
"@emotion/react": "^11.13.3",
|
"@emotion/react": "^11.13.3",
|
||||||
"@emotion/styled": "^11.13.0",
|
"@emotion/styled": "^11.13.0",
|
||||||
"@types/react": "^18.3.12",
|
"@types/react": "^18.3.12",
|
||||||
"@types/react-dom": "^18.3.1",
|
"@types/react-dom": "^18.3.1",
|
||||||
"express": "^4.19.2",
|
"express": "^4.21.2",
|
||||||
"react": "^18.3.1",
|
"react": "^18.3.1",
|
||||||
"react-dom": "^18.3.1",
|
"react-dom": "^18.3.1",
|
||||||
"react-router-dom": "^6.27.0"
|
"react-router-dom": "^6.27.0"
|
||||||
|
@ -1,18 +1,19 @@
|
|||||||
import { getNavigationsValue } from "@brojs/cli";
|
import { getNavigationValue } from "@brojs/cli";
|
||||||
import { generatePath } from "react-router-dom";
|
import { generatePath } from "react-router-dom";
|
||||||
|
|
||||||
const baseUrl = getNavigationsValue("nav1.main");
|
|
||||||
|
|
||||||
export const URLs = {
|
export const URLs = {
|
||||||
|
baseUrl: getNavigationValue('nav1.main'),
|
||||||
profile: {
|
profile: {
|
||||||
isOn: Boolean(getNavigationsValue("link.nav1.profile")),
|
isOn: Boolean(getNavigationValue("link.nav1.profile")),
|
||||||
url: `${baseUrl}${getNavigationsValue("link.nav1.profile")}`,
|
url: `${getNavigationValue('nav1.main')}${getNavigationValue("link.nav1.profile")}`,
|
||||||
getUrl(userId: string, projectId: string) {
|
getUrl(userId: string, projectId: string) {
|
||||||
return generatePath(this.url, { userId, projectId });
|
return generatePath(this.url, { userId, projectId });
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
about: {
|
about: {
|
||||||
url: `${baseUrl}${getNavigationsValue("link.nav1.about")}`,
|
isOn: Boolean(getNavigationValue("link.nav1.about")),
|
||||||
|
url: `${getNavigationValue('nav1.main')}${getNavigationValue("link.nav1.about")}`,
|
||||||
getUrl() {
|
getUrl() {
|
||||||
return this.url;
|
return this.url;
|
||||||
},
|
},
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { BrowserRouter, HashRouter } from "react-router-dom";
|
import { BrowserRouter } from "react-router-dom";
|
||||||
import { ThemeProvider } from "@emotion/react";
|
import { ThemeProvider } from "@emotion/react";
|
||||||
|
|
||||||
import { Dashboard } from "./dashboard";
|
import { Dashboard } from "./dashboard";
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import React, { Suspense } from "react";
|
import React, { Suspense, useEffect } from "react";
|
||||||
import { Routes, Route } from "react-router-dom";
|
import { Routes, Route, useNavigate } from "react-router-dom";
|
||||||
|
|
||||||
import { URLs } from "./__data__/urls";
|
import { URLs } from "./__data__/urls";
|
||||||
import { ProfilePage, AboutPage } from "./pages";
|
import { ProfilePage, AboutPage } from "./pages";
|
||||||
@ -11,9 +11,25 @@ const PageWrapper = ({ children }) => (
|
|||||||
</ErrorBoundary>
|
</ErrorBoundary>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const Redirect = ({ to }: { to: string }) => {
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
navigate(to)
|
||||||
|
}, [navigate])
|
||||||
|
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
export const Dashboard = () => {
|
export const Dashboard = () => {
|
||||||
return (
|
return (
|
||||||
<Routes>
|
<Routes>
|
||||||
|
<Route
|
||||||
|
path={URLs.baseUrl}
|
||||||
|
element={(
|
||||||
|
<Redirect to={URLs.about.getUrl()} />
|
||||||
|
)}
|
||||||
|
/>
|
||||||
<Route
|
<Route
|
||||||
path={URLs.about.url}
|
path={URLs.about.url}
|
||||||
element={
|
element={
|
||||||
|
Loading…
Reference in New Issue
Block a user