Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update(userlogin): update readme and example #226

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/base/src/layouts/UserLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const UserLayout = (props: KktproPageProps) => {
userName: 'username',
passWord: 'password',
}}
footer={<div className="copyright-footer">可以自定义页脚内容</div>}
// onBefore={(store) => ({ a: 12, b: 1221, ...store })}
onSuccess={(data) => {
if (data && data.token) {
Expand Down
2 changes: 2 additions & 0 deletions examples/website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
"@react-login-page/page5": "^0.4.4",
"@react-login-page/page6": "^0.4.4",
"@react-login-page/page7": "^0.4.4",
"@react-login-page/page8": "^0.4.4",
"@react-login-page/page9": "^0.4.4",
"@types/styled-components": "^5.1.26",
"@uiw-admin/authorized": "6.1.9",
"@uiw-admin/basic-layouts": "6.1.9",
Expand Down
34 changes: 2 additions & 32 deletions examples/website/src/pages/request/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import { useReactQuery, useReactMutation, queryClient, fetchFn } from '@kkt/pro'
主要用于**默认**触发请求数据,默认 `GET` 请求,变更使用 `method="POST"` 参数配置

```jsx
useReactQuery({
queryKey: ['user', userId],
useReactQuery({
queryKey: ['user', userId],
url: `/api/user/list?id=${userId}`
});
```
Expand Down Expand Up @@ -113,36 +113,6 @@ import { request } from "@uiw-admin/utils"

**调用方式**

**✨配和swr调用**
> 如果已全局配置过swr,可不用传入request

```tsx
import React from 'react'
import useSWR from 'swr';
import { request } from "@uiw-admin/utils"

export default const Index = () => {
const [ name ,setName ] = React.useState('')
const { mutate } = useSWR(
['/api/selectById',{ method: 'POST', body: {id:1} }],
request,
{
revalidateOnMount: false,
revalidateOnFocus: false,
onSuccess: (data) => {
if (data && data.code === 200) {
setName(data.data)
}
},
}
)

React.useEffect(()=>mutate(false),[mutate])

return <div>{name}</div>
}

```
**在rematch中使用**

> 在servers/index.js中
Expand Down
25 changes: 25 additions & 0 deletions examples/website/src/pages/user-login/Examples.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import Login4 from '@react-login-page/page4';
import Login5 from '@react-login-page/page5';
import Login6 from '@react-login-page/page6';
import Login7 from '@react-login-page/page7';
import Login8 from '@react-login-page/page8';
import Login9 from '@react-login-page/page9';
import Login9Bg from '@react-login-page/page9/bg.jpg';

const bannerImage = require('@react-login-page/page2/banner-image');
const bannerImage3 = require('@react-login-page/page3/banner-image');
Expand Down Expand Up @@ -107,3 +110,25 @@ export const page7: Example = {
</Login7>
),
};

export const page8: Example = {
magnify: 2.2,
children: (
<Login8>
<Login8.Logo>
<LoginLogo />
</Login8.Logo>
</Login8>
),
};

export const page9: Example = {
magnify: 2.2,
children: (
<Login9 style={{ backgroundImage: `url(${Login9Bg})` }}>
<Login9.Logo>
<LoginLogo />
</Login9.Logo>
</Login9>
),
};
34 changes: 32 additions & 2 deletions packages/user-login/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,36 @@ const UserLayout = () => {
export default UserLayout;
```

## 自定义页脚

`footer`:自定义页脚内容

<!--rehype:bgwhite=true&codesandbox=true&codepen=true-->
```jsx mdx:preview
import React from 'react';
import UserLogin from '@uiw-admin/user-login';
import { useNavigate, } from 'react-router-dom';
import { Notify } from "uiw"

const UserLayout = () => {
return (
<UserLogin
api="/api/login"
footer={<div className="copyright-footer">可以自定义页脚内容</div>}
onSuccess={(data) => {
if (data && data.token) {
sessionStorage.setItem("token", data.token)
sessionStorage.setItem("auth", JSON.stringify(data.authList || []))
} else {
Notify.error({ title: "错误通知", description: data?.message || "请求失败" })
}
}}
/>
)
}
export default UserLayout;
```

## 自定义背景样式

`styleContainer`:自定义背景样式 ,`bg`:可直接修改背景图片
Expand Down Expand Up @@ -499,7 +529,7 @@ export interface UserLoginProps {
footer?: React.ReactNode;
/** 背景图片 */
bg?: string;
/** 如果存在 children 则 覆盖默认登录框里面内容 */
/** 如果存在 children 则 覆盖默认登录框里面内容 */
children?: React.ReactNode;
/** 项目名称 */
projectName?: string;
Expand Down Expand Up @@ -554,7 +584,7 @@ export interface UserLoginProps {

```tsx
export interface FieldsProps<T = any> extends FormFieldsProps<T> {
/** 保存字段 */
/** 保存字段 */
name: string;
// 验证输入框值 value:输入框的值,current:当前表单的值,返回值为 string 类型时,进行报错提示
verification?: (value: any, current: Record<string, any>) => string | boolean | null,
Expand Down
29 changes: 0 additions & 29 deletions packages/utils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,36 +25,7 @@
| requestType | 数据格式 | 'form' 或 'json' 或 'urlencoded' | - |

### 调用方式
### ✨配和swr调用
> 如果已全局配置过swr,可不用传入request

```tsx
import React from 'react'
import useSWR from 'swr';
import { request } from "@uiw-admin/utils"

export default const Index = () => {
const [ name ,setName ] = React.useState('')
const { mutate } = useSWR(
['/api/selectById',{ method: 'POST', body: {id:1} }],
request,
{
revalidateOnMount: false,
revalidateOnFocus: false,
onSuccess: (data) => {
if (data && data.code === 200) {
setName(data.data)
}
},
}
)

React.useEffect(()=>mutate(false),[mutate])

return <div>{name}</div>
}

```
### 在rematch中使用
> 在servers/index.js中
```ts
Expand Down