修改免费试用的跳转逻辑和设置密码的校验
This commit is contained in:
@@ -49,9 +49,9 @@ export function ChangePasswordDialog({
|
||||
const form = useForm<Schema>({
|
||||
resolver: zodResolver(
|
||||
schema.refine(
|
||||
data => /^(?=.*[a-z])(?=.*[A-Z]).{6,}$/.test(data.password),
|
||||
data => /^(?=.*[a-zA-Z])(?=.*\d).{6,}$/.test(data.password),
|
||||
{
|
||||
message: '密码需包含大小写字母,且不少于6位',
|
||||
message: '密码需包含字母和数字,且不少于6位',
|
||||
path: ['password'],
|
||||
},
|
||||
),
|
||||
|
||||
@@ -4,7 +4,8 @@ import {merge} from '@/lib/utils'
|
||||
import {Tabs, TabsContent, TabsList, TabsTrigger} from '@/components/ui/tabs'
|
||||
import LongForm from '@/components/composites/purchase/long/form'
|
||||
import ShortForm from '@/components/composites/purchase/short/form'
|
||||
|
||||
import {useProfileStore} from '@/components/stores-provider'
|
||||
import {useRouter} from 'next/navigation'
|
||||
export type TabType = 'short' | 'long' | 'fixed' | 'custom'
|
||||
|
||||
type PurchaseProps = {
|
||||
@@ -13,10 +14,14 @@ type PurchaseProps = {
|
||||
|
||||
export default function Purchase(props: PurchaseProps) {
|
||||
const [currentTab, setCurrentTab] = useState<string>(props.defaultType)
|
||||
|
||||
const profile = useProfileStore(store => store.profile)
|
||||
const router = useRouter()
|
||||
useEffect(() => {
|
||||
setCurrentTab(props.defaultType)
|
||||
}, [props.defaultType])
|
||||
if (!profile) {
|
||||
router.push('/login?redirect=/admin/purchase') // 未登录用户重定向到登录页
|
||||
}
|
||||
}, [props.defaultType, profile, router])
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-4">
|
||||
|
||||
Reference in New Issue
Block a user