55 Card ,
66 DatePicker ,
77 Form ,
8+ Grid ,
89 Input ,
910 Modal ,
1011 message ,
@@ -14,6 +15,7 @@ import {
1415 Table ,
1516 Typography ,
1617} from 'antd' ;
18+ import type { ColumnsType } from 'antd/es/table' ;
1719import dayjs from 'dayjs' ;
1820import { useEffect , useRef , useState } from 'react' ;
1921import {
@@ -45,9 +47,11 @@ const defaultPremiumQuotaText = JSON.stringify(quotas.premium, null, 2);
4547
4648// JSON Editor wrapper component for quota editing
4749const JsonEditorWrapper = ( {
50+ height = 200 ,
4851 value,
4952 onChange,
5053} : {
54+ height ?: number ;
5155 value : string ;
5256 onChange : ( value : string ) => void ;
5357} ) => {
@@ -95,11 +99,13 @@ const JsonEditorWrapper = ({
9599 }
96100 } , [ value ] ) ;
97101
98- return < div ref = { containerRef } style = { { height : 200 } } /> ;
102+ return < div ref = { containerRef } style = { { height } } /> ;
99103} ;
100104
101105export const Component = ( ) => {
102106 const queryClient = useQueryClient ( ) ;
107+ const screens = Grid . useBreakpoint ( ) ;
108+ const isMobile = ! screens . md ;
103109 const [ searchKeyword , setSearchKeyword ] = useState ( '' ) ;
104110 const [ debouncedSearch , setDebouncedSearch ] = useState ( '' ) ;
105111 const [ isModalOpen , setIsModalOpen ] = useState ( false ) ;
@@ -181,11 +187,12 @@ export const Component = () => {
181187 }
182188 } ;
183189
184- const columns = [
190+ const columns : ColumnsType < AdminUser > = [
185191 {
186192 title : 'ID' ,
187193 dataIndex : 'id' ,
188194 key : 'id' ,
195+ responsive : [ 'md' ] ,
189196 width : 80 ,
190197 } ,
191198 {
@@ -202,6 +209,7 @@ export const Component = () => {
202209 title : '状态' ,
203210 dataIndex : 'status' ,
204211 key : 'status' ,
212+ responsive : [ 'sm' ] ,
205213 width : 100 ,
206214 render : ( status : string ) => (
207215 < span
@@ -215,13 +223,15 @@ export const Component = () => {
215223 title : '套餐' ,
216224 dataIndex : 'tier' ,
217225 key : 'tier' ,
226+ responsive : [ 'sm' ] ,
218227 width : 120 ,
219228 render : ( tier : string ) => tierLabelMap . get ( tier ) || tier || '-' ,
220229 } ,
221230 {
222231 title : '套餐过期时间' ,
223232 dataIndex : 'tierExpiresAt' ,
224233 key : 'tierExpiresAt' ,
234+ responsive : [ 'lg' ] ,
225235 width : 180 ,
226236 render : ( date : string | null ) =>
227237 date ? dayjs ( date ) . format ( 'YYYY-MM-DD HH:mm' ) : '-' ,
@@ -230,6 +240,7 @@ export const Component = () => {
230240 title : '自定义配额' ,
231241 dataIndex : 'quota' ,
232242 key : 'quota' ,
243+ responsive : [ 'md' ] ,
233244 width : 100 ,
234245 render : ( quota : Quota | null ) => ( quota ? '有' : '-' ) ,
235246 } ,
@@ -271,15 +282,21 @@ export const Component = () => {
271282 dataSource = { data ?. data || [ ] }
272283 columns = { columns }
273284 rowKey = "id"
274- pagination = { { pageSize : 20 } }
275- scroll = { { x : 900 } }
285+ size = { isMobile ? 'small' : 'middle' }
286+ pagination = {
287+ isMobile
288+ ? { pageSize : 10 , simple : true }
289+ : { pageSize : 20 , showSizeChanger : true }
290+ }
291+ scroll = { { x : 760 } }
276292 />
277293 </ Spin >
278294 </ Card >
279295
280296 < Modal
281297 title = { `编辑用户: ${ editingUser ?. email } ` }
282298 open = { isModalOpen }
299+ width = { isMobile ? 'calc(100vw - 32px)' : 600 }
283300 onCancel = { ( ) => setIsModalOpen ( false ) }
284301 footer = { [
285302 < Button key = "cancel" onClick = { ( ) => setIsModalOpen ( false ) } >
@@ -294,7 +311,6 @@ export const Component = () => {
294311 保存
295312 </ Button > ,
296313 ] }
297- width = { 600 }
298314 >
299315 < Form form = { form } layout = "vertical" className = "mt-4" >
300316 < Space className = "w-full" direction = "vertical" size = "middle" >
@@ -330,7 +346,11 @@ export const Component = () => {
330346 label = "自定义配额 (JSON,留空则使用默认配额)"
331347 className = "mb-0!"
332348 >
333- < JsonEditorWrapper value = { quotaValue } onChange = { setQuotaValue } />
349+ < JsonEditorWrapper
350+ height = { isMobile ? 180 : 200 }
351+ value = { quotaValue }
352+ onChange = { setQuotaValue }
353+ />
334354 </ Form . Item >
335355 </ Space >
336356 </ Form >
0 commit comments