From f023040ea257e1699de1228f3b99bd59388215db Mon Sep 17 00:00:00 2001 From: 2008 <59199830@qq.com> Date: Fri, 26 Jul 2024 17:03:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B9=A6=E6=9E=B6=E5=88=86=E7=BB=84db=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E6=98=BE=E7=A4=BA=EF=BC=8C=E7=AE=A1=E7=90=86=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E8=B7=B3=E8=BD=AC=E5=88=86=E7=BB=84=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 书架分组db操作显示,管理页面跳转分组操作功能实现 --- .../main/ets/common/utils/bookGroupUtils.ets | 66 ++++ .../ets/componets/bookDetail/BookOverlay.ets | 21 +- .../main/ets/componets/group/GroupType.ets | 1 - .../ets/componets/group/groupTypePanel.ets | 12 +- .../main/ets/database/AppDatabase/index.ets | 20 +- .../main/ets/database/dao/BookGroupsDao.ets | 44 +++ entry/src/main/ets/database/dao/BooksDao.ets | 32 ++ .../main/ets/database/entities/BookGroups.ets | 4 + .../ets/pages/view/bookShelf/BookFolder.ets | 103 +++--- .../ets/pages/view/bookShelf/IndexShelf.ets | 11 +- .../view/bookShelf/Manage/BookManagePage.ets | 305 +++++++++++------- .../bookManage/BookFolderGridManage.ets | 75 +++-- .../bookManage/BookFolderInfoManage.ets | 44 ++- .../Manage/bookManage/BookFolderManages.ets | 40 +-- .../Manage/bookManage/BookInfoGridManage.ets | 2 + .../Manage/bookManage/bookListManage.ets | 27 -- .../bookShelf/components/BookBodyContent.ets | 3 - .../components/BookContentRefresh.ets | 8 +- .../components/dialog/BookInfoDialogs.ets | 2 +- .../dialog/BookSelectGroupDialog.ets | 20 +- .../ets/pages/view/coverInfoImageShow.ets | 4 +- .../pages/view/dialog/FolderInfoDialog.ets | 27 +- .../ets/pages/view/dialog/coverInfoDialog.ets | 9 +- 23 files changed, 553 insertions(+), 327 deletions(-) create mode 100644 entry/src/main/ets/common/utils/bookGroupUtils.ets diff --git a/entry/src/main/ets/common/utils/bookGroupUtils.ets b/entry/src/main/ets/common/utils/bookGroupUtils.ets new file mode 100644 index 00000000..47119bff --- /dev/null +++ b/entry/src/main/ets/common/utils/bookGroupUtils.ets @@ -0,0 +1,66 @@ +/** + * @author 2008 + * @datetime 2024/7/26 10:58 + * @className: booksUtils + */ +import BookGroupsDao from '../../database/dao/BookGroupsDao' +import BooksDao from '../../database/dao/BooksDao' +import { BookGroups } from '../../database/entities/BookGroups' + +class bookGroupUtils{ + + async isTopGroup(id: number, isTop?: boolean): Promise { + return BookGroupsDao.isUpdateGroupTop(id, isTop) + } + + async addGroup(books: BookGroups){ + BookGroupsDao.insert(books) + } + // + // async updateBookGroup(id:number|number[], group:number){ + // //循环更新 + // let booId:number[] = [] + // if (typeof id === 'number'){ + // booId.push(id) + // } else { + // booId = id + // } + // booId.forEach((item:number)=>{ + // BooksDao.updateBookGroup(item,group) + // }) + // } + + async delGroupById(id:number){ + //删除分组 + BookGroupsDao.deleteBook(id) + //同时更新书籍分组为未分组 + BooksDao.queryBookByGroup(id, 3) + } + + async moveBookByGroupId(oldGroup:number|number[], newGroup:number){ + //同时更新书籍分组为未分组 + let Ids:number[] = [] + if (typeof oldGroup === 'number'){ + Ids.push(oldGroup) + } else { + Ids = oldGroup + } + Ids.forEach((item:number)=>{ + BooksDao.queryBookByGroup(item, newGroup) + }) + } + + async updateGroupShow(groupId:number|number[]){ + let Ids:number[] = [] + if (typeof groupId === 'number'){ + Ids.push(groupId) + } else { + Ids = groupId + } + Ids.forEach((item:number)=>{ + BookGroupsDao.updateGroupShow(item) + }) + } +} +let bookGroupUtil = new bookGroupUtils(); +export default bookGroupUtil as bookGroupUtils; \ No newline at end of file diff --git a/entry/src/main/ets/componets/bookDetail/BookOverlay.ets b/entry/src/main/ets/componets/bookDetail/BookOverlay.ets index 85152c11..bd9ee7fe 100644 --- a/entry/src/main/ets/componets/bookDetail/BookOverlay.ets +++ b/entry/src/main/ets/componets/bookDetail/BookOverlay.ets @@ -2,9 +2,7 @@ import CommonConstants from '../../common/constants/CommonConstants' @Component export default struct BookOverlay { - // @Prop bookWidth:number - // @Prop bookHeight:number - @Prop bookImage:Resource + @Prop bookImage:Resource|string @Prop isTop:boolean @Prop isShow:boolean = false build() { @@ -18,19 +16,20 @@ export default struct BookOverlay { .backgroundColor('rgba(0,0,0,0.45)') .width(CommonConstants.NOVEL_IMG_WIDTH).height(CommonConstants.NOVEL_IMG_HEIGHT) } - Flex({ - alignItems: ItemAlign.End, - }){ + + Stack(){ if (this.isTop){ Text('置顶').fontColor(Color.White).fontWeight(300).fontSize(8).padding(3).borderRadius(5) - .backgroundColor('rgba(0, 0, 0, 0.45)') + .backgroundColor('rgba(0, 0, 0, 0.45)').zIndex(1) } + Image(this.bookImage) + .draggable(false) + .alt($r('app.media.icon_book_default_cover_one')) + .width(CommonConstants.NOVEL_IMG_WIDTH) + .height(CommonConstants.NOVEL_IMG_HEIGHT) } - .align(Alignment.Start) - .width(CommonConstants.NOVEL_IMG_WIDTH).height(CommonConstants.NOVEL_IMG_HEIGHT) - .backgroundImage(this.bookImage) - .backgroundImageSize({width:CommonConstants.NOVEL_IMG_WIDTH,height:CommonConstants.NOVEL_IMG_HEIGHT}) .zIndex(2) + .alignContent(Alignment.BottomStart) Row(){ Image($r('app.media.occlusion1')) diff --git a/entry/src/main/ets/componets/group/GroupType.ets b/entry/src/main/ets/componets/group/GroupType.ets index 9feb0c23..ed6af952 100644 --- a/entry/src/main/ets/componets/group/GroupType.ets +++ b/entry/src/main/ets/componets/group/GroupType.ets @@ -11,7 +11,6 @@ export default struct groupTypeComponent { @Link GROUP:string @State groupList:BookGroups[] = [] @Link bookTypeNumber:number - // initGroup:string[] = ['分组','全部','未分组','本地','书单'] @StorageLink('BOOK_IS_BOOK_GROUPS_REFRESHING') @Watch('changeRefresh')BOOK_IS_BOOK_GROUPS_REFRESHING: number = 0 aboutToAppear(): void { this.getGroupList() diff --git a/entry/src/main/ets/componets/group/groupTypePanel.ets b/entry/src/main/ets/componets/group/groupTypePanel.ets index e8825b9b..4b479ad5 100644 --- a/entry/src/main/ets/componets/group/groupTypePanel.ets +++ b/entry/src/main/ets/componets/group/groupTypePanel.ets @@ -145,6 +145,7 @@ export default struct groupTypePanel{ .onAction((event: GestureEvent) => { if (event.repeat) { if (!this.isShow) { + this.dialogGroupData = item // this.group = item this.isShow = true this.changeNumber = 1 @@ -206,8 +207,6 @@ export default struct groupTypePanel{ @State dragIndex: number = 0 changeIndex(index1: number, index2: number,type:number = 2) { // 交换数组位置 - //@State hideGroupType:string[] = ['游戏','玄幻','都市', '历史', '军事', '科幻', '灵异', '二次元', '耽美', '同人'] - //hideGroupType数组位置交换 if (!this.isShowIcon) { showMessage('请在管理状态下拖到改变顺序') return @@ -249,12 +248,12 @@ export default struct groupTypePanel{ } } - @State @Watch('watchFolder')group:folderList = new folderList(0,'',0,$r('app.media.folder_test'),'') @State changeNumber:number = 0 @State isShow:boolean = false + @State dialogGroupData:BookGroups = new BookGroups() groupInfoDialog: CustomDialogController | null = new CustomDialogController({ builder: FolderInfoDialog({ - itemData:this.group, + itemData:this.dialogGroupData, cancel: () => { this.exitDialog() } @@ -273,11 +272,6 @@ export default struct groupTypePanel{ this.groupInfoDialog?.close() } - watchFolder(){ - if (this.changeNumber === 1) { - updateDateGroup(this.group) - } - } @State isShowBookFolderInfoDialog:boolean = false @State folderType:string = '' @Builder bookFolderInfoDialog(){ diff --git a/entry/src/main/ets/database/AppDatabase/index.ets b/entry/src/main/ets/database/AppDatabase/index.ets index 4fb7cb3b..8b65d55d 100644 --- a/entry/src/main/ets/database/AppDatabase/index.ets +++ b/entry/src/main/ets/database/AppDatabase/index.ets @@ -8,7 +8,7 @@ export default { "entities": [ { "tableName": "books", - "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` ( `id` INTEGER NOT NULL, `bookUrl` TEXT, `toUrl` TEXT, `origin` TEXT, `originName` TEXT, `bookName` TEXT NOT NULL, `author` TEXT, `cover` TEXT, `customTag` TEXT, `coverUrl` TEXT, `customCoverUrl` TEXT, `intro` TEXT, `customIntro` TEXT, `charset` TEXT, `bookGroup` INTEGER NOT NULL DEFAULT 0, `latestChapterTitle` TEXT, `latestChapterTime` INTEGER NOT NULL DEFAULT 0, `lastCheckTime` INTEGER NOT NULL DEFAULT 0, `lastCheckCount` INTEGER NOT NULL DEFAULT 0, `totalChapterNum` INTEGER NOT NULL DEFAULT 0, `durChapterTitle` TEXT, `durChapterIndex` INTEGER NOT NULL DEFAULT 0, `durChapterPos` INTEGER NOT NULL DEFAULT 0, `durChapterTime` INTEGER NOT NULL DEFAULT 0, `wordCount` TEXT, `canUpdate` INTEGER NOT NULL DEFAULT 1, `sort` INTEGER NOT NULL DEFAULT 0, `originOrder` INTEGER NOT NULL DEFAULT 0, `syncTime` INTEGER NOT NULL DEFAULT 0, `bookType` INTEGER NOT NULL DEFAULT 0, `isTop` INTEGER NOT NULL DEFAULT 0, `createTime` INTEGER NOT NULL DEFAULT 0,`updateTime` INTEGER NOT NULL DEFAULT 0,`isJoin` INTEGER NOT NULL DEFAULT 1,PRIMARY KEY ( `id` ))", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` ( `id` INTEGER NOT NULL, `bookUrl` TEXT, `toUrl` TEXT, `origin` TEXT, `originName` TEXT, `bookName` TEXT NOT NULL, `author` TEXT, `cover` TEXT, `customTag` TEXT, `coverUrl` TEXT, `customCoverUrl` TEXT, `intro` TEXT, `customIntro` TEXT, `charset` TEXT, `bookGroup` INTEGER NOT NULL DEFAULT 0, `latestChapterTitle` TEXT, `latestChapterTime` INTEGER NOT NULL DEFAULT 0, `lastCheckTime` INTEGER NOT NULL DEFAULT 0, `lastCheckCount` INTEGER NOT NULL DEFAULT 0, `totalChapterNum` INTEGER NOT NULL DEFAULT 0, `durChapterTitle` TEXT, `durChapterIndex` INTEGER NOT NULL DEFAULT 0, `durChapterPos` INTEGER NOT NULL DEFAULT 0, `durChapterTime` INTEGER NOT NULL DEFAULT 0, `wordCount` TEXT, `canUpdate` INTEGER NOT NULL DEFAULT 1, `sort` INTEGER NOT NULL DEFAULT 0, `originOrder` INTEGER NOT NULL DEFAULT 0, `syncTime` INTEGER NOT NULL DEFAULT 0, `bookType` INTEGER NOT NULL DEFAULT 0, `isTop` INTEGER NOT NULL DEFAULT 0, `createTime` INTEGER NOT NULL DEFAULT 0,`updateTime` INTEGER NOT NULL DEFAULT 0,`isJoin` INTEGER NOT NULL DEFAULT 1,isSystem INTEGER NOT NULL DEFAULT 0,PRIMARY KEY ( `id` ))", "fields": [ { "fieldPath": "id", @@ -257,7 +257,7 @@ export default { }, { "tableName": "book_groups", - "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`groupId` INTEGER NOT NULL, `groupName` TEXT NOT NULL, `coverUrl` TEXT, `groupDescribe` TEXT, `sort` INTEGER NOT NULL, `enableRefresh` INTEGER NOT NULL DEFAULT 1, `show` INTEGER NOT NULL DEFAULT 1, `groupType` INTEGER NOT NULL DEFAULT 0, `createTime` INTEGER NOT NULL DEFAULT 0, `updateTime` INTEGER NOT NULL DEFAULT 0, `bookSort` INTEGER NOT NULL DEFAULT -1, `canUpdate` INTEGER NOT NULL DEFAULT 0, `coverOnly` INTEGER NOT NULL DEFAULT 0, `coverType` INTEGER NOT NULL DEFAULT 0, `canDelete` INTEGER NOT NULL DEFAULT 1, PRIMARY KEY(`groupId`))", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`groupId` INTEGER NOT NULL, `groupName` TEXT NOT NULL, `coverUrl` TEXT, `groupDescribe` TEXT, `sort` INTEGER NOT NULL, `enableRefresh` INTEGER NOT NULL DEFAULT 1, `show` INTEGER NOT NULL DEFAULT 1, `groupType` INTEGER NOT NULL DEFAULT 0, `createTime` INTEGER NOT NULL DEFAULT 0, `updateTime` INTEGER NOT NULL DEFAULT 0, `bookSort` INTEGER NOT NULL DEFAULT -1, `canUpdate` INTEGER NOT NULL DEFAULT 0, `coverOnly` INTEGER NOT NULL DEFAULT 0, `coverType` INTEGER NOT NULL DEFAULT 0, `canDelete` INTEGER NOT NULL DEFAULT 1, `isTop` INTEGER NOT NULL DEFAULT 0, PRIMARY KEY(`groupId`))", "fields": [ { "fieldPath": "groupId", @@ -362,6 +362,22 @@ export default { "boolean": true, "notNull": true, "defaultValue": "1" + }, + { + "fieldPath": "isTop", + "columnName": "isTop", + "affinity": "INTEGER", + "boolean": true, + "notNull": true, + "defaultValue": "0" + }, + { + "fieldPath": "isSystem", + "columnName": "isSystem", + "affinity": "INTEGER", + "boolean": true, + "notNull": true, + "defaultValue": "0" } ], "primaryKey": { diff --git a/entry/src/main/ets/database/dao/BookGroupsDao.ets b/entry/src/main/ets/database/dao/BookGroupsDao.ets index d9ca28e8..d419b03d 100644 --- a/entry/src/main/ets/database/dao/BookGroupsDao.ets +++ b/entry/src/main/ets/database/dao/BookGroupsDao.ets @@ -47,6 +47,8 @@ class BookGroupsDao{ sql += ` ORDER BY + isSystem DESC, + isTop DESC, sort ASC `; const groupDbList = await DbUtil.querySqlForList(sql, column); @@ -172,6 +174,46 @@ class BookGroupsDao{ } } + //置顶 + async isUpdateGroupTop(id: number, isTop?: boolean) { + try { + const column: ColumnInfo[] = AppDatabaseUtil.getColumn(this.TABLE_NAME); + const predicates = DbUtil.getPredicates(this.TABLE_NAME); + predicates.equalTo('groupId', id) + const count = await DbUtil.queryForList(predicates, column) + if (column.length > 0) { + count.forEach((item) => { + item.isTop = isTop||!item.isTop + item.updateTime = Date.now() + this.update(item) + }) + return true + } + return false + } catch (err) { + console.log('TagInfo, Error, ', JSON.stringify(err)) + return false + } + } + + //更新分组显示状态 + async updateGroupShow(id: number, show?: boolean) { + try { + const column: ColumnInfo[] = AppDatabaseUtil.getColumn(this.TABLE_NAME); + const predicates = DbUtil.getPredicates(this.TABLE_NAME); + predicates.equalTo('groupId', id) + const count = await DbUtil.queryForList(predicates, column) + if (column.length > 0) + count.forEach((item) => { + item.show = show||!item.show + item.updateTime = Date.now() + this.update(item) + }) + } catch (e){ + console.log('TagInfo, Error, ', JSON.stringify(e)) + } + } + //系统初始分组数据 async initGroupData() { let initGroup = ['分组','全部','未分组','本地','书单'] @@ -187,6 +229,8 @@ class BookGroupsDao{ group.show = true group.groupType = 123 group.canDelete = false + group.isSystem = true + group.isTop = true await bookGroupsDao.insert(group) } }catch (e){ diff --git a/entry/src/main/ets/database/dao/BooksDao.ets b/entry/src/main/ets/database/dao/BooksDao.ets index f1ca2d12..acc96f1a 100644 --- a/entry/src/main/ets/database/dao/BooksDao.ets +++ b/entry/src/main/ets/database/dao/BooksDao.ets @@ -199,6 +199,38 @@ class BooksDao { return false } } + + //根据分组id统计书籍数量 + async countBookByGroup(groupId: number) { + try { + const column: ColumnInfo[] = AppDatabaseUtil.getColumn(this.TABLE_NAME); + const predicates = DbUtil.getPredicates(this.TABLE_NAME); + predicates.equalTo('bookGroup', groupId) + const count = await DbUtil.queryForCount(predicates, column) + return count + } catch (err) { + console.log('TagInfo, Error, ', JSON.stringify(err)) + return 0 + } + } + + //分组删除情况下根据删除分组id查询书籍更新未分组 + async queryBookByGroup(groupId: number,updateGroupId: number) { + try { + const column: ColumnInfo[] = AppDatabaseUtil.getColumn(this.TABLE_NAME); + const predicates = DbUtil.getPredicates(this.TABLE_NAME); + predicates.equalTo('bookGroup', groupId) + const bookDbList = await DbUtil.queryForList(predicates, column) + if (bookDbList.length > 0) { + bookDbList.forEach((item) => { + item.bookGroup = updateGroupId + this.update(item) + }) + } + } catch (e) { + console.log('TagInfo, Error, ', JSON.stringify(e)) + } + } } diff --git a/entry/src/main/ets/database/entities/BookGroups.ets b/entry/src/main/ets/database/entities/BookGroups.ets index d3a3bdb5..6bb5b40c 100644 --- a/entry/src/main/ets/database/entities/BookGroups.ets +++ b/entry/src/main/ets/database/entities/BookGroups.ets @@ -36,4 +36,8 @@ export class BookGroups { canUpdate:boolean = false //是否可删除 canDelete:boolean = true + //是否置顶 + isTop:boolean = false + //是否系统参数 + isSystem:boolean = false } \ No newline at end of file diff --git a/entry/src/main/ets/pages/view/bookShelf/BookFolder.ets b/entry/src/main/ets/pages/view/bookShelf/BookFolder.ets index 82605a39..cf888c87 100644 --- a/entry/src/main/ets/pages/view/bookShelf/BookFolder.ets +++ b/entry/src/main/ets/pages/view/bookShelf/BookFolder.ets @@ -2,6 +2,8 @@ import { it } from '@ohos/hypium' import BookOverlay from '../../../componets/bookDetail/BookOverlay' import { showMessage } from '../../../componets/common/promptShow' import { folderList } from '../../../componets/dataList/folderList' +import BookGroupsDao from '../../../database/dao/BookGroupsDao' +import { BookGroups } from '../../../database/entities/BookGroups' import { updateDateGroup } from '../../../storage/groupData' import FolderInfoDialog from '../dialog/FolderInfoDialog' import FolderManageDialog from '../dialog/FolderManageDialog' @@ -12,27 +14,30 @@ import FolderManageDialog from '../dialog/FolderManageDialog' @Component export default struct BookFolder { @Prop EXHIBIT:string - @State groupCheckList:folderList[] = [] - @State isShow:boolean = false - @State @Watch('watchFolder')group:folderList = new folderList(0,'',0,$r('app.media.folder_test'),'') - @StorageProp('GROUP_LIST_DATA') groupData:folderList[] = [] + currentIndex:number = 0 @State changeNumber:number = 0 - - watchFolder(){ - if (this.changeNumber === 1) { - updateDateGroup(this.group) - } - } - @State isShowBookFolderInfoDialog:boolean = false + @StorageLink('BOOK_IS_BOOK_GROUPS_REFRESHING') @Watch('getGroupList')BOOK_IS_BOOK_GROUPS_REFRESHING: number = 0 + aboutToAppear(): void { + this.getGroupList() + } + @State groupList:BookGroups[] = [] + getGroupList(){ + BookGroupsDao.search({ + type:this.currentIndex + }).then((val)=>{ + this.groupList = val + }) + } + @State isShow:boolean = false build() { Flex({ direction: FlexDirection.Row, wrap: FlexWrap.Wrap,alignContent:FlexAlign.Center}){ - ForEach(this.groupData, (item: folderList,index:number) => { + ForEach(this.groupList, (item: BookGroups) => { Column(){ - if(!item.isShow){ + if(item.show && !item.isSystem){ if (this.EXHIBIT === '宫格'){ this.bookInfoGrid(item) } else { @@ -42,8 +47,7 @@ export default struct BookFolder { } .onClick(()=>{ this.isShowBookFolderInfoDialog = true - this.folderType = item.title - showMessage(item.title) + this.folderType = item.groupName }) }) } @@ -66,31 +70,26 @@ export default struct BookFolder { }.padding(15) } - @Builder bookInfoGrid(item: folderList){ + @Builder bookInfoGrid(item: BookGroups){ Column({ space:5 }) { Column(){ Column(){ Stack(){ - Column(){ - + Stack(){ + Stack(){ + if (item.isTop){ + Text('置顶').fontColor(Color.White).fontWeight(300).fontSize(8).padding(3).borderRadius(5) + .backgroundColor('rgba(0, 0, 0, 0.45)').zIndex(1) + } + Image(item.coverUrl) + .draggable(false) + .alt($r('app.media.icon_book_default_cover_one')) + .width(88) + .height(120) + }.alignContent(Alignment.BottomStart) } - .gesture( - LongPressGesture({ repeat: true,duration:500 }) - .onAction((event: GestureEvent) => { - if (event.repeat) { - if (!this.isShow) { - this.group = item - this.isShow = true - this.changeNumber = 1 - this.groupInfoDialog?.open() - } - } - })) - .width(88).height(120) - .backgroundImage(item.bookImage) - .backgroundImageSize({width:88,height:120}) .zIndex(2) Row(){ @@ -109,7 +108,7 @@ export default struct BookFolder { Row().width(100).height(20).backgroundColor('rgba(255, 255, 255, 0.6)').borderRadius(10) } - Text(item.title) + Text(item.groupName) .fontSize(15) .fontWeight(700) .textOverflow({ @@ -117,7 +116,7 @@ export default struct BookFolder { }) .ellipsisMode(EllipsisMode.END) .maxLines(2) - Text(`共${item.countNumber}本`).fontSize(12).fontColor('rgb(174,174,174)') + Text(`共${0}本`).fontSize(12).fontColor('rgb(174,174,174)') .textOverflow({ overflow:TextOverflow.Ellipsis }) @@ -131,7 +130,7 @@ export default struct BookFolder { .backgroundColor('rgba(244,244,244,0.8)') } - @Builder bookFolderInfo(group:folderList){ + @Builder bookFolderInfo(group:BookGroups){ Flex( { alignItems:ItemAlign.Center, @@ -142,16 +141,15 @@ export default struct BookFolder { space:20 }){ BookOverlay({ - bookImage:group.bookImage, + bookImage:group.coverUrl, isTop:group.isTop }) .gesture( LongPressGesture({ repeat: true,duration:500 }) .onAction((event: GestureEvent) => { if (event.repeat) { - if (!this.isShow) { - this.group = group + this.dialogGroupData = group this.isShow = true this.changeNumber = 1 this.groupInfoDialog?.open() @@ -162,10 +160,10 @@ export default struct BookFolder { space:24 }) { - Text(group.title) + Text(group.groupName) .fontWeight(700) Column(){ - Text(`共${group.countNumber}本`).fontSize(12).fontColor('rgb(174,174,174)') + Text(`共${0}本`).fontSize(12).fontColor('rgb(174,174,174)') .textOverflow({ overflow:TextOverflow.Ellipsis }) @@ -173,15 +171,15 @@ export default struct BookFolder { .fontWeight(400) .maxLines(1) .lineHeight(20) - Text(group.newUpdateBook?group.newUpdateBook:'暂无更新') - .fontSize(12) - .fontWeight(400) - .textOverflow({ - overflow:TextOverflow.Ellipsis - }) - .ellipsisMode(EllipsisMode.END) - .maxLines(1) - .lineHeight(20) + // Text(group.newUpdateBook?group.newUpdateBook:'暂无更新') + // .fontSize(12) + // .fontWeight(400) + // .textOverflow({ + // overflow:TextOverflow.Ellipsis + // }) + // .ellipsisMode(EllipsisMode.END) + // .maxLines(1) + // .lineHeight(20) } .width('60%') .alignItems(HorizontalAlign.Start) @@ -193,10 +191,10 @@ export default struct BookFolder { .borderRadius(10) } - + @State dialogGroupData:BookGroups = new BookGroups() groupInfoDialog: CustomDialogController | null = new CustomDialogController({ builder: FolderInfoDialog({ - itemData:this.group, + itemData:this.dialogGroupData, cancel: () => { this.exitDialog() } @@ -213,7 +211,6 @@ export default struct BookFolder { this.isShow = false this.changeNumber = 0 this.groupInfoDialog?.close() - showMessage('退出了') } } \ No newline at end of file diff --git a/entry/src/main/ets/pages/view/bookShelf/IndexShelf.ets b/entry/src/main/ets/pages/view/bookShelf/IndexShelf.ets index fff53e06..a5cce2af 100644 --- a/entry/src/main/ets/pages/view/bookShelf/IndexShelf.ets +++ b/entry/src/main/ets/pages/view/bookShelf/IndexShelf.ets @@ -10,10 +10,16 @@ export default struct IndexShelf { THEME_NAMES: string[] = ['书籍导入', '下载管理', '导入书单', '批量管理'] titleArray: Array = ['小说', '漫画', '有声书'] - @State bookType:string = '全部' @State bookTypeNumber:number = 2 @State EXHIBIT: string = '列表' - @State GROUP: string = '标签' + @State @Watch('changeGroup')GROUP: string = '标签' + changeGroup(){ + if (this.GROUP === '文件夹') { + this.bookTypeNumber = 1 + } else { + this.bookTypeNumber = 2 + } + } @State searchValue: string = '最近阅读' @State isShowImport: boolean = false @@ -169,7 +175,6 @@ export default struct IndexShelf { EXHIBIT: this.EXHIBIT, GROUP: this.GROUP, searchValue: this.searchValue, - bookType: this.bookType, bookTypeNumber:this.bookTypeNumber }) } diff --git a/entry/src/main/ets/pages/view/bookShelf/Manage/BookManagePage.ets b/entry/src/main/ets/pages/view/bookShelf/Manage/BookManagePage.ets index 09369d3b..91de29b1 100644 --- a/entry/src/main/ets/pages/view/bookShelf/Manage/BookManagePage.ets +++ b/entry/src/main/ets/pages/view/bookShelf/Manage/BookManagePage.ets @@ -15,21 +15,20 @@ import ShelfBookList from '../Shelf/ShelfBookList'; import booksDao from '../../../../database/dao/BooksDao'; import { Books } from '../../../../database/entities/Books'; import { buttonList } from '../../../../componets/dataList/buttonList'; -import InsideCircleIcon from '../../../../componets/common/InsideCircleIcon'; import booksUtil from '../../../../common/utils/booksUtils'; import BookSelectGroupDialog from '../components/dialog/BookSelectGroupDialog'; +import BookGroupsDao from '../../../../database/dao/BookGroupsDao'; +import { BookGroups } from '../../../../database/entities/BookGroups'; +import PaddingConstants from '../../../../common/constants/PaddingConstants'; +import bookGroupUtil from '../../../../common/utils/bookGroupUtils'; class routerParams { currentIndex:number EXHIBIT:string - GROUPName:string - bookTypes:string bookTypeNumber:number constructor(param:routerParams) { this.currentIndex = param.currentIndex this.EXHIBIT = param.EXHIBIT - this.GROUPName = param.GROUPName - this.bookTypes = param.bookTypes this.bookTypeNumber = param.bookTypeNumber } } @@ -39,50 +38,52 @@ class routerParams { @Entry @Component struct BookManagePage { - @State GROUPName:string = (router.getParams() as routerParams).GROUPName @State currentIndex: number = (router.getParams() as routerParams).currentIndex @State EXHIBIT: string = (router.getParams() as routerParams).EXHIBIT - @State bookTypes: string = (router.getParams() as routerParams).bookTypes @State bookTypeNumber:number = (router.getParams() as routerParams).bookTypeNumber @StorageLink('topRectHeight') topRectHeight: number = 0 @StorageLink('bottomRectHeight') bottomRectHeight: number = 0 - @State isClear:boolean = false - @State allCheck:boolean = false - @State @Watch('changeCheckNumber')checkNumber:number = 0 - - @State changeTop:boolean = false - @State isShow:boolean = false @State isAddShelfShow:boolean = false - - - @State bookType:string = '' - - @State BooTypeList:string[] = ['玄幻','修真', '都市', '穿越', '网游', '科幻', '历史'] - @State ShelfList:string[] = ['玄幻神作', '精品小说,亲自品鉴', '冷门小说不容错过','冷门小说不容错过'] - @State clickBookType:string = '' - @State topTitle:string = '置顶' @State bookList:Books[] = [] @State checkList:string[] = [] + @State bookGroups:BookGroups[] = [] @StorageLink('BOOK_IS_BOOK_REFRESHING') isBookRefreshing: number = 0 + @StorageLink('BOOK_IS_BOOK_GROUPS_REFRESHING') BOOK_IS_BOOK_GROUPS_REFRESHING: number = 0 + selectIsAllTop(){ let allTopNumber = 0 let allNotTopNumber = 0 this.checkList.forEach((index)=>{ //从bookList更具id查询是否都isTop - this.bookList.filter((item)=>{ - if (item.isTop && Number(index) === item.id){ - allTopNumber++ - } - if (!item.isTop && Number(index) === item.id){ - allNotTopNumber++ - } - }) + if (this.bookTypeNumber === 5){ + + } else if (this.bookTypeNumber === 1){ + this.bookGroups.filter((item)=>{ + if (item.isTop && Number(index) === item.groupId){ + allTopNumber++ + } + if (!item.isTop && Number(index) === item.groupId){ + allNotTopNumber++ + } + }) + } else { + this.bookList.filter((item)=>{ + if (item.isTop && Number(index) === item.id){ + allTopNumber++ + } + if (!item.isTop && Number(index) === item.id){ + allNotTopNumber++ + } + }) + } + }) + if (allTopNumber === this.checkList.length && allTopNumber > 0) { this.topTitle = '取消置顶' } @@ -99,22 +100,37 @@ struct BookManagePage { }) } + getGroupList(){ + BookGroupsDao.search({ + type:this.currentIndex + }).then((val)=>{ + this.bookGroups = val + }) + } + + changeCheckNumber(){ - if (this.checkNumber !== 0 && this.checkNumber === this.bookList.length) { - this.allCheck = true - } + } @StorageLink('GROUP_LIST_DATA') groupData:folderList[] = [] onPageShow(): void { - this.getBookList() + if (this.bookTypeNumber === 1) { + this.getGroupList() + this.isMoveStatus = 1 + } else if (this.bookTypeNumber !== 5){ + this.getBookList() + this.isMoveStatus = 0 + } else if (this.bookTypeNumber === 5){ + this.isMoveStatus = 2 + // this.getBookList() //todo 获取书单 + } + } - @State folderCheckList:folderList[] = [] folderCheckNumber(){ - this.checkNumber = this.folderCheckList.length } @State showNumber:number = 0 @@ -122,52 +138,55 @@ struct BookManagePage { new BookList('1','开局长生万古,苟到天荒地老','这个世界,有儒;有道;有佛书;有妖;有术士。警校毕业的许七安幽幽醒来,发现自己将要远赴','更新至·第340章 镇压',$r('app.media.shelf_book'),'玄幻')] build() { Column(){ - if (this.showNumber === 0){ - this.bookManage() - } else if(this.showNumber === 1){ - newBookShelf({ - addCheckShelf:this.addCheckShelf, - showNumber:this.showNumber, - isAddShelfShow:this.isAddShelfShow - }) - } else if (this.showNumber === 2){ - newAddShelf({ - addCheckShelf:this.addCheckShelf, - showNumber:this.showNumber, - isAddShelfShow:this.isAddShelfShow - }) + Column(){ + if (this.showNumber === 0){ + this.bookManage() + } else if(this.showNumber === 1){ + newBookShelf({ + addCheckShelf:this.addCheckShelf, + showNumber:this.showNumber, + isAddShelfShow:this.isAddShelfShow + }) + } else if (this.showNumber === 2){ + newAddShelf({ + addCheckShelf:this.addCheckShelf, + showNumber:this.showNumber, + isAddShelfShow:this.isAddShelfShow + }) + } } + .backgroundColor(Color.White) + .margin({ + top:this.topRectHeight, + bottom:this.bottomRectHeight + }) } - .backgroundColor(Color.White) - .padding({ - top:this.topRectHeight, - bottom:this.bottomRectHeight - }) - .backgroundColor("rgb(245, 245, 245)") - .linearGradient({ - direction: GradientDirection.Bottom, // 渐变方向 - colors: [["rgb(254, 203, 169)", 0.0], ["RGB(245, 245, 245)", 0.2]] // 数组末尾元素占比小于1时满足重复着色效果 - }) + // .height('100%') + // .linearGradient({ + // direction: GradientDirection.Bottom, // 渐变方向 + // colors: [["rgb(254, 203, 169)", 0.1],["RGB(245, 245, 245)", 0.2]] // 数组末尾元素占比小于1时满足重复着色效果 + // }) + // .borderRadius({ bottomRight: 5, bottomLeft: 5 }) + } @Builder bookManage(){ - Column() { - this.headTitle() - Flex({ - justifyContent:FlexAlign.Center - }){ + Flex({ + justifyContent:FlexAlign.SpaceBetween, + direction:FlexDirection.Column + }) { + Column(){ + this.headTitle() Scroll(){ - if (this.bookTypes === '书单'){ + if (this.bookTypeNumber === 5){ ShelfBookList({ EXHIBIT:this.EXHIBIT, isShowCheck:true }) } else { - if (this.GROUPName === '文件夹' || this.bookTypes === '分组'){ + if (this.bookTypeNumber === 1){ BookFolderManages({ - folderList:this.groupData, - folderCheckList:this.folderCheckList, - changeTop:this.changeTop, - EXHIBIT:this.EXHIBIT + EXHIBIT:this.EXHIBIT, + bookGroups:this.bookGroups }) } else { bookListManage({ @@ -179,15 +198,17 @@ struct BookManagePage { } } } - .height('88%') + .height('90%') .align(Alignment.TopStart) .scrollBar(BarState.Off) } - - if (this.bookTypes === '书单'){ - this.footerDel() - } else { - this.footerTitle() + Column(){ + Divider() + if (this.bookTypeNumber === 5){ + this.footerDel() + } else { + this.footerTitle() + } } } } @@ -241,22 +262,25 @@ struct BookManagePage { }.width('33%') - Text(`已选${this.checkList.length}项目`).fontSize(20).fontWeight(600) - .width('33%') + Column(){ + Text(`已选${this.checkList.length}项目`).fontSize(20).fontWeight(600) + } + .alignItems(HorizontalAlign.Center) + .width('33%') + Column(){ Text('完成') .fontSize(16) } .onClick(()=>{ - this.allCheck = false router.back() setTimeout(()=>{ this.isBookRefreshing++ },100) }) - .alignItems(HorizontalAlign.End) .width('33%') + .alignItems(HorizontalAlign.End) } .padding(10) } @@ -265,24 +289,33 @@ struct BookManagePage { Column(){ Text('删除').fontSize(16).fontWeight(500).lineHeight(24).fontColor('#EF4444') }.onClick(()=>{ - showMessage('测试删除') - this.isClear = true + }) + .backgroundColor(Color.White) .alignItems(HorizontalAlign.Center) .height('10%') .padding(20) } - @State buttonListInfo:buttonList[] = [ + @State buttonListInfo5:buttonList[] = [ new buttonList(1,'置顶',$r('app.media.top')), new buttonList(2,'移动至',$r('app.media.folder')), new buttonList(3,'加入书单',$r('app.media.shelf')), - new buttonList(4,'删除',$r('app.media.ic_public_delete')) + new buttonList(4,'隐藏分组',$r('app.media.hide')), + new buttonList(5,'删除',$r('app.media.ic_public_delete')) ] - @Builder footerTitle(){ + + @State buttonListInfo4:buttonList[] = [ + new buttonList(1,'置顶',$r('app.media.top')), + new buttonList(2,'移动至',$r('app.media.folder')), + new buttonList(3,'加入书单',$r('app.media.shelf')), + new buttonList(5,'删除',$r('app.media.ic_public_delete')) + ] + +@Builder footerTitle(){ GridRow({ - columns:4 + columns:this.bookTypeNumber===1?5:4 }){ - ForEach(this.buttonListInfo,(item:buttonList)=>{ + ForEach(this.bookTypeNumber===1?this.buttonListInfo5:this.buttonListInfo4,(item:buttonList)=>{ GridCol(){ if (item.id === 1) { Column({ @@ -308,7 +341,11 @@ struct BookManagePage { } }) } - .height('10%') + .padding({ + top:10, + bottom:10 + }) + .backgroundColor(Color.White) } bookInfoButton(index:number){ @@ -328,7 +365,14 @@ struct BookManagePage { showMessage('请选择要操作的内容'); return } - this.bookDelDialog?.open(); break; + this.clickHideDialog?.open() + break + case 5 : + if (this.checkList.length <= 0) { + showMessage('请选择要操作的内容'); + return + } + this.delDialog?.open(); break; } } @@ -337,7 +381,7 @@ struct BookManagePage { showMessage('请选择要操作的内容') return } - if (this.GROUPName !== '分组' && this.GROUPName !== '书单') { + if (this.bookTypeNumber !== 5 && this.bookTypeNumber !== 1) { this.checkList.forEach((item:string)=>{ //将item转换为number let bookId = Number(item) @@ -348,15 +392,29 @@ struct BookManagePage { this.checkList = [] setTimeout(()=>{ this.getBookList() - showMessage('已置顶') this.topTitle = '置顶' this.fullActive = !this.fullActive },500) + } else if(this.bookTypeNumber === 1){ + this.checkList.forEach((item:string)=>{ + //将item转换为number + let bookId = Number(item) + if (bookId) { + bookGroupUtil.isTopGroup(bookId, this.topTitle==='置顶'?true:false) + } + }) + this.checkList = [] + setTimeout(()=>{ + this.getGroupList() + this.topTitle = '置顶' + this.fullActive = !this.fullActive + },500) } + showMessage('已置顶') } @State delCache:boolean = false //弹窗 - bookDelDialog: CustomDialogController | null = new CustomDialogController({ + delDialog: CustomDialogController | null = new CustomDialogController({ builder: confirmDialogExample({ confirm: ()=> { this.deleteGroup() }, delCache:this.delCache @@ -370,7 +428,7 @@ struct BookManagePage { deleteGroup() { this.isBookDelete() - this.bookDelDialog?.close() + this.delDialog?.close() } isBookDelete(){ @@ -378,21 +436,28 @@ struct BookManagePage { showMessage('请选择要删除的内容') return } - if (this.GROUPName !== '分组' && this.GROUPName !== '书单') { - this.checkList.forEach((item:string)=>{ - //将item转换为number - let bookId = Number(item) + this.checkList.forEach((item:string)=>{ + let bookId = Number(item) + if (this.bookTypeNumber !== 1 && this.bookTypeNumber !== 5) { if (bookId) { booksUtil.delBooksById(bookId) } - }) - this.checkList = [] - setTimeout(()=>{ - this.getBookList() - showMessage('已删除') - this.fullActive = !this.fullActive - },500) - } + } else if(this.bookTypeNumber === 1){ + if (bookId) { + bookGroupUtil.delGroupById(bookId) + } + } + }) + this.checkList = [] + setTimeout(()=>{ + this.getBookList() + this.getGroupList() + this.BOOK_IS_BOOK_GROUPS_REFRESHING++ + this.isBookRefreshing++ + showMessage('已删除') + this.fullActive = !this.fullActive + },500) + } @Builder catalogAddShelf() { @@ -501,11 +566,8 @@ struct BookManagePage { //是否隐藏分组 clickHideDialog: CustomDialogController | null = new CustomDialogController({ builder: hideDialogExample({ - cancel: ()=> { this.clickHideCancel() }, - confirm: ()=> { this.clickHideAccept() }, - title:`` + confirm: ()=> { this.clickHideAccept() } }), - cancel: this.hideDialog, autoCancel: true, alignment: DialogAlignment.Center, gridCount: 4, @@ -513,32 +575,37 @@ struct BookManagePage { cornerRadius: 25, }) - clickHideCancel() { - - } - clickHideAccept() { + bookGroupUtil.updateGroupShow(this.checkList.map((item:string)=>{ + return Number(item) + })) + setTimeout(()=>{ + this.getGroupList() + this.BOOK_IS_BOOK_GROUPS_REFRESHING++ + this.fullActive = !this.fullActive + showMessage('已隐藏') + },500) } - hideDialog() { - } + //操作状态 + @State isMoveStatus:number = 0 - //移动分组 - //弹窗 bookMoveGroup: CustomDialogController | null = new CustomDialogController({ builder: BookSelectGroupDialog({ moveGroup: ()=> { this.bookMoveGroup?.close() setTimeout(()=>{ this.isBookRefreshing++ + this.BOOK_IS_BOOK_GROUPS_REFRESHING++ },500) showMessage('移动成功') }, currentIndex:this.currentIndex, //将this.checkList转换为number - bookIds:this.checkList.map((item:string)=>{ + Ids:this.checkList.map((item:string)=>{ return Number(item) - }) + }), + isMoveStatus:this.isMoveStatus }), height: 400, autoCancel: true, diff --git a/entry/src/main/ets/pages/view/bookShelf/Manage/bookManage/BookFolderGridManage.ets b/entry/src/main/ets/pages/view/bookShelf/Manage/bookManage/BookFolderGridManage.ets index 6312a522..65d354a8 100644 --- a/entry/src/main/ets/pages/view/bookShelf/Manage/bookManage/BookFolderGridManage.ets +++ b/entry/src/main/ets/pages/view/bookShelf/Manage/bookManage/BookFolderGridManage.ets @@ -1,5 +1,6 @@ -import BookOverlay from '../../../../../componets/bookDetail/BookOverlay' -import { folderList } from '../../../../../componets/dataList/folderList' +import { showMessage } from '../../../../../componets/common/promptShow' +import BooksDao from '../../../../../database/dao/BooksDao' +import { BookGroups } from '../../../../../database/entities/BookGroups' /** * 文件夹宫格_管理页 @@ -7,58 +8,56 @@ import { folderList } from '../../../../../componets/dataList/folderList' @Component export default struct BookFolderGridManage { - @Prop folderList:folderList - + @Prop group:BookGroups + @State count:number = 0 + aboutToAppear(): void { + if (this.group.groupId) { + BooksDao.countBookByGroup(this.group.groupId) + .then((val)=>{ + showMessage(JSON.stringify(val)) + this.count = val + }) + } + } build() { Column() { Stack() { - Flex({ - alignItems: ItemAlign.End, - justifyContent: FlexAlign.End - }) { - Flex({ - alignItems: ItemAlign.End, - }) { - if (this.folderList.isTop) { - Text('置顶') - .fontColor(Color.White) - .fontWeight(300) - .fontSize(8) - .padding(5) - .margin({ left: 1, bottom: 1 }) - .borderRadius({ bottomLeft: 10, bottomRight: 5, topRight: 5, topLeft: 5 }) - .backgroundColor('rgba(0, 0, 0, 0.45)') - } - } - .align(Alignment.Bottom) - + Stack(){ Checkbox({ - name: this.folderList.title, + name: JSON.stringify(this.group.groupId), group:'checkboxGroup' }) - .zIndex(2) + .zIndex(999) .selectedColor($r('app.color.theme_color')) .unselectedColor('rgba(0, 0, 0, 0.35)') + + Stack(){ + if (this.group.isTop){ + Text('置顶').fontColor(Color.White).fontWeight(300).fontSize(8).padding(3).borderRadius(5) + .backgroundColor('rgba(0, 0, 0, 0.45)').zIndex(1) + } + Image(this.group.coverUrl) + .alt($r('app.media.icon_book_default_cover_one')) + .width(88) + .height(120) + }.alignContent(Alignment.BottomStart) } - .backgroundColor('rgba(0, 0, 0, 0.45)') - .width(88) - .height(120) - .backgroundImage(this.folderList.bookImage) - .backgroundImageSize({ width: 88, height: 120 }) .zIndex(2) + // .alignContent(Alignment.BottomStart) + + Row() { Image($r('app.media.occlusion1')) } - .zIndex(1) - .width(95).height(110) - + .zIndex(1).width(95).height(110) Row() { Image($r('app.media.occlusion2')) - }.zIndex(0) - .width(100).height(100) + } + .zIndex(0).width(100).height(100) } + .alignContent(Alignment.BottomStart) Row().width(100).height(20).backgroundColor('rgba(255, 255, 255, 0.6)').borderRadius(10) - Text(this.folderList.title) + Text(this.group.groupName) .fontSize(15) .fontWeight(700) .textOverflow({ @@ -66,7 +65,7 @@ export default struct BookFolderGridManage { }) .ellipsisMode(EllipsisMode.END) .maxLines(2) - Text(`共${this.folderList.countNumber}本`).fontSize(12).fontColor('rgb(174,174,174)') + Text(`共${this.count}本`).fontSize(12).fontColor('rgb(174,174,174)') .textOverflow({ overflow:TextOverflow.Ellipsis }) diff --git a/entry/src/main/ets/pages/view/bookShelf/Manage/bookManage/BookFolderInfoManage.ets b/entry/src/main/ets/pages/view/bookShelf/Manage/bookManage/BookFolderInfoManage.ets index 104ecd08..665c714c 100644 --- a/entry/src/main/ets/pages/view/bookShelf/Manage/bookManage/BookFolderInfoManage.ets +++ b/entry/src/main/ets/pages/view/bookShelf/Manage/bookManage/BookFolderInfoManage.ets @@ -1,5 +1,7 @@ import BookOverlay from '../../../../../componets/bookDetail/BookOverlay' -import { folderList } from '../../../../../componets/dataList/folderList' +import { showMessage } from '../../../../../componets/common/promptShow' +import BooksDao from '../../../../../database/dao/BooksDao' +import { BookGroups } from '../../../../../database/entities/BookGroups' /** * 文件夹列表_管理页 @@ -7,7 +9,17 @@ import { folderList } from '../../../../../componets/dataList/folderList' @Component export default struct BookFolderInfoManage { - @Prop folderList:folderList + @Prop group:BookGroups + @State count:number = 0 + aboutToAppear(): void { + if (this.group.groupId) { + BooksDao.countBookByGroup(this.group.groupId) + .then((val)=>{ + showMessage(JSON.stringify(val)) + this.count = val + }) + } + } build() { Flex( { @@ -19,17 +31,17 @@ export default struct BookFolderInfoManage { space:20 }){ BookOverlay({ - bookImage:this.folderList.bookImage, - isTop:this.folderList.isTop + bookImage:this.group.coverUrl, + isTop:this.group.isTop }) Column({ space:24 }) { - Text(this.folderList.title) + Text(this.group.groupName) .fontWeight(700) Column(){ - Text(`共${this.folderList.countNumber}本`).fontSize(12).fontColor('rgb(174,174,174)') + Text(`共${this.count}本`).fontSize(12).fontColor('rgb(174,174,174)') .textOverflow({ overflow:TextOverflow.Ellipsis }) @@ -37,15 +49,15 @@ export default struct BookFolderInfoManage { .fontWeight(400) .maxLines(1) .lineHeight(20) - Text(this.folderList.newUpdateBook?this.folderList.newUpdateBook:'暂无更新') - .fontSize(12) - .fontWeight(400) - .textOverflow({ - overflow:TextOverflow.Ellipsis - }) - .ellipsisMode(EllipsisMode.END) - .maxLines(1) - .lineHeight(20) + // Text(this.group.?this.folderList.newUpdateBook:'暂无更新') + // .fontSize(12) + // .fontWeight(400) + // .textOverflow({ + // overflow:TextOverflow.Ellipsis + // }) + // .ellipsisMode(EllipsisMode.END) + // .maxLines(1) + // .lineHeight(20) } .width('60%') .alignItems(HorizontalAlign.Start) @@ -54,7 +66,7 @@ export default struct BookFolderInfoManage { } Row() { Checkbox({ - name: this.folderList.title, + name: JSON.stringify(this.group.groupId), group:'checkboxGroup' }) .selectedColor($r('app.color.theme_color')) diff --git a/entry/src/main/ets/pages/view/bookShelf/Manage/bookManage/BookFolderManages.ets b/entry/src/main/ets/pages/view/bookShelf/Manage/bookManage/BookFolderManages.ets index 3a095401..63ec815c 100644 --- a/entry/src/main/ets/pages/view/bookShelf/Manage/bookManage/BookFolderManages.ets +++ b/entry/src/main/ets/pages/view/bookShelf/Manage/bookManage/BookFolderManages.ets @@ -1,14 +1,13 @@ import confirmDialogExample from '../../../../../componets/common/confirmDialog' import { showMessage } from '../../../../../componets/common/promptShow' import { folderList } from '../../../../../componets/dataList/folderList' +import { BookGroups } from '../../../../../database/entities/BookGroups' import BookFolderGridManage from './BookFolderGridManage' import BookFolderInfoManage from './BookFolderInfoManage' @Component export default struct BookFolderManages { - @Link folderCheckList:folderList[] - @Prop changeTop:boolean - @Link folderList:folderList[] + @Prop bookGroups:BookGroups[] = [] @Prop EXHIBIT:string @State delCache:boolean = false bookInfoDel: CustomDialogController | null = new CustomDialogController({ @@ -42,35 +41,38 @@ export default struct BookFolderManages { } build() { - if (this.folderList === null || this.folderList.length === 0) { + if (this.bookGroups === null || this.bookGroups.length === 0) { Column() { Image($r('app.media.no_record')).width(200).height(200) Text('暂无浏览记录').fontSize(12).fontColor('rgba(96, 96, 96, 0.6)').fontWeight(500).padding(5) } .margin({ top: 120 }) } else { - Flex({ direction: FlexDirection.Row, wrap: FlexWrap.Wrap,alignContent:FlexAlign.Center}){ + Column(){ if (this.EXHIBIT === '列表') { - ForEach(this.folderList, (item: folderList) => { - if (!item.isShow) { + ForEach(this.bookGroups, (item: BookGroups) => { + if (item.show && !item.isSystem) { BookFolderInfoManage({ - folderList:item + group:item }) } }) } else { - ForEach(this.folderList, (item: folderList) => { - if (!item.isShow) { - BookFolderGridManage({ - folderList:item - }).width('33%') - } - }) + GridRow({ + columns:3 + }){ + ForEach(this.bookGroups, (item: BookGroups) => { + if (item.show && !item.isSystem) { + GridCol(){ + BookFolderGridManage({ + group:item + }) + } + } + }) + } } - } + }.layoutWeight(1) } - - - } } \ No newline at end of file diff --git a/entry/src/main/ets/pages/view/bookShelf/Manage/bookManage/BookInfoGridManage.ets b/entry/src/main/ets/pages/view/bookShelf/Manage/bookManage/BookInfoGridManage.ets index a9fca3e9..a31e72cd 100644 --- a/entry/src/main/ets/pages/view/bookShelf/Manage/bookManage/BookInfoGridManage.ets +++ b/entry/src/main/ets/pages/view/bookShelf/Manage/bookManage/BookInfoGridManage.ets @@ -21,6 +21,8 @@ export default struct BookInfoGridManage{ name: JSON.stringify(this.bookData.id), group: 'checkboxGroup' }) + .selectedColor($r('app.color.theme_color')) + .unselectedColor('rgba(0, 0, 0, 0.35)') .zIndex(2) } Stack(){ diff --git a/entry/src/main/ets/pages/view/bookShelf/Manage/bookManage/bookListManage.ets b/entry/src/main/ets/pages/view/bookShelf/Manage/bookManage/bookListManage.ets index 3982199c..075b03df 100644 --- a/entry/src/main/ets/pages/view/bookShelf/Manage/bookManage/bookListManage.ets +++ b/entry/src/main/ets/pages/view/bookShelf/Manage/bookManage/bookListManage.ets @@ -16,33 +16,6 @@ export default struct bookListManage{ } @State delCache:boolean = false - //弹窗 - bookInfoDel: CustomDialogController | null = new CustomDialogController({ - builder: confirmDialogExample({ - cancel: ()=> { this.onCancel() }, - confirm: ()=> { this.onAccept() }, - delCache:this.delCache, - isShowCache:true - }), - cancel: this.exitApp, - autoCancel: true, - alignment: DialogAlignment.Center, - gridCount: 4, - customStyle: false, - cornerRadius: 25, - }) - - onCancel() { - - } - - onAccept() { - - } - - exitApp() { - - } build() { if (this.bookList === null || this.bookList.length === 0) { diff --git a/entry/src/main/ets/pages/view/bookShelf/components/BookBodyContent.ets b/entry/src/main/ets/pages/view/bookShelf/components/BookBodyContent.ets index f2509004..277a1811 100644 --- a/entry/src/main/ets/pages/view/bookShelf/components/BookBodyContent.ets +++ b/entry/src/main/ets/pages/view/bookShelf/components/BookBodyContent.ets @@ -18,7 +18,6 @@ export default struct BookBodyContent { @Link EXHIBIT: string @Link GROUP: string @Link searchValue: string - @Link bookType: string @Link bookTypeNumber:number @State title: string = '最近阅读' @State groupCoverShow: boolean = false @@ -56,7 +55,6 @@ export default struct BookBodyContent { currentIndex: this.currentIndex, EXHIBIT: this.EXHIBIT, GROUPName: this.GROUP, - bookTypes: this.bookType, bookTypeNumber: this.bookTypeNumber } }) @@ -103,7 +101,6 @@ export default struct BookBodyContent { GROUP: this.GROUP, searchValue: this.searchValue, currentIndex: this.currentIndex, - bookType: this.bookType, bookTypeNumber:this.bookTypeNumber }) } 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 40d26e79..a80f84ac 100644 --- a/entry/src/main/ets/pages/view/bookShelf/components/BookContentRefresh.ets +++ b/entry/src/main/ets/pages/view/bookShelf/components/BookContentRefresh.ets @@ -12,9 +12,9 @@ import BookContent from './BookContent' export default struct BookContentRefresh { @State @Watch('changeRefreshing')isRefreshing: boolean = false @StorageLink('BOOK_IS_BOOK_REFRESHING') isBookRefreshing: number = 0 + @StorageLink('BOOK_IS_BOOK_GROUPS_REFRESHING') isGroupRefreshing: number = 0 @State counter: number = 0 @State RefreshingTitle: string = '松开刷新' - @Link bookType:string @Prop currentIndex: number = 0 @Link EXHIBIT: string @Link GROUP: string @@ -24,13 +24,14 @@ export default struct BookContentRefresh { changeRefreshing(){ if (this.isRefreshing) { this.isBookRefreshing++ + this.isGroupRefreshing++ } } build() { Refresh({ refreshing: $$this.isRefreshing, builder: this.refreshComponent }) { Scroll() { Column() { - if (this.bookType === '书单' && this.searchValue !== '浏览历史') { + if (this.bookTypeNumber === 5 && this.searchValue !== '浏览历史') { ShelfBookList({ EXHIBIT: this.EXHIBIT }) @@ -44,7 +45,8 @@ export default struct BookContentRefresh { }) } else { BookFolder({ - EXHIBIT: this.EXHIBIT + EXHIBIT: this.EXHIBIT, + currentIndex:this.currentIndex }) } } 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 8b592b5b..90e8757d 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 @@ -155,7 +155,7 @@ export default struct BookInfoDialogs{ },500) }, currentIndex:this.bookData.bookType, - bookIds:this.bookData.id + Ids:this.bookData.id }), height: 400, cancel: this.exitApp, diff --git a/entry/src/main/ets/pages/view/bookShelf/components/dialog/BookSelectGroupDialog.ets b/entry/src/main/ets/pages/view/bookShelf/components/dialog/BookSelectGroupDialog.ets index 0b33e9dc..da1e3678 100644 --- a/entry/src/main/ets/pages/view/bookShelf/components/dialog/BookSelectGroupDialog.ets +++ b/entry/src/main/ets/pages/view/bookShelf/components/dialog/BookSelectGroupDialog.ets @@ -6,6 +6,7 @@ */ import CommonConstants from '../../../../../common/constants/CommonConstants' import PaddingConstants from '../../../../../common/constants/PaddingConstants' +import bookGroupUtils from '../../../../../common/utils/bookGroupUtils' import booksUtils from '../../../../../common/utils/booksUtils' import addBookTypeDialog from '../../../../../componets/common/addBookTypeDialog' import { showMessage } from '../../../../../componets/common/promptShow' @@ -19,7 +20,8 @@ import { BookGroups } from '../../../../../database/entities/BookGroups' export default struct BookSelectGroupDialog{ controller?: CustomDialogController currentIndex:number = 0 - bookIds:number|number[] = 0 + Ids:number|number[] = 0 + isMoveStatus:number = 0 moveGroup:Function = ()=>{ } @@ -86,6 +88,7 @@ export default struct BookSelectGroupDialog{ .height(CommonConstants.FULL_HEIGHT) } @State moveGroupId:number = 0 + @State moveTitle:string = '' @Builder title(item?:BookGroups) { Column() { if (item){ @@ -103,6 +106,7 @@ export default struct BookSelectGroupDialog{ } if (item.groupId) { this.moveGroupId = item.groupId + this.moveTitle = item.groupName this.clickBookTypeDialog?.open() } }) @@ -173,7 +177,7 @@ export default struct BookSelectGroupDialog{ confirm: ()=> { this.clickBookAccept() }, - title:`移动分组至${this.bookType}` + title:`移动分组至${this.moveTitle}` }), autoCancel: true, alignment: DialogAlignment.Center, @@ -183,8 +187,16 @@ export default struct BookSelectGroupDialog{ }) clickBookAccept() { - booksUtils.updateBooks(this.bookIds,this.moveGroupId) - this.moveGroup() + switch (this.isMoveStatus){ + //0标识书籍 + case 0: + booksUtils.updateBooks(this.Ids,this.moveGroupId); + break + //1标识分组 + case 1: + bookGroupUtils.moveBookByGroupId(this.Ids,this.moveGroupId) + break + } } } \ No newline at end of file diff --git a/entry/src/main/ets/pages/view/coverInfoImageShow.ets b/entry/src/main/ets/pages/view/coverInfoImageShow.ets index 3e2aa386..b8d27a88 100644 --- a/entry/src/main/ets/pages/view/coverInfoImageShow.ets +++ b/entry/src/main/ets/pages/view/coverInfoImageShow.ets @@ -9,7 +9,7 @@ import BookOverlay from '../../componets/bookDetail/BookOverlay' @Component export default struct coverInfoImageShow { @Prop coverCount:number - @Prop image:Resource + @Prop image:Resource|string @Prop imageString:string build() { if (this.coverCount === 1){ @@ -21,7 +21,7 @@ export default struct coverInfoImageShow { } } - @Builder coverImageOne(bookImage:Resource){ + @Builder coverImageOne(bookImage:Resource|string){ Column(){ BookOverlay({ bookImage:bookImage, diff --git a/entry/src/main/ets/pages/view/dialog/FolderInfoDialog.ets b/entry/src/main/ets/pages/view/dialog/FolderInfoDialog.ets index 66acfb43..39be875d 100644 --- a/entry/src/main/ets/pages/view/dialog/FolderInfoDialog.ets +++ b/entry/src/main/ets/pages/view/dialog/FolderInfoDialog.ets @@ -5,6 +5,7 @@ import { showMessage } from '../../../componets/common/promptShow' import TitleContentDialog from '../../../componets/common/TitleContentDialog' import { buttonList } from '../../../componets/dataList/buttonList' import { folderList } from '../../../componets/dataList/folderList' +import { BookGroups } from '../../../database/entities/BookGroups' import { updateBookListData } from '../../../storage/bookListData' import { delGroupById } from '../../../storage/groupData' import coverInfoDialog from './coverInfoDialog' @@ -16,7 +17,7 @@ import coverInfoDialog from './coverInfoDialog' export default struct FolderInfoDialog{ controller?: CustomDialogController //推送提醒 - @Link itemData:folderList + @Prop itemData:BookGroups @State pushReminder:boolean = false @State buttonListInfo:buttonList[] = [ new buttonList(1,'重命名',$r('app.media.edit')), @@ -30,6 +31,7 @@ export default struct FolderInfoDialog{ ] cancel: () => void = () => { + } build() { @@ -39,15 +41,15 @@ export default struct FolderInfoDialog{ alignItems:ItemAlign.Center }){ Column(){ - Text(this.itemData.title).fontColor('rgba(0, 0, 0, 0.88)').fontSize(16).fontWeight(500).lineHeight(24) - Text(`共${(this.itemData.countNumber)}本`).fontColor('rgba(0, 0, 0, 0.45)').fontWeight(400).lineHeight(20).fontSize(12) + Text(this.itemData.groupName).fontColor('rgba(0, 0, 0, 0.88)').fontSize(16).fontWeight(500).lineHeight(24) + Text(`共${0}本`).fontColor('rgba(0, 0, 0, 0.45)').fontWeight(400).lineHeight(20).fontSize(12) } Row(){ Text('更新提醒') - Toggle({ type: ToggleType.Switch, isOn: this.itemData.isUpdateReminder}) + Toggle({ type: ToggleType.Switch, isOn: this.itemData.canDelete}) .selectedColor("#F60").hoverEffect(HoverEffect.None) - .onChange(()=>{ - this.itemData.isUpdateReminder = !this.itemData.isUpdateReminder + .onChange((val)=>{ + this.itemData.canDelete = val }) } }.padding(20) @@ -113,12 +115,11 @@ export default struct FolderInfoDialog{ } restTitle(){ this.restTitleDialog?.open() - this.inputValue = this.itemData.title + this.inputValue = this.itemData.groupName } isFolderTop(){ this.itemData.isTop = true - this.itemData.topUpdateTime = new Date() } @State inputValue:string = '' @@ -148,11 +149,11 @@ export default struct FolderInfoDialog{ } restTitleConfirm(){ console.log(this.inputValue + 'inputValue') - this.itemData.title = this.inputValue + this.itemData.groupName = this.inputValue this.inputValue = '' showMessage('重命名成功') console.log(JSON.stringify(this.itemData)) - console.log(JSON.stringify(this.itemData.title)) + console.log(JSON.stringify(this.itemData.groupName)) this.restTitleDialog?.close() } @@ -172,7 +173,9 @@ export default struct FolderInfoDialog{ }) deleteGroup() { - delGroupById(this.itemData.id) + if (this.itemData.groupId) { + delGroupById(this.itemData.groupId) + } this.cancel() } @@ -215,7 +218,7 @@ export default struct FolderInfoDialog{ } //隐藏分组 hideGroup(){ - this.itemData.isShow = true + this.itemData.show = false this.cancel() } diff --git a/entry/src/main/ets/pages/view/dialog/coverInfoDialog.ets b/entry/src/main/ets/pages/view/dialog/coverInfoDialog.ets index b068c2c7..4fb13855 100644 --- a/entry/src/main/ets/pages/view/dialog/coverInfoDialog.ets +++ b/entry/src/main/ets/pages/view/dialog/coverInfoDialog.ets @@ -1,6 +1,7 @@ import { folderList } from '../../../componets/dataList/folderList' import { pickerAvatar } from '../../../common/utils/photoViewPicker' import coverInfoImageShow from '../coverInfoImageShow' +import { BookGroups } from '../../../database/entities/BookGroups' @CustomDialog /** @@ -10,7 +11,7 @@ import coverInfoImageShow from '../coverInfoImageShow' export default struct coverInfoDialog{ controller?: CustomDialogController //推送提醒 - @Link itemData:folderList + @Prop itemData:BookGroups @State coverImages:string = '' cancel: () => void = () => { } @@ -22,8 +23,8 @@ export default struct coverInfoDialog{ alignItems:ItemAlign.Center }){ Column(){ - Text(this.itemData.title).fontColor('rgba(0, 0, 0, 0.88)').fontSize(16).fontWeight(500).lineHeight(24) - Text(`共${this.itemData.countNumber}本`).fontColor('rgba(0, 0, 0, 0.45)').fontWeight(400).lineHeight(20).fontSize(12) + Text(this.itemData.groupName).fontColor('rgba(0, 0, 0, 0.88)').fontSize(16).fontWeight(500).lineHeight(24) + Text(`共${0}本`).fontColor('rgba(0, 0, 0, 0.45)').fontWeight(400).lineHeight(20).fontSize(12) } Row(){ Text('仅用于当前分组') @@ -41,7 +42,7 @@ export default struct coverInfoDialog{ }){ coverInfoImageShow({ coverCount:1, - image:this.itemData.bookImage + image:this.itemData.coverUrl }) coverInfoImageShow({ coverCount:2,