mirror of
https://github.com/IT4Change/ohmyform-ui.git
synced 2025-12-13 09:45:50 +00:00
fix redirect for static export in semi spa mode
This commit is contained in:
parent
472e07bd29
commit
c1ba7f2556
@ -6,6 +6,7 @@ import 'assets/global.scss'
|
||||
import 'assets/variables.scss'
|
||||
import axios from 'axios'
|
||||
import {authConfig} from 'components/with.auth'
|
||||
import 'i18n'
|
||||
import {AppProps} from 'next/app'
|
||||
import getConfig from 'next/config'
|
||||
import Head from 'next/head'
|
||||
@ -34,11 +35,4 @@ const App: React.FC<AppProps> = ({ Component, pageProps }) => {
|
||||
)
|
||||
}
|
||||
|
||||
const WrappedApp = wrapper.withRedux(App)
|
||||
|
||||
WrappedApp.getInitialProps = async (): Promise<any> => {
|
||||
// important for now to pass public runtime config to clients!
|
||||
return {}
|
||||
}
|
||||
|
||||
export default WrappedApp
|
||||
export default wrapper.withRedux(App)
|
||||
|
||||
@ -1,9 +1,38 @@
|
||||
import {Layout} from 'antd'
|
||||
import {AuthFooter} from 'components/auth/footer'
|
||||
import {NextPage} from 'next'
|
||||
import React from 'react'
|
||||
import {useRouter} from 'next/router'
|
||||
import React, {useEffect} from 'react'
|
||||
import {LoadingPage} from '../components/loading.page'
|
||||
|
||||
const Index: NextPage = () => {
|
||||
const router = useRouter()
|
||||
|
||||
useEffect(() => {
|
||||
if (router.pathname !== window.location.pathname) {
|
||||
let href = router.asPath
|
||||
let as = router.asPath;
|
||||
|
||||
[
|
||||
/(\/form\/)[^\/]+/i,
|
||||
/(\/admin\/forms\/)[^\/]+/i,
|
||||
/(\/admin\/users\/)[^\/]+/i,
|
||||
].forEach(r => {
|
||||
if (r.test(as)) {
|
||||
href = href.replace(r, '$1[id]')
|
||||
}
|
||||
})
|
||||
|
||||
router.replace(href, as)
|
||||
}
|
||||
})
|
||||
|
||||
if (process.browser && router.pathname !== window.location.pathname) {
|
||||
return (
|
||||
<LoadingPage message={'redirecting'} />
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<Layout style={{
|
||||
height: '100vh',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user