feat: update template

This commit is contained in:
2026-08-19 22:07:42 +08:00
parent 99d5392a68
commit 6c45b75786
97 changed files with 1460 additions and 477 deletions

View File

@@ -1,6 +1,6 @@
import { z } from 'zod'
import { fileFormSchema } from '@/schemas'
import { uploadedFileSchema } from '@/schemas'
export const postSchema = z.object({
id: z.number().int(),
@@ -8,21 +8,27 @@ export const postSchema = z.object({
cover_id: z.number().int(),
cover: z.string(),
slug: z.string(),
content: z.string(),
summary: z.string(),
status: z.number().int(),
view: z.number().int(),
view_count: z.number().int(),
sort: z.number().int(),
category_name: z.string(),
category_id: z.number().int().optional(),
published_at: z.string(),
tags: z.array(z.number().int()),
cover_size: z.number(),
created_at: z.string(),
updated_at: z.string(),
tags: z.array(z.number().int()),
})
export const postDetailSchema = postSchema.extend({
content: z.string(),
})
export type Post = z.infer<typeof postSchema>
export type PostDetail = z.infer<typeof postDetailSchema>
export const postFormSchema = z
.object({
id: z.number().int().optional(),
@@ -34,7 +40,7 @@ export const postFormSchema = z
summary: z.string(),
status: z.number().int(),
published_at: z.string().min(1, '请选择发布日期!'),
cover: fileFormSchema,
cover: uploadedFileSchema.optional(),
sort: z.coerce.number<number>().int().min(0, '排序值不能小于0'),
content: z.string().optional(),
category_id: z
@@ -48,7 +54,7 @@ export const postFormSchema = z
const { cover, ...rest } = data
return {
...rest,
cover_id: cover && cover.id,
cover_id: cover?.id || null,
}
})