Skip to content

Commit

Permalink
Merge pull request #226 from mgz0227/dev_2008
Browse files Browse the repository at this point in the history
长按书架书籍弹窗删除功能
  • Loading branch information
MaoXiaoone authored Jul 23, 2024
2 parents dabb71b + dd34f6b commit 6f51343
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 29 deletions.
6 changes: 5 additions & 1 deletion entry/src/main/ets/common/utils/booksUtils.ets
Original file line number Diff line number Diff line change
Expand Up @@ -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;
4 changes: 2 additions & 2 deletions entry/src/main/ets/database/dao/BooksDao.ets
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 3 additions & 2 deletions entry/src/main/ets/pages/view/bookShelf/IndexShelf.ets
Original file line number Diff line number Diff line change
Expand Up @@ -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:
// 云盘导入
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export default struct BookContentRefresh {
BookContent({
currentIndex:this.currentIndex,
bookType:this.bookType,
EXHIBIT: this.EXHIBIT
})
} else {
BookFolder({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ export default struct BookInfoGrids{
bookInfoDialog: CustomDialogController | null = new CustomDialogController({
builder: BookInfoDialogs({
bookData:this.book,
onDelete:this.onDelete,
cancel: () => {
this.exitDialog()
}
Expand Down
12 changes: 2 additions & 10 deletions entry/src/main/ets/pages/view/bookShelf/components/BookInfos.ets
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ export default struct BookInfos{
@Prop book:Books

@State delCache:boolean = false

onDelete: () => void = () => {

}
build() {

Flex(
Expand Down Expand Up @@ -124,7 +120,6 @@ export default struct BookInfos{
bookInfoDialog: CustomDialogController | null = new CustomDialogController({
builder: BookInfoDialogs({
bookData:this.book,
onDelete:this.onDelete,
cancel: () => {
this.exitDialog()
}
Expand All @@ -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%' },
Expand All @@ -163,10 +157,8 @@ export default struct BookInfos{
}

onAccept() {
this.onDelete()
}

exitApp() {
console.info('点外围取消')
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -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
/**
Expand All @@ -24,10 +26,6 @@ export default struct BookInfoDialogs{
cancel: () => void = () => {
}

onDelete: () => void = () => {

}

build() {
Column(){
Flex({
Expand All @@ -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})
Expand Down Expand Up @@ -104,7 +97,7 @@ export default struct BookInfoDialogs{
case 3 :
showMessage('加入书单'); break;
case 4 :
showMessage('删除'); this.bookDelDialog?.open(); break;
this.bookDelDialog?.open(); break;
}
}

Expand Down Expand Up @@ -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('删除成功')
}

}

0 comments on commit 6f51343

Please sign in to comment.