@@ -29,19 +29,9 @@ async function goPage(f: (currentIndex: number) => number) {
2929 if ( isRefreshing ) return
3030
3131 const state = getListState ( )
32- if ( state === undefined ) {
33- void Alert . warn ( '操作失败: 状态错误' )
34- return
35- }
36-
37- const index = f ( state . pageIndex )
38- if ( ! isPageIndexInRange ( index , state ) ) {
39- void Alert . warn ( `操作失败: 已达到最大页数` )
40- return
41- }
42-
43- await updatePostListState ( index , state . pageCap , state . pageItemCount , state . pageCount )
44- await PostListView . refresh ( )
32+ let pageIndex = state ?. pageIndex ?? 1
33+ pageIndex = f ( pageIndex )
34+ await PostListView . refresh ( { pageIndex : pageIndex } )
4535}
4636
4737function isPageIndexInRange ( pageIndex : number , state : PostListState ) {
@@ -65,7 +55,7 @@ function updatePostListViewTitle() {
6555export namespace PostListView {
6656 import calcPageCount = PageList . calcPageCount
6757
68- export async function refresh ( { queue = false } = { } ) : Promise < boolean > {
58+ export async function refresh ( { queue = false , pageIndex = 1 } = { } ) : Promise < boolean > {
6959 if ( isRefreshing && ! queue ) {
7060 await refreshTask
7161 return false
@@ -76,10 +66,9 @@ export namespace PostListView {
7666
7767 const fut = async ( ) => {
7868 await setRefreshing ( true )
79- const page = await postDataProvider . loadPosts ( )
69+ const page = await postDataProvider . loadPosts ( pageIndex )
8070 const postCount = await PostService . getCount ( )
8171 const pageCount = calcPageCount ( page . cap , postCount )
82- const pageIndex = page . index
8372 const hasPrev = PageList . hasPrev ( pageIndex )
8473 const hasNext = PageList . hasNext ( pageIndex , pageCount )
8574
@@ -113,7 +102,7 @@ export namespace PostListView {
113102 if ( isNaN ( n ) || n === 0 ) return '请输入正确格式的页码'
114103
115104 const state = getListState ( )
116- if ( state === undefined ) return '博文列表尚未加载'
105+ if ( state === undefined ) return undefined
117106
118107 if ( isPageIndexInRange ( n , state ) ) return undefined
119108
0 commit comments