From 076dc1269f273ef6ca4abf5f2c10ceaa2578f985 Mon Sep 17 00:00:00 2001
From: ShukeBta <272197458+ShukeBta@users.noreply.github.com>
Date: Wed, 24 Jun 2026 23:16:36 +0800
Subject: [PATCH] refactor: split profile form sections
---
web/src/pages/ProfileFormModal.tsx | 183 ++-------------------
web/src/pages/ProfileFormSections.tsx | 226 ++++++++++++++++++++++++++
2 files changed, 237 insertions(+), 172 deletions(-)
create mode 100644 web/src/pages/ProfileFormSections.tsx
diff --git a/web/src/pages/ProfileFormModal.tsx b/web/src/pages/ProfileFormModal.tsx
index a4d0348..e22cdb4 100644
--- a/web/src/pages/ProfileFormModal.tsx
+++ b/web/src/pages/ProfileFormModal.tsx
@@ -1,9 +1,14 @@
-import { FormEvent, useState, type ReactNode } from 'react'
-import { Loader2 } from 'lucide-react'
+import { FormEvent, useState } from 'react'
import toast from 'react-hot-toast'
import { playProfilesAPI, type PlayProfileInput } from '../api/play_profiles'
import type { Library, PlayProfile } from '../types'
+import {
+ ProfileFormActions,
+ ProfileIdentityFields,
+ ProfileLibraryAccessField,
+ ProfilePreferenceFields,
+} from './ProfileFormSections'
type ProfileFormModalProps = {
editing: PlayProfile | null
@@ -72,178 +77,12 @@ export function ProfileFormModal({
{editing ? '编辑 Profile' : '创建 Profile'}
)
}
-
-function Field({ label, children }: { label: string; children: ReactNode }) {
- return (
-
- )
-}
-
-function Toggle({
- label,
- hint,
- checked,
- onChange,
-}: {
- label: string
- hint?: string
- checked: boolean
- onChange: (value: boolean) => void
-}) {
- return (
-
- )
-}
diff --git a/web/src/pages/ProfileFormSections.tsx b/web/src/pages/ProfileFormSections.tsx
new file mode 100644
index 0000000..66b49d0
--- /dev/null
+++ b/web/src/pages/ProfileFormSections.tsx
@@ -0,0 +1,226 @@
+import type { ReactNode } from 'react'
+import { Loader2 } from 'lucide-react'
+
+import type { PlayProfileInput } from '../api/play_profiles'
+import type { Library, PlayProfile } from '../types'
+
+type ProfileFormUpdate = (patch: Partial) => void
+
+export function ProfileIdentityFields({
+ form,
+ editing,
+ update,
+}: {
+ form: PlayProfileInput
+ editing: PlayProfile | null
+ update: ProfileFormUpdate
+}) {
+ return (
+ <>
+
+ update({ name: event.target.value })}
+ />
+
+
+ update({ is_default: value })}
+ />
+
+
+
+
+
+ update({ allow_adult: value })}
+ />
+
+ update({ require_pin: value })}
+ />
+ {form.require_pin && (
+
+ update({ pin: event.target.value })}
+ />
+
+ )}
+ >
+ )
+}
+
+export function ProfilePreferenceFields({
+ form,
+ update,
+}: {
+ form: PlayProfileInput
+ update: ProfileFormUpdate
+}) {
+ return (
+ <>
+
+
+
+
+
+
+
+
+
+ update({ autoplay_next: value })}
+ />
+ update({ skip_intro: value })}
+ />
+ >
+ )
+}
+
+export function ProfileLibraryAccessField({
+ form,
+ libraries,
+ onToggleLibrary,
+}: {
+ form: PlayProfileInput
+ libraries: Library[]
+ onToggleLibrary: (id: string) => void
+}) {
+ return (
+
+
+ {libraries.map((library) => (
+
+ ))}
+ {libraries.length === 0 && (
+ 暂无媒体库
+ )}
+
+
+ )
+}
+
+export function ProfileFormActions({
+ saving,
+ onClose,
+}: {
+ saving: boolean
+ onClose: () => void
+}) {
+ return (
+
+
+
+
+ )
+}
+
+function Field({ label, children }: { label: string; children: ReactNode }) {
+ return (
+
+ )
+}
+
+function Toggle({
+ label,
+ hint,
+ checked,
+ onChange,
+}: {
+ label: string
+ hint?: string
+ checked: boolean
+ onChange: (value: boolean) => void
+}) {
+ return (
+
+ )
+}