routing
This commit is contained in:
parent
76bbdbfb61
commit
098e0fe1da
@ -8,8 +8,9 @@ module.exports = {
|
||||
}
|
||||
},
|
||||
navigations: {
|
||||
'undefined.main': '/undefined',
|
||||
'link.undefined.auth': '/auth'
|
||||
'enter.main': '/enter',
|
||||
'link.enter.auth': '/auth',
|
||||
'link.enter.account': '/account',
|
||||
},
|
||||
features: {
|
||||
'undefined': {
|
||||
|
@ -15,5 +15,6 @@
|
||||
"build": "npm run clean && ijl-cli build --dev",
|
||||
"build:prod": "npm run clean && ijl-cli build",
|
||||
"clean": "rimraf dist"
|
||||
}
|
||||
},
|
||||
"name": "enter"
|
||||
}
|
||||
|
@ -1,13 +1,16 @@
|
||||
import { getNavigations, getNavigationsValue } from '@ijl/cli';
|
||||
import pkg from '../../package.json';
|
||||
|
||||
const baseUrl = getNavigationsValue(`${pkg.name}.main`);
|
||||
const baseUrl = getNavigationsValue(`${(pkg as any).name}.main`);
|
||||
const navs = getNavigations();
|
||||
const makeUrl = url => baseUrl + url;
|
||||
|
||||
export const URLs = {
|
||||
baseUrl,
|
||||
auth: {
|
||||
url: makeUrl(navs[`link.${pkg.name}.auth`]),
|
||||
url: makeUrl(navs[`link.${(pkg as any).name}.auth`]),
|
||||
},
|
||||
account: {
|
||||
url: makeUrl(navs[`link.${(pkg as any).name}.account`]),
|
||||
}
|
||||
};
|
||||
|
@ -3,16 +3,16 @@ import { Routes, Route, Navigate } from 'react-router-dom';
|
||||
|
||||
import { URLs } from './__data__/urls';
|
||||
|
||||
const Hello = () => <h1>Hello</h1>;
|
||||
import HomePage from './pages/HomePage.jsx'
|
||||
import Hello from './pages/Hello.jsx'
|
||||
import Account from './pages/Account.jsx'
|
||||
|
||||
export const Dashboard = () => {
|
||||
return (
|
||||
<Routes>
|
||||
<Route
|
||||
path={URLs.baseUrl}
|
||||
element={<Navigate replace to={URLs.auth.url} />}
|
||||
/>
|
||||
<Route path={URLs.auth.url} element={<Hello />} />
|
||||
<Route path={URLs.baseUrl} element={<HomePage/>}/>
|
||||
<Route path={URLs.auth.url} element={<Hello/>} />
|
||||
<Route path={URLs.account.url} element={<Account/>}/>
|
||||
</Routes>
|
||||
);
|
||||
};
|
||||
|
9
src/pages/Account.jsx
Normal file
9
src/pages/Account.jsx
Normal file
@ -0,0 +1,9 @@
|
||||
import React from "react";
|
||||
|
||||
const Account = () => {
|
||||
return (
|
||||
<h1>Account</h1>
|
||||
)
|
||||
}
|
||||
|
||||
export default Account;
|
9
src/pages/Hello.jsx
Normal file
9
src/pages/Hello.jsx
Normal file
@ -0,0 +1,9 @@
|
||||
import React from "react";
|
||||
|
||||
const Hello = () => {
|
||||
return (
|
||||
<h1>Hello!</h1>
|
||||
)
|
||||
}
|
||||
|
||||
export default Hello;
|
9
src/pages/HomePage.jsx
Normal file
9
src/pages/HomePage.jsx
Normal file
@ -0,0 +1,9 @@
|
||||
import React from "react";
|
||||
|
||||
const HomePage = () => {
|
||||
return (
|
||||
<h1>Home</h1>
|
||||
)
|
||||
}
|
||||
|
||||
export default HomePage
|
Loading…
Reference in New Issue
Block a user