diff --git a/entry/src/main/ets/common/utils/booksUtils.ets b/entry/src/main/ets/common/utils/booksUtils.ets index d6329a61..798a952e 100644 --- a/entry/src/main/ets/common/utils/booksUtils.ets +++ b/entry/src/main/ets/common/utils/booksUtils.ets @@ -7,9 +7,13 @@ import BooksDao from '../../database/dao/BooksDao' import { Books } from '../../database/entities/Books' class booksUtils{ - addBooks(books: Books){ + async addBooks(books: Books){ BooksDao.insert(books) } + + async delBooksById(id:number){ + BooksDao.deleteBook(id) + } } let booksUtil = new booksUtils(); export default booksUtil as booksUtils; \ No newline at end of file diff --git a/entry/src/main/ets/database/dao/BooksDao.ets b/entry/src/main/ets/database/dao/BooksDao.ets index 7c5e2a03..0b3691fc 100644 --- a/entry/src/main/ets/database/dao/BooksDao.ets +++ b/entry/src/main/ets/database/dao/BooksDao.ets @@ -137,10 +137,10 @@ class BooksDao { } //删除订阅源历史记录 - async deleteBook(bookId: number) { + async deleteBook(id: number) { try { const predicates = DbUtil.getPredicates(this.TABLE_NAME); - predicates.equalTo('bookId', bookId) + predicates.equalTo('id', id) await DbUtil.delete(predicates) return true } catch (err) { diff --git a/entry/src/main/ets/pages/view/bookShelf/IndexShelf.ets b/entry/src/main/ets/pages/view/bookShelf/IndexShelf.ets index 12810f5d..aea7bf58 100644 --- a/entry/src/main/ets/pages/view/bookShelf/IndexShelf.ets +++ b/entry/src/main/ets/pages/view/bookShelf/IndexShelf.ets @@ -235,8 +235,9 @@ export default struct IndexShelf { }) FileHandler.CopyFile(filePath,this.currentIndex) this.isShowImport = false - sleep(500) - this.isBookRefreshing++ + setTimeout(()=>{ + this.isBookRefreshing++ + },500) break case 1: // 云盘导入 diff --git a/entry/src/main/ets/pages/view/bookShelf/components/BookContentRefresh.ets b/entry/src/main/ets/pages/view/bookShelf/components/BookContentRefresh.ets index 1b34b8e4..cf4b1db8 100644 --- a/entry/src/main/ets/pages/view/bookShelf/components/BookContentRefresh.ets +++ b/entry/src/main/ets/pages/view/bookShelf/components/BookContentRefresh.ets @@ -40,6 +40,7 @@ export default struct BookContentRefresh { BookContent({ currentIndex:this.currentIndex, bookType:this.bookType, + EXHIBIT: this.EXHIBIT }) } else { BookFolder({ diff --git a/entry/src/main/ets/pages/view/bookShelf/components/BookInfoGrids.ets b/entry/src/main/ets/pages/view/bookShelf/components/BookInfoGrids.ets index 783218f8..e831e19c 100644 --- a/entry/src/main/ets/pages/view/bookShelf/components/BookInfoGrids.ets +++ b/entry/src/main/ets/pages/view/bookShelf/components/BookInfoGrids.ets @@ -116,7 +116,6 @@ export default struct BookInfoGrids{ bookInfoDialog: CustomDialogController | null = new CustomDialogController({ builder: BookInfoDialogs({ bookData:this.book, - onDelete:this.onDelete, cancel: () => { this.exitDialog() } diff --git a/entry/src/main/ets/pages/view/bookShelf/components/BookInfos.ets b/entry/src/main/ets/pages/view/bookShelf/components/BookInfos.ets index 08256625..4090e6d8 100644 --- a/entry/src/main/ets/pages/view/bookShelf/components/BookInfos.ets +++ b/entry/src/main/ets/pages/view/bookShelf/components/BookInfos.ets @@ -16,10 +16,6 @@ export default struct BookInfos{ @Prop book:Books @State delCache:boolean = false - - onDelete: () => void = () => { - - } build() { Flex( @@ -124,7 +120,6 @@ export default struct BookInfos{ bookInfoDialog: CustomDialogController | null = new CustomDialogController({ builder: BookInfoDialogs({ bookData:this.book, - onDelete:this.onDelete, cancel: () => { this.exitDialog() } @@ -149,7 +144,6 @@ export default struct BookInfos{ delCache:this.delCache, isShowCache:true }), - cancel: this.exitApp, autoCancel: true, alignment: DialogAlignment.Center, // offset: { dx: 0, dy: '-40%' }, @@ -163,10 +157,8 @@ export default struct BookInfos{ } onAccept() { - this.onDelete() - } - exitApp() { - console.info('点外围取消') } + + } \ No newline at end of file diff --git a/entry/src/main/ets/pages/view/bookShelf/components/dialog/BookInfoDialogs.ets b/entry/src/main/ets/pages/view/bookShelf/components/dialog/BookInfoDialogs.ets index dcb00a30..4353552f 100644 --- a/entry/src/main/ets/pages/view/bookShelf/components/dialog/BookInfoDialogs.ets +++ b/entry/src/main/ets/pages/view/bookShelf/components/dialog/BookInfoDialogs.ets @@ -4,6 +4,8 @@ import { router } from '@kit.ArkUI' import InsideCircleIcon from '../../../../../componets/common/InsideCircleIcon' import { showMessage } from '../../../../../componets/common/promptShow' import confirmDialogExample from '../../../../../componets/common/confirmDialog' +import { sleep } from '../../../../../common/utils/utils' +import booksUtil from '../../../../../common/utils/booksUtils' @CustomDialog /** @@ -24,10 +26,6 @@ export default struct BookInfoDialogs{ cancel: () => void = () => { } - onDelete: () => void = () => { - - } - build() { Column(){ Flex({ @@ -54,14 +52,9 @@ export default struct BookInfoDialogs{ } .onClick(()=>{ router.pushUrl({ url: 'pages/view/BookDetailPage', - params: { - bookId: '1', - bookName: '大奉打更人', - bookAuthor: '卖报小郎君', - bookImage: $r('app.media.cover_list'), - bookDescribe: '《大奉打更人》(第一卷)实体书已在天猫、当当、京东等全平台,以及各个实体书店发售。 这个世界,有儒;有道;有佛;有妖;有术士。 警校毕业的许七安幽幽醒来,发现自己身处牢狱之中,三日后流放边陲..... ' - } + params: this.bookData }) + this.controller?.close() }) }.padding(20) Divider().strokeWidth(0.5).padding({bottom:16}) @@ -104,7 +97,7 @@ export default struct BookInfoDialogs{ case 3 : showMessage('加入书单'); break; case 4 : - showMessage('删除'); this.bookDelDialog?.open(); break; + this.bookDelDialog?.open(); break; } } @@ -132,11 +125,21 @@ export default struct BookInfoDialogs{ }) deleteGroup() { - this.onDelete() + this.deleteBook() this.cancel() } exitApp() { this.bookDelDialog?.close() } + @StorageLink('BOOK_IS_BOOK_REFRESHING') isBookRefreshing: number = 0 + + async deleteBook(){ + booksUtil.delBooksById(this.bookData.id || 0) + setTimeout(()=>{ + this.isBookRefreshing++ + },500) + showMessage('删除成功') + } + } \ No newline at end of file