添加联系表单提交接口和邮件通知功能,支持从环境变量读取 SMTP 配置 重构 SEO 配置到 site.json,新增 robots.txt 和 sitemap.xml 生成 更新公司电话并添加 PM2 生产运行配置
28 lines
887 B
TypeScript
28 lines
887 B
TypeScript
import { z } from "zod"
|
|
|
|
function requiredTextField(label: string, maxLength: number) {
|
|
return z.preprocess(
|
|
(value) => typeof value === "string" ? value.trim() : "",
|
|
z.string()
|
|
.min(1, `请填写${label}`)
|
|
.max(maxLength, `${label}不能超过 ${maxLength} 个字符`)
|
|
)
|
|
}
|
|
|
|
function optionalTextField(label: string, maxLength: number) {
|
|
return z.preprocess(
|
|
(value) => typeof value === "string" ? value.trim() : "",
|
|
z.string().max(maxLength, `${label}不能超过 ${maxLength} 个字符`)
|
|
)
|
|
}
|
|
|
|
export const contactFormSchema = z.object({
|
|
name: requiredTextField("姓名", 80),
|
|
company: requiredTextField("公司 / 品牌", 120),
|
|
phone: requiredTextField("联系电话", 40),
|
|
scale: optionalTextField("门店规模", 120),
|
|
message: optionalTextField("需求描述", 2000),
|
|
})
|
|
|
|
export type ContactFormData = z.infer<typeof contactFormSchema>
|