Complete main UI #37

Merged
FatttSnake merged 192 commits from FatttSnake into dev 2024-02-23 16:31:17 +08:00
4 changed files with 30 additions and 14 deletions
Showing only changes of commit aa295db6ae - Show all commits

10
src/global.d.ts vendored
View File

@@ -16,6 +16,7 @@ type RouteJsonObject = {
id?: string
element?: React.JSX.Element
component?: React.ComponentType
children?: RouteJsonObject[]
name?: string
titlePrefix?: string
title?: string
@@ -23,18 +24,21 @@ type RouteJsonObject = {
icon?: IconComponent
menu?: boolean
auth?: boolean
children?: RouteJsonObject[]
permission?: boolean
autoHide?: boolean
}
type RouteHandle = {
absolutePath: string
name?: string
menu?: boolean
auth?: boolean
titlePrefix?: string
title?: string
titlePostfix?: string
icon?: IconComponent
menu?: boolean
auth?: boolean
permission?: boolean
autoHide?: boolean
}
type _Response<T> = {

View File

@@ -5,6 +5,7 @@ import FitFullScreen from '@/components/common/FitFullScreen'
import Sidebar from '@/components/common/sidebar'
import SidebarItemList from '@/components/common/sidebar/SidebarItemList'
import SidebarItem from '@/components/common/sidebar/SidebarItem'
import { hasPathPermission } from '@/utils/auth.ts'
const ToolsFramework: React.FC = () => {
return (
@@ -14,6 +15,7 @@ const ToolsFramework: React.FC = () => {
<Sidebar
title={'个人中心'}
bottomFixed={
hasPathPermission('/system') ? (
<SidebarItemList>
<SidebarItem
path={'/system'}
@@ -21,6 +23,7 @@ const ToolsFramework: React.FC = () => {
text={'系统设置'}
/>
</SidebarItemList>
) : undefined
}
>
<SidebarItemList>

View File

@@ -11,13 +11,16 @@ const mapJsonToRoute = (jsonObject: RouteJsonObject[]): RouteObject[] => {
element: value.element,
Component: value.component,
handle: {
absolutePath: value.absolutePath,
name: value.name,
titlePrefix: value.titlePrefix,
title: value.title,
titlePostfix: value.titlePostfix,
icon: value.icon,
menu: value.menu,
auth: value.auth
auth: value.auth,
permission: value.permission,
autoHide: value.autoHide
},
children: value.children && mapJsonToRoute(value.children)
}))

View File

@@ -75,16 +75,21 @@ export const getPermissionPath = (): string[] => {
const user = JSON.parse(s) as UserWithInfoVo
const paths: string[] = []
user.menus.forEach((menu) => {
paths.join(menu.url)
paths.push(menu.url)
})
return paths
}
export const hasPathPermission = (path: string) => {
return getPermissionPath().indexOf(path) !== -1
}
/*
export const getAuthRoute = (route: RouteJsonObject[]): RouteJsonObject[] => {
return route.map((value) => {
if (value.auth) {
value.path
if (value.absolutePath) {
value.absolutePath
}
if (value.children) {
value.children = getAuthRoute(value.children)
@@ -92,6 +97,7 @@ export const getAuthRoute = (route: RouteJsonObject[]): RouteJsonObject[] => {
return value
})
}
*/
export const getCaptchaSrc = () => {
captcha = getCaptcha(300, 150, 4)