-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
62 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { z } from "zod" | ||
|
||
export const albumSchema = z.object({ | ||
id: z.string(), | ||
title: z.string(), | ||
cover: z.string(), | ||
url: z.string(), | ||
slogan: z.string(), | ||
updatedAt: z.date(), | ||
digitalDownloads: z.number(), | ||
}) | ||
|
||
export type IAlbum = z.infer<typeof albumSchema> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import type { LucideIcon } from "lucide-react" | ||
import { z } from "zod" | ||
|
||
// 由于 LucideIcon 是一个类型,我们需要使用 custom 方法来验证 | ||
const LucideIconSchema = z.custom<LucideIcon>( | ||
(data) => { | ||
return typeof data === "function" | ||
}, | ||
{ | ||
message: "Invalid Lucide icon", | ||
}, | ||
) | ||
|
||
// 子菜单项 Schema | ||
export const ChildrenMenuItemSchema = z.object({ | ||
title: z.string(), | ||
label: z.string().optional(), | ||
icon: LucideIconSchema, | ||
to: z.string().url(), | ||
}) | ||
|
||
// 菜单项 Schema | ||
export const MenuItemSchema = z.object({ | ||
title: z.string(), | ||
label: z.string().optional(), | ||
icon: LucideIconSchema, | ||
to: z.string().url(), | ||
children: z.array(ChildrenMenuItemSchema).optional(), | ||
}) | ||
|
||
// 导出类型 | ||
export type IChildrenMenuItem = z.infer<typeof ChildrenMenuItemSchema> | ||
export type MenuItem = z.infer<typeof MenuItemSchema> | ||
export type IMenu = MenuItem | ||
|
||
// 如果需要验证菜单数组 | ||
export const MenuArraySchema = z.array(MenuItemSchema) |
File renamed without changes.