mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-14 04:50:26 +00:00
defaultPath property added to Router
This commit is contained in:
parent
3ec8c5afc7
commit
45c985f299
4 changed files with 55 additions and 47 deletions
|
|
@ -1,13 +1,14 @@
|
|||
const React = require('react');
|
||||
const { Router } = require('stremio-navigation');
|
||||
const routerViewsConfig = require('./routerViewsConfig');
|
||||
const { defaultPath, views: viewsConfig } = require('./routerConfig');
|
||||
const styles = require('./styles');
|
||||
|
||||
const App = () => (
|
||||
<React.StrictMode>
|
||||
<Router
|
||||
className={styles['router']}
|
||||
viewsConfig={routerViewsConfig}
|
||||
defaultPath={defaultPath}
|
||||
viewsConfig={viewsConfig}
|
||||
/>
|
||||
</React.StrictMode>
|
||||
);
|
||||
|
|
|
|||
47
src/App/routerConfig.js
Normal file
47
src/App/routerConfig.js
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
const { Addons, Board, Calendar, Detail, Discover, Intro, Library, Player, Search, Settings } = require('stremio-routes');
|
||||
|
||||
const routerConfig = {
|
||||
defaultPath: '/',
|
||||
views: [
|
||||
[
|
||||
{
|
||||
path: '/',
|
||||
component: Board
|
||||
},
|
||||
{
|
||||
path: '/intro',
|
||||
component: Intro
|
||||
},
|
||||
{
|
||||
path: '/calendar',
|
||||
component: Calendar
|
||||
},
|
||||
{
|
||||
path: '/discover/:type?/:sort?/:genre?',
|
||||
component: Discover
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
path: '/addons',
|
||||
component: Addons
|
||||
},
|
||||
{
|
||||
path: '/settings',
|
||||
component: Settings
|
||||
},
|
||||
{
|
||||
path: '/detail',
|
||||
component: Detail
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
path: '/player',
|
||||
component: Player
|
||||
}
|
||||
]
|
||||
]
|
||||
};
|
||||
|
||||
module.exports = routerConfig;
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
const { Calendar, Discover, Addons, Settings, Board, Player, Detail, Intro } = require('stremio-routes');
|
||||
|
||||
const routerViewsConfig = [
|
||||
[
|
||||
{
|
||||
path: '/',
|
||||
component: Board
|
||||
},
|
||||
{
|
||||
path: '/intro',
|
||||
component: Intro
|
||||
},
|
||||
{
|
||||
path: '/calendar',
|
||||
component: Calendar
|
||||
},
|
||||
{
|
||||
path: '/discover/:type?/:sort?/:genre?',
|
||||
component: Discover
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
path: '/addons',
|
||||
component: Addons
|
||||
},
|
||||
{
|
||||
path: '/settings',
|
||||
component: Settings
|
||||
},
|
||||
{
|
||||
path: '/detail',
|
||||
component: Detail
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
path: '/player',
|
||||
component: Player
|
||||
}
|
||||
]
|
||||
];
|
||||
|
||||
module.exports = routerViewsConfig;
|
||||
|
|
@ -89,7 +89,7 @@ class Router extends React.Component {
|
|||
}
|
||||
}
|
||||
|
||||
window.location.replace('#/');
|
||||
window.location.replace(`#${this.props.defaultPath}`);
|
||||
}
|
||||
|
||||
render() {
|
||||
|
|
@ -109,11 +109,15 @@ class Router extends React.Component {
|
|||
|
||||
Router.propTypes = {
|
||||
className: PropTypes.string,
|
||||
defaultPath: PropTypes.string.isRequired,
|
||||
viewsConfig: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.exact({
|
||||
path: PropTypes.string.isRequired,
|
||||
component: PropTypes.elementType.isRequired,
|
||||
options: PropTypes.object
|
||||
}))).isRequired
|
||||
};
|
||||
Router.defaultProps = {
|
||||
defaultPath: '/'
|
||||
};
|
||||
|
||||
module.exports = Router;
|
||||
|
|
|
|||
Loading…
Reference in a new issue