diff --git a/tone-page-web/app/console/(with-menu)/web/blog/components/AddBlog.tsx b/tone-page-web/app/console/(with-menu)/web/blog/components/AddBlog.tsx
index 7b869e3..1853ead 100644
--- a/tone-page-web/app/console/(with-menu)/web/blog/components/AddBlog.tsx
+++ b/tone-page-web/app/console/(with-menu)/web/blog/components/AddBlog.tsx
@@ -16,27 +16,13 @@ import { AdminApi } from "@/lib/api";
import { BlogPermission } from "@/lib/types/Blog.Permission.enum";
import { useState } from "react";
import { toast } from "sonner";
+import { BlogPermissionCheckBoxs } from "./BlogPermissionCheckBoxs";
interface AddBlogProps {
children: React.ReactNode;
onRefresh: () => void;
}
-const blogPermissions = [
- {
- permission: BlogPermission.Public,
- localText: '公开可读',
- },
- {
- permission: BlogPermission.ByPassword,
- localText: '受密码保护',
- },
- {
- permission: BlogPermission.List,
- localText: '显示在列表中',
- },
-] as const;
-
export default function AddBlog({ children, onRefresh }: AddBlogProps) {
const [open, setOpen] = useState(false);
const [blog, setBlog] = useState({
@@ -120,22 +106,15 @@ export default function AddBlog({ children, onRefresh }: AddBlogProps) {
{
- blogPermissions.map((v, i) => (
-
- {
- setBlog({
- ...blog,
- permissions: newChecked ?
- [...blog.permissions, v.permission] :
- [...blog.permissions].filter(p => p !== v.permission),
- })
- }} />
-
-
- ))
+
setBlog({
+ ...blog,
+ permissions: n ?
+ [...blog.permissions, p] :
+ [...blog.permissions].filter(p => p !== p),
+ })}
+ />
}
diff --git a/tone-page-web/app/console/(with-menu)/web/blog/components/BlogPermissionCheckBoxs.tsx b/tone-page-web/app/console/(with-menu)/web/blog/components/BlogPermissionCheckBoxs.tsx
new file mode 100644
index 0000000..978eafd
--- /dev/null
+++ b/tone-page-web/app/console/(with-menu)/web/blog/components/BlogPermissionCheckBoxs.tsx
@@ -0,0 +1,41 @@
+import { Checkbox } from "@/components/ui/checkbox";
+import { Label } from "@/components/ui/label";
+import { BlogPermission } from "@/lib/types/Blog.Permission.enum";
+
+const blogPermissions = [
+ {
+ permission: BlogPermission.Public,
+ localText: '公开可读',
+ },
+ {
+ permission: BlogPermission.ByPassword,
+ localText: '受密码保护',
+ },
+ {
+ permission: BlogPermission.List,
+ localText: '显示在列表中',
+ },
+] as const;
+
+interface BlogPermissionCheckBoxsProps {
+ permissions: BlogPermission[];
+ onCheckedChange: (permission: BlogPermission, newState: boolean) => void;
+}
+
+export function BlogPermissionCheckBoxs({ permissions, onCheckedChange }: BlogPermissionCheckBoxsProps) {
+ return (
+ <>
+ {
+ blogPermissions.map((v, i) => (
+
+ onCheckedChange(v.permission, !!newChecked)} />
+
+
+ ))
+ }
+ >
+ )
+}
\ No newline at end of file