mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-02-16 07:11:15 +03:00
Fix http route not working
This commit is contained in:
parent
58c6b6349c
commit
3d458826cf
1 changed files with 27 additions and 10 deletions
|
@ -1,3 +1,4 @@
|
|||
import { useLayoutEffect } from 'preact/hooks';
|
||||
import { useLocation } from 'react-router-dom';
|
||||
|
||||
import Link from '../components/link';
|
||||
|
@ -7,18 +8,34 @@ export default function HttpRoute() {
|
|||
const location = useLocation();
|
||||
const url = location.pathname.replace(/^\//, '');
|
||||
const statusURL = getInstanceStatusURL(url);
|
||||
if (statusURL) {
|
||||
window.location.hash = statusURL + '?view=full';
|
||||
return null;
|
||||
}
|
||||
|
||||
useLayoutEffect(() => {
|
||||
if (statusURL) {
|
||||
setTimeout(() => {
|
||||
window.location.hash = statusURL + '?view=full';
|
||||
}, 300);
|
||||
}
|
||||
}, [statusURL]);
|
||||
|
||||
return (
|
||||
<div class="ui-state" tabIndex="-1">
|
||||
<h2>Unable to process URL</h2>
|
||||
<p>
|
||||
<a href={url} target="_blank">
|
||||
{url}
|
||||
</a>
|
||||
</p>
|
||||
{statusURL ? (
|
||||
<>
|
||||
<h2>Redirecting…</h2>
|
||||
<p>
|
||||
<a href={`#${statusURL}?view=full`}>{statusURL}</a>
|
||||
</p>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<h2>Unable to process URL</h2>
|
||||
<p>
|
||||
<a href={url} target="_blank">
|
||||
{url}
|
||||
</a>
|
||||
</p>
|
||||
</>
|
||||
)}
|
||||
<hr />
|
||||
<p>
|
||||
<Link to="/">Go home</Link>
|
||||
|
|
Loading…
Add table
Reference in a new issue