@@ -44,6 +44,7 @@ const tierLabelMap = new Map(
4444 tierOptions . map ( ( option ) => [ option . value , option . label ] ) ,
4545) ;
4646const defaultPremiumQuotaText = JSON . stringify ( quotas . premium , null , 2 ) ;
47+ const expiryShortcutDays = [ 7 , 30 , 365 ] as const ;
4748
4849// JSON Editor wrapper component for quota editing
4950const JsonEditorWrapper = ( {
@@ -187,6 +188,23 @@ export const Component = () => {
187188 }
188189 } ;
189190
191+ const handleExtendTierExpiry = (
192+ days : ( typeof expiryShortcutDays ) [ number ] ,
193+ ) => {
194+ const currentValue = form . getFieldValue ( 'tierExpiresAt' ) ;
195+ const currentExpiry = currentValue ? dayjs ( currentValue ) : null ;
196+ const baseDate = currentExpiry ?. isValid ( ) ? currentExpiry : dayjs ( ) ;
197+
198+ form . setFieldValue ( 'tierExpiresAt' , baseDate . add ( days , 'day' ) ) ;
199+ } ;
200+
201+ const handleResetTierExpiry = ( ) => {
202+ form . setFieldValue (
203+ 'tierExpiresAt' ,
204+ editingUser ?. tierExpiresAt ? dayjs ( editingUser . tierExpiresAt ) : null ,
205+ ) ;
206+ } ;
207+
190208 const columns : ColumnsType < AdminUser > = [
191209 {
192210 title : 'ID' ,
@@ -335,12 +353,26 @@ export const Component = () => {
335353 ] }
336354 />
337355 </ Form . Item >
338- < Form . Item
339- name = "tierExpiresAt"
340- label = "套餐过期时间"
341- className = "mb-0!"
342- >
343- < DatePicker showTime className = "w-full" />
356+ < Form . Item label = "套餐过期时间" className = "mb-0!" >
357+ < Space direction = "vertical" size = "small" className = "w-full" >
358+ < Form . Item name = "tierExpiresAt" noStyle >
359+ < DatePicker showTime className = "w-full" />
360+ </ Form . Item >
361+ < Space wrap size = { [ 8 , 8 ] } >
362+ { expiryShortcutDays . map ( ( days ) => (
363+ < Button
364+ key = { days }
365+ size = "small"
366+ onClick = { ( ) => handleExtendTierExpiry ( days ) }
367+ >
368+ +{ days } 天
369+ </ Button >
370+ ) ) }
371+ < Button size = "small" onClick = { handleResetTierExpiry } >
372+ 重置
373+ </ Button >
374+ </ Space >
375+ </ Space >
344376 </ Form . Item >
345377 < Form . Item
346378 label = "自定义配额 (JSON,留空则使用默认配额)"
0 commit comments