@@ -19,7 +19,8 @@ class _AppVersionPageState extends State<AppVersionPage> {
1919bool _isLoading= false ;
2020bool _hasMore= true ;
2121int _currentPage= 0 ;
22- final int _pageSize= 5 ;
22+ int _totalPages= 1 ;
23+ final int _pageSize= 3 ;
2324
2425@override
2526void initState () {
@@ -44,15 +45,21 @@ class _AppVersionPageState extends State<AppVersionPage> {
4445 );
4546
4647if (response['code' ]== 200 && response['data' ]!= null ) {
47- final List <dynamic > versionData= response['data' ]['versions' ]?? [];
48+ final data= response['data' ];
49+ final List <dynamic > versionData= data['versions' ]?? [];
4850final List <Version > newVersions= versionData
4951 .map <Version >((item)=> Version .fromJson (item))
5052 .toList ();
5153
54+ // 从响应中获取分页信息
55+ _totalPages= data['totalPages' ]?? 1 ;
56+ final int currentPage= (data['currentPage' ]?? 0 )+ 1 ;// 后端从0开始,前端从1开始
57+ final int totalElements= data['totalElements' ]?? 0 ;
58+
5259setState (() {
5360 _versions= newVersions;
54- _currentPage= page ;
55- _hasMore= newVersions.length == _pageSize ;
61+ _currentPage= currentPage ;
62+ _hasMore= currentPage < _totalPages ;
5663 });
5764 }else {
5865Get .snackbar (
@@ -181,25 +188,34 @@ class _AppVersionPageState extends State<AppVersionPage> {
181188 icon: const Icon (Icons .arrow_back),
182189 label: Text ('previous_page' .tr),
183190 style: ElevatedButton .styleFrom (
184- backgroundColor: _currentPage> 1 ? Colors .blue: Colors .grey,
191+ backgroundColor: _currentPage> 1
192+ ? Colors .blue
193+ : Colors .grey,
185194 ),
186195 ),
187196
188197// 页码显示
189- Container (
190- padding: const EdgeInsets .symmetric (horizontal: 16 , vertical: 8 ),
191- decoration: BoxDecoration (
192- color: Colors .blue.withOpacity (0.1 ),
193- borderRadius: BorderRadius .circular (8 ),
194- ),
195- child: Text (
196- '${'page' .tr } $_currentPage ' ,
197- style: const TextStyle (
198- fontSize: 16 ,
199- fontWeight: FontWeight .bold,
200- color: Colors .blue,
198+ Column (
199+ children: [
200+ Container (
201+ padding: const EdgeInsets .symmetric (
202+ horizontal: 16 ,
203+ vertical: 8 ,
204+ ),
205+ decoration: BoxDecoration (
206+ color: Colors .blue.withOpacity (0.1 ),
207+ borderRadius: BorderRadius .circular (8 ),
208+ ),
209+ child: Text (
210+ '$_currentPage / $_totalPages ' ,
211+ style: const TextStyle (
212+ fontSize: 16 ,
213+ fontWeight: FontWeight .bold,
214+ color: Colors .blue,
215+ ),
216+ ),
201217 ),
202- ) ,
218+ ] ,
203219 ),
204220
205221// 下一页按钮