mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-21 22:47:50 +00:00
Merge branch 'master' into createUIBasePage
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
require('./homebrew.less');
|
||||
const React = require('react');
|
||||
const createClass = require('create-react-class');
|
||||
const { StaticRouter:Router, Switch, Route } = require('react-router-dom');
|
||||
const queryString = require('query-string');
|
||||
const { StaticRouter:Router } = require('react-router-dom/server');
|
||||
const { Route, Routes, useParams, useSearchParams } = require('react-router-dom');
|
||||
|
||||
const HomePage = require('./pages/homePage/homePage.jsx');
|
||||
const EditPage = require('./pages/editPage/editPage.jsx');
|
||||
@@ -13,6 +13,23 @@ const NewPage = require('./pages/newPage/newPage.jsx');
|
||||
const PrintPage = require('./pages/printPage/printPage.jsx');
|
||||
const AccountPage = require('./pages/accountPage/accountPage.jsx');
|
||||
|
||||
const WithRoute = (props)=>{
|
||||
const params = useParams();
|
||||
const [searchParams] = useSearchParams();
|
||||
const queryParams = {};
|
||||
for (const [key, value] of searchParams?.entries() || []) {
|
||||
queryParams[key] = value;
|
||||
}
|
||||
const Element = props.el;
|
||||
const allProps = {
|
||||
...props,
|
||||
...params,
|
||||
query : queryParams,
|
||||
el : undefined
|
||||
};
|
||||
return <Element {...allProps} />;
|
||||
};
|
||||
|
||||
const Homebrew = createClass({
|
||||
displayName : 'Homebrewery',
|
||||
getDefaultProps : function() {
|
||||
@@ -38,6 +55,7 @@ const Homebrew = createClass({
|
||||
global.account = this.props.account;
|
||||
global.version = this.props.version;
|
||||
global.enable_v3 = this.props.enable_v3;
|
||||
global.enable_themes = this.props.enable_themes;
|
||||
global.config = this.props.config;
|
||||
|
||||
return {};
|
||||
@@ -58,8 +76,10 @@ const Homebrew = createClass({
|
||||
<Route path='/changelog' exact component={()=><SharePage brew={this.props.brew} />}/>
|
||||
<Route path='/faq' exact component={()=><SharePage brew={this.props.brew} />}/>
|
||||
<Route path='/v3_preview' exact component={()=><HomePage brew={this.props.brew} />}/>
|
||||
<Route path='/ui/account' exact component={()=><AccountPage brew={this.props.brew} uiItems={this.props.brew.uiItems} />}/>
|
||||
<Route path='/' component={()=><HomePage brew={this.props.brew} />}/>
|
||||
<Route path='/account' exact component={()=><AccountPage brew={this.props.brew} uiItems={this.props.brew.uiItems} />}/>
|
||||
<Route path='/legacy' element={<WithRoute el={HomePage} brew={this.props.brew} />} />
|
||||
<Route path='/' element={<WithRoute el={HomePage} brew={this.props.brew} />} />
|
||||
<Route path='/*' element={<WithRoute el={HomePage} brew={this.props.brew} />} />
|
||||
</Switch>
|
||||
</div>
|
||||
</Router>
|
||||
|
||||
Reference in New Issue
Block a user