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