-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #128 from sj-distributor/enhance-user-list-tree
Enhance user list tree
- Loading branch information
Showing
12 changed files
with
223 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,56 @@ | ||
import { Outlet } from "react-router-dom"; | ||
import { useEffect, useState } from "react"; | ||
import { GetCurrentAccountPermission } from "@/services/api/user-permission"; | ||
import { Spin } from "antd"; | ||
import { FrontRolePermissionEnum } from "../user/user-permissions/user-newpermissions/props"; | ||
|
||
export const Container = () => { | ||
const [permission, setPermission] = useState<{ | ||
isGetPermission: boolean; | ||
hasSwitchCameraAiBackEnd: boolean; | ||
}>({ | ||
isGetPermission: false, | ||
hasSwitchCameraAiBackEnd: false, | ||
}); | ||
|
||
useEffect(() => { | ||
GetCurrentAccountPermission() | ||
.then((response) => { | ||
if (!response) return; | ||
|
||
setPermission((prevState) => ({ | ||
...prevState, | ||
isGetPermission: true, | ||
hasSwitchCameraAiBackEnd: response.rolePermissionData.some((item) => | ||
item.permissions.some( | ||
(permission) => | ||
permission.name === | ||
FrontRolePermissionEnum.CanSwitchCameraAiBackEnd | ||
) | ||
), | ||
})); | ||
}) | ||
.catch(() => { | ||
setPermission({ | ||
isGetPermission: true, | ||
hasSwitchCameraAiBackEnd: false, | ||
}); | ||
}); | ||
}, []); | ||
|
||
return ( | ||
<div className="pt-6 px-6 flex-1 flex flex-col bg-[#F6F8FC] overflow-hidden"> | ||
<Outlet /> | ||
{permission.isGetPermission ? ( | ||
permission.hasSwitchCameraAiBackEnd ? ( | ||
<Outlet /> | ||
) : ( | ||
<div className="flex justify-center font-semibold">暂无权限</div> | ||
) | ||
) : ( | ||
<div className="w-full h-screen flex items-center justify-center"> | ||
<Spin /> | ||
</div> | ||
)} | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.