feat: update user preferences and system settings management

This commit is contained in:
2026-02-03 16:37:05 +08:00
parent 555bf38b71
commit 5a22351a66
21 changed files with 417 additions and 153 deletions

View File

@@ -33,7 +33,6 @@ const formSchema = z.object({
top_k: z.number().min(1).max(100).optional(),
top_p: z.number().min(0).max(1).optional(),
repetition_penalty: z.number().min(0).max(2).optional(),
backend: z.string().optional(),
})
type FormData = z.infer<typeof formSchema>
@@ -77,16 +76,9 @@ const CustomVoiceForm = forwardRef<CustomVoiceFormHandle>((_props, ref) => {
top_k: 20,
top_p: 0.7,
repetition_penalty: 1.05,
backend: preferences?.default_backend || 'local',
},
})
useEffect(() => {
if (preferences?.default_backend) {
setValue('backend', preferences.default_backend)
}
}, [preferences?.default_backend, setValue])
useImperativeHandle(ref, () => ({
loadParams: (params: any) => {
setValue('text', params.text || '')
@@ -142,22 +134,6 @@ const CustomVoiceForm = forwardRef<CustomVoiceFormHandle>((_props, ref) => {
return (
<form onSubmit={handleSubmit(onSubmit)} className="space-y-2">
<div className="space-y-0.5">
<Label></Label>
<Select
value={watch('backend')}
onValueChange={(value: string) => setValue('backend', value)}
>
<SelectTrigger>
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="local"></SelectItem>
<SelectItem value="aliyun"> API</SelectItem>
</SelectContent>
</Select>
</div>
<div className="space-y-0.5">
<IconLabel icon={Globe2} tooltip="语言" required />
<Select

View File

@@ -38,7 +38,6 @@ const formSchema = z.object({
top_k: z.number().min(1).max(100).optional(),
top_p: z.number().min(0).max(1).optional(),
repetition_penalty: z.number().min(0).max(2).optional(),
backend: z.string().optional(),
})
type FormData = z.infer<typeof formSchema>
@@ -78,16 +77,9 @@ function VoiceCloneForm() {
top_k: 20,
top_p: 0.7,
repetition_penalty: 1.05,
backend: preferences?.default_backend || 'local',
} as Partial<FormData>,
})
useEffect(() => {
if (preferences?.default_backend) {
setValue('backend', preferences.default_backend)
}
}, [preferences?.default_backend, setValue])
useEffect(() => {
const fetchData = async () => {
try {
@@ -243,22 +235,6 @@ function VoiceCloneForm() {
<div className={step === 2 ? 'block space-y-4' : 'hidden'}>
{/* Step 2: Synthesis Options */}
<div className="space-y-0.5">
<Label></Label>
<Select
value={watch('backend')}
onValueChange={(value: string) => setValue('backend', value)}
>
<SelectTrigger>
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="local"></SelectItem>
<SelectItem value="aliyun"> API</SelectItem>
</SelectContent>
</Select>
</div>
<div className="space-y-0.5">
<IconLabel icon={Globe2} tooltip="语言(可选)" />
<Select

View File

@@ -32,7 +32,6 @@ const formSchema = z.object({
top_k: z.number().min(1).max(100).optional(),
top_p: z.number().min(0).max(1).optional(),
repetition_penalty: z.number().min(0).max(2).optional(),
backend: z.string().optional(),
})
type FormData = z.infer<typeof formSchema>
@@ -74,16 +73,9 @@ const VoiceDesignForm = forwardRef<VoiceDesignFormHandle>((_props, ref) => {
top_k: 20,
top_p: 0.7,
repetition_penalty: 1.05,
backend: preferences?.default_backend || 'local',
},
})
useEffect(() => {
if (preferences?.default_backend) {
setValue('backend', preferences.default_backend)
}
}, [preferences?.default_backend, setValue])
useImperativeHandle(ref, () => ({
loadParams: (params: any) => {
setValue('text', params.text || '')
@@ -94,7 +86,6 @@ const VoiceDesignForm = forwardRef<VoiceDesignFormHandle>((_props, ref) => {
setValue('top_k', params.top_k || 20)
setValue('top_p', params.top_p || 0.7)
setValue('repetition_penalty', params.repetition_penalty || 1.05)
setValue('backend', params.backend || 'local')
}
}))
@@ -133,22 +124,6 @@ const VoiceDesignForm = forwardRef<VoiceDesignFormHandle>((_props, ref) => {
return (
<form onSubmit={handleSubmit(onSubmit)} className="space-y-2">
<div className="space-y-0.5">
<Label></Label>
<Select
value={watch('backend')}
onValueChange={(value: string) => setValue('backend', value)}
>
<SelectTrigger>
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="local"></SelectItem>
<SelectItem value="aliyun"> API</SelectItem>
</SelectContent>
</Select>
</div>
<div className="space-y-0.5">
<IconLabel icon={Globe2} tooltip="语言" required />
<Select

View File

@@ -0,0 +1,27 @@
import * as React from "react"
import * as SwitchPrimitives from "@radix-ui/react-switch"
import { cn } from "@/lib/utils"
const Switch = React.forwardRef<
React.ElementRef<typeof SwitchPrimitives.Root>,
React.ComponentPropsWithoutRef<typeof SwitchPrimitives.Root>
>(({ className, ...props }, ref) => (
<SwitchPrimitives.Root
className={cn(
"peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",
className
)}
{...props}
ref={ref}
>
<SwitchPrimitives.Thumb
className={cn(
"pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0"
)}
/>
</SwitchPrimitives.Root>
))
Switch.displayName = SwitchPrimitives.Root.displayName
export { Switch }