mirror of https://github.com/fantasticit/think.git
client: keep router query
parent
5b6f211900
commit
778217022a
|
@ -1,6 +1,6 @@
|
|||
import { useRouter } from 'next/router';
|
||||
import { Router, useRouter } from 'next/router';
|
||||
|
||||
export function useRouterQuery<T>() {
|
||||
export function useRouterQuery<T extends Router['query']>() {
|
||||
const router = useRouter();
|
||||
return router.query as unknown as T;
|
||||
return router.query as T;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ import { Author } from 'components/author';
|
|||
import { LogoImage, LogoText } from 'components/logo';
|
||||
import { Seo } from 'components/seo';
|
||||
import { useUser } from 'data/user';
|
||||
import { useRouterQuery } from 'hooks/use-router-query';
|
||||
import { useToggle } from 'hooks/use-toggle';
|
||||
import Link from 'next/link';
|
||||
import React, { useCallback } from 'react';
|
||||
|
@ -14,6 +15,7 @@ const { Title, Text } = Typography;
|
|||
|
||||
const Page = () => {
|
||||
const { login } = useUser();
|
||||
const query = useRouterQuery();
|
||||
const [loading, toggleLoading] = useToggle(false);
|
||||
|
||||
const toLogin = useCallback(
|
||||
|
@ -66,7 +68,12 @@ const Page = () => {
|
|||
</Button>
|
||||
<footer>
|
||||
<Text link style={{ textAlign: 'center' }}>
|
||||
<Link href="/register">
|
||||
<Link
|
||||
href={{
|
||||
pathname: '/register',
|
||||
query,
|
||||
}}
|
||||
>
|
||||
<a>注册用户以登录</a>
|
||||
</Link>
|
||||
</Text>
|
||||
|
|
|
@ -3,6 +3,7 @@ import { Author } from 'components/author';
|
|||
import { LogoImage, LogoText } from 'components/logo';
|
||||
import { Seo } from 'components/seo';
|
||||
import { useAsyncLoading } from 'hooks/use-async-loading';
|
||||
import { useRouterQuery } from 'hooks/use-router-query';
|
||||
import Link from 'next/link';
|
||||
import Router from 'next/router';
|
||||
import React from 'react';
|
||||
|
@ -14,6 +15,7 @@ const { Content, Footer } = Layout;
|
|||
const { Title, Text } = Typography;
|
||||
|
||||
const Page = () => {
|
||||
const query = useRouterQuery();
|
||||
const [registerWithLoading, loading] = useAsyncLoading(registerApi);
|
||||
|
||||
const onFinish = (values) => {
|
||||
|
@ -75,7 +77,12 @@ const Page = () => {
|
|||
</Button>
|
||||
<footer>
|
||||
<Text link style={{ textAlign: 'center' }}>
|
||||
<Link href="/login">
|
||||
<Link
|
||||
href={{
|
||||
pathname: '/login',
|
||||
query,
|
||||
}}
|
||||
>
|
||||
<a>使用其他账户登录</a>
|
||||
</Link>
|
||||
</Text>
|
||||
|
|
Loading…
Reference in New Issue