Skip to content

Commit

Permalink
Merge pull request #257 from mgz0227/dev_2008
Browse files Browse the repository at this point in the history
书籍页面居中
  • Loading branch information
MaoXiaoone authored Aug 12, 2024
2 parents 0381319 + b0739d0 commit 9923c0d
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions entry/src/main/ets/pages/view/bookShelf/components/BookContent.ets
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ export default struct BookContent {
@Provide('booksDataSource') booksDataSource: BasicDataSource<Books> = new BasicDataSource<Books>()

async aboutToAppear(): Promise<void> {
this.getBookCount()
if (this.booksDataSource.totalCount() === 0) {
this.getBookList()
}
}

async getBookCount(){
this.bookCount = await booksDao.getBookCount({
type:this.currentIndex,
bookGroup:this.bookTypeNumber,
})
if (this.booksDataSource.totalCount() === 0) {
this.getBookList()
}
}
@State bookCount:number = 0
@Prop EXHIBIT:string
Expand All @@ -39,6 +43,9 @@ export default struct BookContent {
changeBookType(){
this.currentPage = 1
if (this.bookTypeNumber !== 1 && this.bookTypeNumber !== 5) {
if (this.bookCount === 0){
this.getBookCount()
}
if (this.booksDataSource.totalCount() > 0) {
this.booksDataSource.clear()
}
Expand Down Expand Up @@ -112,6 +119,7 @@ export default struct BookContent {
}
})
}
.alignListItem(ListItemAlign.Center)
.layoutWeight(1)
.lanes(this.EXHIBIT === '宫格' ? 3 : 1)
.scrollBar(BarState.Off)
Expand Down

0 comments on commit 9923c0d

Please sign in to comment.