Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
37fc934233 | ||
|
|
aebbaadfac | ||
|
|
6929f6535c | ||
|
|
e2f2b1518c | ||
|
|
e0d42f8913 | ||
|
|
4ed199fc89 | ||
|
|
1b68171ea0 | ||
|
|
ae23186c56 |
@@ -70,7 +70,7 @@ volumes:
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
# - prod
|
||||
# - prod
|
||||
- dev
|
||||
event:
|
||||
- push
|
||||
|
||||
@@ -4,6 +4,8 @@ import './assets/styles/login.scss'
|
||||
import { getCaptchaApi, loginApi } from "./api/login";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { setToken } from "./utils/auth";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { addAuthInfo, getAuthInfo } from "./stores/auth";
|
||||
|
||||
type Login = {
|
||||
uuid?: string,
|
||||
@@ -16,8 +18,14 @@ export default function Login() {
|
||||
const [messageApi, contextHolder] = message.useMessage()
|
||||
const [uuid, setUuid] = useState<string>('')
|
||||
const [captcha, setCaptcha] = useState<string>('')
|
||||
const dispatch = useDispatch()
|
||||
const navigate = useNavigate()
|
||||
|
||||
const requestAuthInfo = async () => {
|
||||
const { payload } = await dispatch(getAuthInfo() as any)
|
||||
dispatch(addAuthInfo(payload))
|
||||
}
|
||||
|
||||
const getCaptcha = async () => {
|
||||
try {
|
||||
const { code, data } = await getCaptchaApi()
|
||||
@@ -37,6 +45,7 @@ export default function Login() {
|
||||
if (code === 1000) {
|
||||
setToken(data)
|
||||
messageApi.success(msg)
|
||||
requestAuthInfo()
|
||||
navigate('/')
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useState } from "react";
|
||||
import { useSelector } from "react-redux";
|
||||
|
||||
/**
|
||||
* @author {温华}
|
||||
@@ -9,9 +10,10 @@ import { useState } from "react";
|
||||
|
||||
export default function Authenticationbtn({ permission, children }: any) {
|
||||
// 还需从缓存中获取用户权限数组
|
||||
const authInfo = useSelector((store: any) => store.auth)
|
||||
const [visible, setVisible] = useState(true)
|
||||
const allPermission: string = "*:*:*"
|
||||
const authPermissions: Array<string> = []
|
||||
const authPermissions: Array<string> = authInfo.permissions
|
||||
if(permission && permission instanceof Array && permission.length > 0) {
|
||||
const permissiosFlag = permission
|
||||
const hasPermission = authPermissions.some((perm: string)=>{
|
||||
@@ -20,6 +22,6 @@ export default function Authenticationbtn({ permission, children }: any) {
|
||||
setVisible(hasPermission)
|
||||
}
|
||||
|
||||
if(visible) return <div>{children}</div>
|
||||
if(visible) return children
|
||||
return null
|
||||
}
|
||||
@@ -46,7 +46,7 @@ const currentRouter: Array<route> = [
|
||||
},
|
||||
{
|
||||
path: '/login',
|
||||
element: lazyLoad('login')
|
||||
element: <Suspense fallback={<Loading />}>{lazyLoad('login')}</Suspense>
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
import Authenticationbtn from "@/components/Authenticationbtn";
|
||||
import { Button } from "antd";
|
||||
|
||||
export default function Home() {
|
||||
return(
|
||||
<div>home</div>
|
||||
<Authenticationbtn permission="['system:list']">
|
||||
<Button>测试</Button>
|
||||
</Authenticationbtn>
|
||||
)
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
base: './',
|
||||
base: '/',
|
||||
plugins: [
|
||||
react(),
|
||||
createSvgIconsPlugin({
|
||||
|
||||
Reference in New Issue
Block a user