From e91367702b7de28930a3d65c3a4b01edc2ebea00 Mon Sep 17 00:00:00 2001 From: Arvin Xu Date: Sun, 28 Nov 2021 16:35:13 +0800 Subject: [PATCH] =?UTF-8?q?:pushpin:=20chore:=20=E9=94=81=E5=AE=9A=20react?= =?UTF-8?q?-router=20=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 9 ++-- packages/layout-kit/src/layout-kit.md | 4 +- packages/user-panel/demos/LoginWithFooter.tsx | 4 +- .../user-panel/demos/LoginWithForgotUrl.tsx | 4 +- packages/user-panel/package.json | 2 +- .../src/components/Footer/index.tsx | 11 ++-- packages/user-panel/src/login/index.tsx | 15 +++--- yarn.lock | 50 ++++++++----------- 8 files changed, 45 insertions(+), 54 deletions(-) diff --git a/package.json b/package.json index 33f8c7c2..fb98768b 100644 --- a/package.json +++ b/package.json @@ -60,8 +60,8 @@ }, "devDependencies": { "@ant-design/icons": "^4.x", - "@ant-design/pro-skeleton": "^1.0.2", "@ant-design/pro-form": "^1.x", + "@ant-design/pro-skeleton": "^1.0.2", "@babel/core": "^7.8.3", "@babel/plugin-proposal-object-rest-spread": "^7.8.3", "@babel/plugin-transform-react-jsx": "^7.12.16", @@ -96,6 +96,7 @@ "concurrently": "^6.0.0", "cross-env": "^7.0.0", "css-loader": "^5.1.3", + "dayjs": "^1.10.5", "dpdm": "^3.5.0", "ejs": "^3.1.6", "enzyme-to-json": "^3.4.3", @@ -133,13 +134,13 @@ "utility-types": "^3.10.0", "webpack": "^5.26.1", "webpack-bundle-analyzer": "^4.1.0", - "webpack-cli": "^4.5.0", - "dayjs": "^1.10.5" + "webpack-cli": "^4.5.0" }, "resolutions": { "typescript": "4.4.3" }, "engines": { "node": ">=8.0.0" - } + }, + "dependencies": {} } diff --git a/packages/layout-kit/src/layout-kit.md b/packages/layout-kit/src/layout-kit.md index 91f65aba..2b0844c1 100644 --- a/packages/layout-kit/src/layout-kit.md +++ b/packages/layout-kit/src/layout-kit.md @@ -1,12 +1,12 @@ --- -title: LayoutToolkit 布局工具库 +title: LayoutKit 布局工具库 group: path: / nav: path: /components --- -# LayoutToolkit 布局工具库 +# LayoutKit 布局工具库 [![NPM version][version-image]][version-url] [![NPM downloads][download-image]][download-url] diff --git a/packages/user-panel/demos/LoginWithFooter.tsx b/packages/user-panel/demos/LoginWithFooter.tsx index 0752b35d..54508afb 100644 --- a/packages/user-panel/demos/LoginWithFooter.tsx +++ b/packages/user-panel/demos/LoginWithFooter.tsx @@ -21,8 +21,8 @@ const LoginWithFooter = () => { onWechatLoginClick={() => { message.info('微信登录实现方法'); }} - onRegisterClick={(navigate) => { - navigate('/components/biz/user-panel#显示底部'); + onRegisterClick={(history) => { + history.push('/components/biz/user-panel#显示底部'); }} /> diff --git a/packages/user-panel/demos/LoginWithForgotUrl.tsx b/packages/user-panel/demos/LoginWithForgotUrl.tsx index 71277378..2bbfe285 100644 --- a/packages/user-panel/demos/LoginWithForgotUrl.tsx +++ b/packages/user-panel/demos/LoginWithForgotUrl.tsx @@ -16,8 +16,8 @@ const LoginWithLogo = () => { }} > { - navigate('/components/biz/user-panel'); + onForgotClick={(history) => { + history.push('/components/biz/user-panel'); }} /> diff --git a/packages/user-panel/package.json b/packages/user-panel/package.json index b74cced6..e838c220 100644 --- a/packages/user-panel/package.json +++ b/packages/user-panel/package.json @@ -29,7 +29,7 @@ "dependencies": { "@arvinxu/i18n": "1.0.1", "classnames": "^2.3.1", - "react-router": "^6.0.2" + "react-router": "^5.2.1" }, "peerDependencies": { "@ant-design/icons": "^4.x", diff --git a/packages/user-panel/src/components/Footer/index.tsx b/packages/user-panel/src/components/Footer/index.tsx index b80b3c99..2b1922dd 100644 --- a/packages/user-panel/src/components/Footer/index.tsx +++ b/packages/user-panel/src/components/Footer/index.tsx @@ -1,8 +1,7 @@ import React from 'react'; import type { FC } from 'react'; -import type { NavigateFunction } from 'react-router'; -import { useNavigate } from 'react-router'; - +import type * as H from 'history'; +import { useHistory } from 'react-router'; import { Typography, Divider } from 'antd'; import WechatLogin from '../WechatLogin'; @@ -27,7 +26,7 @@ export interface FooterProps { /** * @title 注册页面 Url */ - onRegisterClick?: (navigate: NavigateFunction) => void; + onRegisterClick?: (history: H.History) => void; } export const Footer: FC = ({ @@ -37,12 +36,12 @@ export const Footer: FC = ({ }) => { const f = useFormatMessage(); - const navigate = useNavigate(); + const history = useHistory(); const onClick = () => { switch (type) { case 'login': - onRegisterClick?.(navigate); + onRegisterClick?.(history); break; case 'register': break; diff --git a/packages/user-panel/src/login/index.tsx b/packages/user-panel/src/login/index.tsx index bfcd09e9..6ec5dbe1 100644 --- a/packages/user-panel/src/login/index.tsx +++ b/packages/user-panel/src/login/index.tsx @@ -11,14 +11,13 @@ import ProForm, { ProFormCheckbox, ProFormText, } from '@ant-design/pro-form'; -import type { NavigateFunction } from 'react-router'; -import { useNavigate } from 'react-router'; - import LoginErrorMessage from './LoginErrorMessage'; -import type { IUserLogin } from '../types'; -import { useFormatMessage } from '../components'; import './index.less'; +import { useFormatMessage } from '../components'; +import type { IUserLogin } from '../types'; +import * as H from 'history'; +import { useHistory } from 'react-router'; export interface LoginProps { /** @@ -36,7 +35,7 @@ export interface LoginProps { /** * 忘记密码 url */ - onForgotClick?: (navigate: NavigateFunction) => void; + onForgotClick?: (history: H.History) => void; } const Login: React.FC = (props) => { @@ -49,7 +48,7 @@ const Login: React.FC = (props) => { const { status, type: loginType } = loginStatus; const f = useFormatMessage(); - const navigate = useNavigate(); + const history = useHistory(); return (
@@ -208,7 +207,7 @@ const Login: React.FC = (props) => { float: 'right', }} onClick={() => { - onForgotClick(navigate); + onForgotClick(history); }} > {f('login.forgotPassword')} diff --git a/yarn.lock b/yarn.lock index 3c8de421..a3549808 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1983,7 +1983,7 @@ dependencies: regenerator-runtime "^0.13.4" -"@babel/runtime@^7.2.0", "@babel/runtime@^7.7.6": +"@babel/runtime@^7.12.13", "@babel/runtime@^7.2.0": version "7.16.3" resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.16.3.tgz#b86f0db02a04187a3c17caa77de69840165d42d5" integrity sha512-WBwekcqacdY2e9AF/Q7WLFUWmdJGJTkbjqTjoMDgXkVZ3ZRUvOPsLb5KdwISoQVsbP+DQzVZW4Zhci0DvpbNTQ== @@ -7035,20 +7035,10 @@ caniuse-api@^3.0.0: lodash.memoize "^4.1.2" lodash.uniq "^4.5.0" -caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000971, caniuse-lite@^1.0.30000981, caniuse-lite@^1.0.30001109: - version "1.0.30001187" - resolved "https://registry.npm.taobao.org/caniuse-lite/download/caniuse-lite-1.0.30001187.tgz#5706942631f83baa5a0218b7dfa6ced29f845438" - integrity sha1-VwaUJjH4O6paAhi336bO0p+EVDg= - -caniuse-lite@^1.0.30001219: - version "1.0.30001233" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001233.tgz#b7cb4a377a4b12ed240d2fa5c792951a06e5f2c4" - integrity sha512-BmkbxLfStqiPA7IEzQpIk0UFZFf3A4E6fzjPJ6OR+bFC2L8ES9J8zGA/asoi47p8XDVkev+WJo2I2Nc8c/34Yg== - -caniuse-lite@^1.0.30001254: - version "1.0.30001259" - resolved "https://registry.nlark.com/caniuse-lite/download/caniuse-lite-1.0.30001259.tgz?cache=0&sync_timestamp=1632203514424&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fcaniuse-lite%2Fdownload%2Fcaniuse-lite-1.0.30001259.tgz#ae21691d3da9c4be6144403ac40f71d9f6efd790" - integrity sha1-riFpHT2pxL5hREA6xA9x2fbv15A= +caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000971, caniuse-lite@^1.0.30000981, caniuse-lite@^1.0.30001109, caniuse-lite@^1.0.30001219, caniuse-lite@^1.0.30001254: + version "1.0.30001283" + resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001283.tgz" + integrity sha512-9RoKo841j1GQFSJz/nCXOj0sD7tHBtlowjYlrqIUS812x9/emfBLBt6IyMz1zIaYc/eRL8Cs6HPUVi2Hzq4sIg== canvas@2.6.1: version "2.6.1" @@ -11193,13 +11183,6 @@ history@^4.7.2, history@^4.9.0: tiny-warning "^1.0.0" value-equal "^1.0.1" -history@^5.1.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/history/-/history-5.1.0.tgz#2e93c09c064194d38d52ed62afd0afc9d9b01ece" - integrity sha512-zPuQgPacm2vH2xdORvGGz1wQMuHSIB56yNAy5FnLuwOwgSYyPKptJtcMm6Ev+hRGeS+GzhbmRacHzvlESbFwDg== - dependencies: - "@babel/runtime" "^7.7.6" - hmac-drbg@^1.0.1: version "1.0.1" resolved "https://registry.npm.taobao.org/hmac-drbg/download/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1" @@ -18687,13 +18670,6 @@ react-router-dom@5.2.0, react-router-dom@^5.1.2: tiny-invariant "^1.0.2" tiny-warning "^1.0.0" -react-router@*: - version "6.0.2" - resolved "https://registry.yarnpkg.com/react-router/-/react-router-6.0.2.tgz#bd2b0fa84fd1d152671e9f654d9c0b1f5a7c86da" - integrity sha512-8/Wm3Ed8t7TuedXjAvV39+c8j0vwrI5qVsYqjFr5WkJjsJpEvNSoLRUbtqSEYzqaTUj1IV+sbPJxvO+accvU0Q== - dependencies: - history "^5.1.0" - react-router@5.2.0: version "5.2.0" resolved "https://registry.npm.taobao.org/react-router/download/react-router-5.2.0.tgz#424e75641ca8747fbf76e5ecca69781aa37ea293" @@ -18710,6 +18686,22 @@ react-router@5.2.0: tiny-invariant "^1.0.2" tiny-warning "^1.0.0" +react-router@^5.2.1: + version "5.2.1" + resolved "https://registry.yarnpkg.com/react-router/-/react-router-5.2.1.tgz#4d2e4e9d5ae9425091845b8dbc6d9d276239774d" + integrity sha512-lIboRiOtDLFdg1VTemMwud9vRVuOCZmUIT/7lUoZiSpPODiiH1UQlfXy+vPLC/7IWdFYnhRwAyNqA/+I7wnvKQ== + dependencies: + "@babel/runtime" "^7.12.13" + history "^4.9.0" + hoist-non-react-statics "^3.1.0" + loose-envify "^1.3.1" + mini-create-react-context "^0.4.0" + path-to-regexp "^1.7.0" + prop-types "^15.6.2" + react-is "^16.6.0" + tiny-invariant "^1.0.2" + tiny-warning "^1.0.0" + react-side-effect@^2.1.0: version "2.1.1" resolved "https://registry.npm.taobao.org/react-side-effect/download/react-side-effect-2.1.1.tgz#66c5701c3e7560ab4822a4ee2742dee215d72eb3"