From 0ae049e6f5392bc7dea0ef1c851f8e33cb448f89 Mon Sep 17 00:00:00 2001 From: Eamon-meng <17516219072@163.com> Date: Thu, 17 Jul 2025 14:30:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=85=8D=E8=B4=B9=E8=AF=95?= =?UTF-8?q?=E7=94=A8=E7=9A=84=E8=B7=B3=E8=BD=AC=E9=80=BB=E8=BE=91=E5=92=8C?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=AF=86=E7=A0=81=E7=9A=84=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/(home)/customized/page.tsx | 101 ++++++++++++------ src/app/(home)/page.tsx | 13 ++- .../dialogs/change-password-dialog.tsx | 4 +- src/components/composites/purchase/index.tsx | 11 +- 4 files changed, 89 insertions(+), 40 deletions(-) diff --git a/src/app/(home)/customized/page.tsx b/src/app/(home)/customized/page.tsx index aaaf298..526f3d8 100644 --- a/src/app/(home)/customized/page.tsx +++ b/src/app/(home)/customized/page.tsx @@ -11,9 +11,10 @@ import {zodResolver} from '@hookform/resolvers/zod' import Image from 'next/image' import check from './_assets/check.svg' import banner from './_assets/Mask-group.webp' -import group from './_assets/Group.svg' +import group from './_assets/Group.webp' import {merge} from '@/lib/utils' import {useRouter} from 'next/navigation' +import {useProfileStore} from '@/components/stores-provider' const formSchema = z.object({ companyName: z.string().min(2, '企业名称至少2个字符'), @@ -37,7 +38,8 @@ export default function CollectPage() { purpose: '', }, }) - + // 从store中获取用户信息 + const profile = useProfileStore(store => store.profile) return (
@@ -60,7 +62,7 @@ export default function CollectPage() { 宣传图 @@ -108,66 +110,85 @@ export default function CollectPage() {

企业基本信息

+
-
+
+ {/* 企业名称 */} {({id, field}) => ( -
-
diff --git a/src/app/(home)/page.tsx b/src/app/(home)/page.tsx index 310dfb5..39e6ffd 100644 --- a/src/app/(home)/page.tsx +++ b/src/app/(home)/page.tsx @@ -4,9 +4,13 @@ import Wrap from '@/components/wrap' import Image from 'next/image' import React, {useState} from 'react' import {useRouter} from 'next/navigation' +import {useProfileStore} from '@/components/stores-provider' export default function Home() { const router = useRouter() + // 从store中获取用户信息 + const profile = useProfileStore(store => store.profile) + return (
@@ -36,7 +40,14 @@ export default function Home() { `mt-32 max-md:mt-20 w-96 max-md:w-full h-16 md:h-24 rounded-lg shadow-lg`, `bg-gradient-to-r from-blue-500 to-cyan-400 text-white text-xl lg:text-4xl`, ].join(' ')} - onClick={() => router.push('/login')} + onClick={() => { + if (profile) { + router.push('/admin/purchase') // 已登录用户跳转购买页 + } + else { + router.push('/login?redirect=/admin/purchase') // 未登录跳转登录页并携带重定向路径 + } + }} > 免费试用 diff --git a/src/components/composites/dialogs/change-password-dialog.tsx b/src/components/composites/dialogs/change-password-dialog.tsx index eac3bcf..960313d 100644 --- a/src/components/composites/dialogs/change-password-dialog.tsx +++ b/src/components/composites/dialogs/change-password-dialog.tsx @@ -49,9 +49,9 @@ export function ChangePasswordDialog({ const form = useForm({ 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'], }, ), diff --git a/src/components/composites/purchase/index.tsx b/src/components/composites/purchase/index.tsx index 147379b..512c30f 100644 --- a/src/components/composites/purchase/index.tsx +++ b/src/components/composites/purchase/index.tsx @@ -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(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 (