Skip to content

Commit

Permalink
feat(permission): 添加useAuthority hooks使用示例
Browse files Browse the repository at this point in the history
  • Loading branch information
wangxingkang committed Nov 11, 2020
1 parent 622d23b commit 9fa3c9d
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/pages/permission/button/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
import React, { useState } from 'react';
import { Authority } from 'umi';
import React, { useState, useEffect } from 'react';
import { Authority, useAuthority } from 'umi';
import { Radio, Divider, Alert, Tag, Space } from 'antd';
import { RadioChangeEvent } from 'antd/es/radio/interface';
import { PageContainer } from '@ant-design/pro-layout';

const PermissionButton: React.FC = () => {
const [role, setRole] = useState<string>('admin');

const { singleVerify } = useAuthority();

const showList = singleVerify('dashboard:list')

useEffect(
() => {
if (showList) {
// 请求数据

}
},
[showList]
)

const handleChange = (e: RadioChangeEvent) => {
setRole(e.target.value);
}
Expand Down

1 comment on commit 9fa3c9d

@vercel
Copy link

@vercel vercel bot commented on 9fa3c9d Nov 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.