@@ -5,13 +5,12 @@ import { Card, CardContent } from "@/components/ui/card";
55import { Input } from "@/components/ui/input" ;
66import { OptionCombobox } from "@/components/ui/option-combobox" ;
77import { WorkspaceField } from "@/components/layout/workspace-ui" ;
8- import { Switch } from "@/components/ui/switch" ;
9- import { Label } from "@/components/ui/label" ;
108import { MailPlus } from "lucide-react" ;
119import { mailboxLocalPartSchema } from "@/lib/schemas" ;
1210import type { DomainOption } from "../api" ;
1311
1412const ttlOptions = [
13+ { label : "永久" , value : "permanent" , keywords : [ "permanent" , "forever" , "永久" , "不过期" ] } ,
1514 { label : "24 小时" , value : "24" , keywords : [ "1 day" , "24" ] } ,
1615 { label : "72 小时" , value : "72" , keywords : [ "3 days" , "72" ] } ,
1716 { label : "168 小时" , value : "168" , keywords : [ "7 days" , "168" ] } ,
@@ -111,13 +110,19 @@ export function MailboxCreateForm({
111110 < WorkspaceField label = "有效期" >
112111 < OptionCombobox
113112 ariaLabel = "邮箱有效期"
114- disabled = { permanent }
115113 emptyLabel = "没有匹配的有效期"
116- onValueChange = { ( value ) => onTtlHoursChange ( Number ( value ) ) }
114+ onValueChange = { ( value ) => {
115+ if ( value === "permanent" ) {
116+ onPermanentChange ( true ) ;
117+ } else {
118+ onPermanentChange ( false ) ;
119+ onTtlHoursChange ( Number ( value ) ) ;
120+ }
121+ } }
117122 options = { ttlOptions }
118- placeholder = { permanent ? "永久" : " 选择有效期"}
123+ placeholder = " 选择有效期"
119124 searchPlaceholder = "搜索有效期"
120- value = { permanent ? "" : String ( ttlHours ) }
125+ value = { permanent ? "permanent " : String ( ttlHours ) }
121126 />
122127 </ WorkspaceField >
123128
@@ -145,27 +150,14 @@ export function MailboxCreateForm({
145150 </ div >
146151 </ div >
147152
148- < div className = "flex items-center gap-4" >
149- < div className = "flex-1" >
150- < WorkspaceField label = "邮箱前缀" >
151- < Input
152- onChange = { ( event ) => handleLocalPartChange ( event . target . value ) }
153- placeholder = "留空则自动生成"
154- value = { localPart }
155- />
156- { localPartError ? < p className = "text-xs text-destructive" > { localPartError } </ p > : null }
157- </ WorkspaceField >
158- </ div >
159-
160- < div className = "flex items-center gap-2 pt-5" >
161- < Switch
162- checked = { permanent }
163- id = "permanent-switch"
164- onCheckedChange = { onPermanentChange }
165- />
166- < Label htmlFor = "permanent-switch" className = "text-sm whitespace-nowrap" > 永久邮箱</ Label >
167- </ div >
168- </ div >
153+ < WorkspaceField label = "邮箱前缀" >
154+ < Input
155+ onChange = { ( event ) => handleLocalPartChange ( event . target . value ) }
156+ placeholder = "留空则自动生成"
157+ value = { localPart }
158+ />
159+ { localPartError ? < p className = "text-xs text-destructive" > { localPartError } </ p > : null }
160+ </ WorkspaceField >
169161
170162 { feedback ? < div className = "text-xs text-muted-foreground" > { feedback } </ div > : null }
171163 </ CardContent >
0 commit comments