@@ -29,19 +29,9 @@ async function goPage(f: (currentIndex: number) => number) {
29
29
if ( isRefreshing ) return
30
30
31
31
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 } )
45
35
}
46
36
47
37
function isPageIndexInRange ( pageIndex : number , state : PostListState ) {
@@ -65,7 +55,7 @@ function updatePostListViewTitle() {
65
55
export namespace PostListView {
66
56
import calcPageCount = PageList . calcPageCount
67
57
68
- export async function refresh ( { queue = false } = { } ) : Promise < boolean > {
58
+ export async function refresh ( { queue = false , pageIndex = 1 } = { } ) : Promise < boolean > {
69
59
if ( isRefreshing && ! queue ) {
70
60
await refreshTask
71
61
return false
@@ -76,10 +66,9 @@ export namespace PostListView {
76
66
77
67
const fut = async ( ) => {
78
68
await setRefreshing ( true )
79
- const page = await postDataProvider . loadPosts ( )
69
+ const page = await postDataProvider . loadPosts ( pageIndex )
80
70
const postCount = await PostService . getCount ( )
81
71
const pageCount = calcPageCount ( page . cap , postCount )
82
- const pageIndex = page . index
83
72
const hasPrev = PageList . hasPrev ( pageIndex )
84
73
const hasNext = PageList . hasNext ( pageIndex , pageCount )
85
74
@@ -113,7 +102,7 @@ export namespace PostListView {
113
102
if ( isNaN ( n ) || n === 0 ) return '请输入正确格式的页码'
114
103
115
104
const state = getListState ( )
116
- if ( state === undefined ) return '博文列表尚未加载'
105
+ if ( state === undefined ) return undefined
117
106
118
107
if ( isPageIndexInRange ( n , state ) ) return undefined
119
108
0 commit comments