修改免费试用的跳转逻辑和设置密码的校验

This commit is contained in:
Eamon-meng
2025-07-17 14:30:51 +08:00
parent 92ab2e7b14
commit 0ae049e6f5
4 changed files with 89 additions and 40 deletions

View File

@@ -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'],
},
),

View File

@@ -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">