实现权限列表与权限渲染组件

This commit is contained in:
2026-03-31 10:56:01 +08:00
parent 2c7970796f
commit 12b60e74df
7 changed files with 94 additions and 3 deletions

View File

@@ -1,5 +1,6 @@
"use client"
import { zodResolver } from "@hookform/resolvers/zod"
import { useSetAtom } from "jotai"
import { useRouter } from "next/navigation"
import { Controller, useForm } from "react-hook-form"
import { toast } from "sonner"
@@ -16,6 +17,7 @@ import {
FieldLegend,
} from "@/components/ui/field"
import { Input } from "@/components/ui/input"
import { scopesAtom } from "@/lib/stores/scopes"
const schema = z.object({
username: z.string().min(4).max(50),
@@ -36,7 +38,7 @@ export default function LoginPage() {
})
const router = useRouter()
const setScopes = useSetAtom(scopesAtom)
const onSubmit = async (data: Schema) => {
try {
const resp = await login(data)
@@ -45,6 +47,8 @@ export default function LoginPage() {
}
// 登录成功后跳转到首页
console.log("用户权限列表", resp.data)
setScopes(resp.data)
router.push("/")
} catch (e) {
toast.error("登录失败", {