mirror of
https://github.com/sasjs/server.git
synced 2026-01-17 19:00:05 +00:00
fix: use hash router instead of browser router in react app
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { Route, BrowserRouter, Switch, Redirect } from 'react-router-dom'
|
import { Route, HashRouter, Switch, Redirect } from 'react-router-dom'
|
||||||
import { ThemeProvider } from '@mui/material/styles'
|
import { ThemeProvider } from '@mui/material/styles'
|
||||||
import { theme } from './theme'
|
import { theme } from './theme'
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@ import SASjsStudio from './containers/SASjsStudio'
|
|||||||
function App() {
|
function App() {
|
||||||
return (
|
return (
|
||||||
<ThemeProvider theme={theme}>
|
<ThemeProvider theme={theme}>
|
||||||
<BrowserRouter>
|
<HashRouter>
|
||||||
<Header />
|
<Header />
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route exact path="/">
|
<Route exact path="/">
|
||||||
@@ -23,7 +23,7 @@ function App() {
|
|||||||
<SASjsStudio />
|
<SASjsStudio />
|
||||||
</Route>
|
</Route>
|
||||||
</Switch>
|
</Switch>
|
||||||
</BrowserRouter>
|
</HashRouter>
|
||||||
</ThemeProvider>
|
</ThemeProvider>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,9 +8,10 @@ import Tab from '@mui/material/Tab'
|
|||||||
|
|
||||||
const Header = (props: any) => {
|
const Header = (props: any) => {
|
||||||
const history = useHistory()
|
const history = useHistory()
|
||||||
const [tabValue, setTabValue] = useState(0)
|
const { pathname } = useLocation()
|
||||||
|
const [tabValue, setTabValue] = useState(pathname)
|
||||||
|
|
||||||
const handleTabChange = (event: React.SyntheticEvent, value: number) => {
|
const handleTabChange = (event: React.SyntheticEvent, value: string) => {
|
||||||
setTabValue(value)
|
setTabValue(value)
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
@@ -28,7 +29,7 @@ const Header = (props: any) => {
|
|||||||
marginRight: '25px'
|
marginRight: '25px'
|
||||||
}}
|
}}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setTabValue(0)
|
setTabValue('/')
|
||||||
history.push('/')
|
history.push('/')
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
@@ -37,9 +38,19 @@ const Header = (props: any) => {
|
|||||||
value={tabValue}
|
value={tabValue}
|
||||||
onChange={handleTabChange}
|
onChange={handleTabChange}
|
||||||
>
|
>
|
||||||
<Tab label="Home" to="/" component={Link} />
|
<Tab label="Home" value="/" to="/" component={Link} />
|
||||||
<Tab label="Drive" to="/SASjsDrive" component={Link} />
|
<Tab
|
||||||
<Tab label="Studio" to="/SASjsStudio" component={Link} />
|
label="Drive"
|
||||||
|
value="/SASjsDrive"
|
||||||
|
to="/SASjsDrive"
|
||||||
|
component={Link}
|
||||||
|
/>
|
||||||
|
<Tab
|
||||||
|
label="Studio"
|
||||||
|
value="/SASjsStudio"
|
||||||
|
to="/SASjsStudio"
|
||||||
|
component={Link}
|
||||||
|
/>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
</Toolbar>
|
</Toolbar>
|
||||||
</AppBar>
|
</AppBar>
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ const SideBar = (props: any) => {
|
|||||||
window.history.pushState(
|
window.history.pushState(
|
||||||
'',
|
'',
|
||||||
'',
|
'',
|
||||||
`${baseUrl}/SASjsDrive?filepath=${node.relativePath}`
|
`${baseUrl}/#/SASjsDrive?filepath=${node.relativePath}`
|
||||||
)
|
)
|
||||||
props.setSelectedFilePath(node.relativePath)
|
props.setSelectedFilePath(node.relativePath)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user