'use client'; import { Button } from "@/components/ui/button" import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "@/components/ui/dialog" import { Input } from "@/components/ui/input" import { Label } from "@/components/ui/label" import { FC } from "react"; import { DialogProps } from "@radix-ui/react-dialog"; import { toast } from "sonner"; import { UserAPI } from "@/lib/api/client"; import { handleAPIError } from "@/lib/api/common"; export default function SetPassword({ onOpenChange, ...props }: React.ComponentProps>) { async function handleSetPassword(password: string) { try { await UserAPI.updatePassword(password); toast.success('新密码设置成功'); onOpenChange?.(false); } catch (error) { handleAPIError(error, ({ message }) => toast.error(message || '新密码设置失败')) } } return ( 修改密码 新密码长度在6-32位之间,且至少包含一个字母和一个数字,可以包含特殊字符
{ e.preventDefault(); const formData = new FormData(e.currentTarget); const password = formData.get('password') as string; handleSetPassword(password); }}>
) }