diff --git a/entry/src/main/ets/common/utils/booksUtils.ets b/entry/src/main/ets/common/utils/booksUtils.ets index 1effa839..ac15e943 100644 --- a/entry/src/main/ets/common/utils/booksUtils.ets +++ b/entry/src/main/ets/common/utils/booksUtils.ets @@ -1,5 +1,5 @@ import BooksDao from '../../database/dao/BooksDao' -import { Books } from '../../database/entities/Books' +import { Books, BOOK_SEARCH_TYPE } from '../../database/entities/Books' import bookGroupUtils from './bookGroupUtils' import toolsUtils from './ToolsUtils' @@ -60,6 +60,11 @@ class booksUtils{ let bookId: number[] = toolsUtils.numberArrays(ids) return await BooksDao.getBookByIds(bookId) } + + //校验类型数据查询数组内容 + getOrder(type:string){ + return BOOK_SEARCH_TYPE.indexOf(type) ?? 0; + } } let booksUtil = new booksUtils(); export default booksUtil as booksUtils; \ No newline at end of file diff --git a/entry/src/main/ets/componets/group/GroupTypeSearch.ets b/entry/src/main/ets/componets/group/GroupTypeSearch.ets index 3ce63f39..bfbb0ae9 100644 --- a/entry/src/main/ets/componets/group/GroupTypeSearch.ets +++ b/entry/src/main/ets/componets/group/GroupTypeSearch.ets @@ -9,6 +9,7 @@ export default struct groupTypeSearch { @Link groupCoverShow:boolean @State groupList:BookGroups[] = [] @Link bookTypeNumber:number + @Link searchBookList:number[] aboutToAppear(): void { this.getGroupList() } @@ -30,6 +31,7 @@ export default struct groupTypeSearch { groupCoverShow:this.groupCoverShow, showGroupList:this.groupList, currentIndex:this.currentIndex, + searchBookList:this.searchBookList }) .zIndex(9999) Rect() diff --git a/entry/src/main/ets/componets/group/groupTypePanel.ets b/entry/src/main/ets/componets/group/groupTypePanel.ets index 3bf60014..372c05d1 100644 --- a/entry/src/main/ets/componets/group/groupTypePanel.ets +++ b/entry/src/main/ets/componets/group/groupTypePanel.ets @@ -292,7 +292,6 @@ export default struct groupTypePanel{ } @State isShowBookFolderInfoDialog:boolean = false - @Provide searchBookList:number[] = [] @Builder bookFolderInfoDialog(){ Column(){ BookManageDialog({ diff --git a/entry/src/main/ets/componets/group/groupTypeSearchPanel.ets b/entry/src/main/ets/componets/group/groupTypeSearchPanel.ets index a3763065..e4883c63 100644 --- a/entry/src/main/ets/componets/group/groupTypeSearchPanel.ets +++ b/entry/src/main/ets/componets/group/groupTypeSearchPanel.ets @@ -11,6 +11,7 @@ export default struct groupTypeSearchPanel{ @State hideList:BookGroups[] = [] @Prop currentIndex:number = 0 @Prop clickGroup:BookGroups + @Link searchBookList:number[] aboutToAppear(): void { this.getGroupList() } @@ -160,7 +161,8 @@ export default struct groupTypeSearchPanel{ bookTypeNumber:this.clickGroup.groupId, isManage:true, isManageSearch:true, - searchCheck:()=>{ + searchCheck:(val:number[])=>{ + this.searchBookList = val this.isShowBookFolderInfoDialog = false } }) diff --git a/entry/src/main/ets/componets/head/IndexSearchType.ets b/entry/src/main/ets/componets/head/IndexSearchType.ets index b4c5a47c..47506027 100644 --- a/entry/src/main/ets/componets/head/IndexSearchType.ets +++ b/entry/src/main/ets/componets/head/IndexSearchType.ets @@ -1,12 +1,16 @@ +import CommonConstants from '../../common/constants/CommonConstants' +import FontConstants from '../../common/constants/FontConstants' +import PaddingConstants from '../../common/constants/PaddingConstants' +import { BOOK_SEARCH_TYPE } from '../../database/entities/Books' + @Component export default struct IndexSearchType { @Prop title:string @Link searchValue:string @State isShown: boolean = false - @State THEME_NAME: string[] = ['最近阅读', '阅读排序', '更新排序', '手动排序'] build() { - if (this.THEME_NAME.includes(this.title)){ + if (BOOK_SEARCH_TYPE.includes(this.title)){ Row( { space:3 @@ -24,12 +28,23 @@ export default struct IndexSearchType { this.searchValue = this.title this.isShown = !this.isShown }) - .bindMenu(this.isShown, this.MenuBuilder, - { - onDisappear: ()=>{ + .bindPopup(this.isShown,{ + builder: this.MenuBuilder(), + placement: Placement.Bottom, + enableArrow:true, + radius:12, + onStateChange: (e) => { + if (!e.isVisible) { this.isShown = false; } - }) + } + }) + // .bindMenu(this.isShown, this.MenuBuilder, + // { + // onDisappear: ()=>{ + // this.isShown = false; + // } + // }) } else { Row( { @@ -46,31 +61,41 @@ export default struct IndexSearchType { } @Builder MenuBuilder() { - Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { - ForEach(this.THEME_NAME, (item:string, index) => { - if (item !== this.searchValue){ - Column() { - Row() { - Text(item).fontSize(15) - } - .width('100%') - .height(30) - .justifyContent(FlexAlign.Center) - .align(Alignment.Center) - .onClick(() => { - this.title = item - this.searchValue = item - // this.THEME_NAMES = this.THEME_NAME.filter((value) => { - // return value !== item; - // }) - }) - if (index != this.THEME_NAME.length - 1) { - Divider().height(10).width('80%').color('#ccc') - } + Column(){ + ForEach(BOOK_SEARCH_TYPE, (item:string, index) => { + Column() { + Row() { + Text(item) + .font({ + size: FontConstants.FONT_SIZE_14, + weight: FontConstants.FONT_WEIGHT_400, + family: CommonConstants.FAMILY_PingFANG + }) + .fontColor(this.searchValue === item ? $r('app.color.theme_color') : $r('app.string.color_black_88')) + Image(item === this.searchValue?$r('app.media.hook'):'').width(20).height(20) + } + .padding({ + top: PaddingConstants.PADDING_12, + bottom: PaddingConstants.PADDING_12, + left:PaddingConstants.PADDING_20, + right:PaddingConstants.PADDING_20 + }) + .width('100%') + .height(40) + .justifyContent(FlexAlign.SpaceBetween) + .align(Alignment.Center) + .onClick(() => { + this.title = item + this.searchValue = item + this.isShown = false + }) + if (index != BOOK_SEARCH_TYPE.length - 1) { + Divider().height(10).width('80%').color('#ccc') } } - }) - }.width(150) + } + .padding(PaddingConstants.PADDING_4) + .width(150) } } \ 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 c277e5cd..3fc3146a 100644 --- a/entry/src/main/ets/database/dao/BooksDao.ets +++ b/entry/src/main/ets/database/dao/BooksDao.ets @@ -1,3 +1,4 @@ +import booksUtils from '../../common/utils/booksUtils'; import DbUtil from '../../common/utils/DbUtil'; import toolsUtils from '../../common/utils/ToolsUtils'; import AppDatabaseUtil from '../AppDatabaseUtil'; @@ -27,6 +28,11 @@ class BooksDao { let searchKey = param?.searchKey ?? ''; let type = param?.type; let bookGroup = param?.bookGroup; + let order = param?.order; + let sort = 0 + if (order !== undefined){ + sort = booksUtils.getOrder(order) + } try { const column: ColumnInfo[] = AppDatabaseUtil.getColumn(this.TABLE_NAME); let sql = `SELECT * FROM ${this.TABLE_NAME}`; @@ -50,10 +56,23 @@ class BooksDao { if (whereClause.length > 0) { sql += ` WHERE ${whereClause.join(' AND ')}`; } - sql += ` - ORDER BY - isTop DESC, createTime DESC -`; + sql += ` ORDER BY`; + if (order !== undefined) { + switch (sort){ + case 0: + sql += ` isTop DESC, durChapterTime DESC`; + break; + case 1: + sql += ` isTop DESC, latestChapterTime DESC`; + break; + case 2: + sql += ` isTop DESC, sort ASC`; + break; + } + } else { + sql += ` isTop DESC, createTime DESC`; + } + const bookDbList = await DbUtil.querySqlForList(sql, column); console.log("TagInfo", '书籍:' + bookDbList.length) return bookDbList diff --git a/entry/src/main/ets/database/entities/Books.ets b/entry/src/main/ets/database/entities/Books.ets index 89c773f8..ec57d1b7 100644 --- a/entry/src/main/ets/database/entities/Books.ets +++ b/entry/src/main/ets/database/entities/Books.ets @@ -75,4 +75,6 @@ export class Books { updateTime?:number = 0 //是否加入书架 isJoin:boolean = false -} \ No newline at end of file +} + +export const BOOK_SEARCH_TYPE: string[] = ['最近阅读', '更新排序', '手动排序'] \ No newline at end of file diff --git a/entry/src/main/ets/database/types/BooksType.ets b/entry/src/main/ets/database/types/BooksType.ets index f57e8ad5..a7314006 100644 --- a/entry/src/main/ets/database/types/BooksType.ets +++ b/entry/src/main/ets/database/types/BooksType.ets @@ -9,5 +9,7 @@ export interface BooksTypeSearchParams { // 源类型 0 小说;1 漫画;2 有声书; type?: number, //分组 - bookGroup?: number + bookGroup?: number, + //排序方式 + order?: string } \ No newline at end of file diff --git a/entry/src/main/ets/pages/view/Subscription/RssSources/dialogNewSources.ets b/entry/src/main/ets/pages/view/Subscription/RssSources/dialogNewSources.ets index 3e15d0a6..2d2aebc9 100644 --- a/entry/src/main/ets/pages/view/Subscription/RssSources/dialogNewSources.ets +++ b/entry/src/main/ets/pages/view/Subscription/RssSources/dialogNewSources.ets @@ -73,7 +73,7 @@ export default struct dialogNewSources{ @Builder newSourcesBuilder(){ - Flex(){ + Column(){ newSources({ isEdit:false, hideNewSources:()=>{ diff --git a/entry/src/main/ets/pages/view/Subscription/components/SubscriptionContent.ets b/entry/src/main/ets/pages/view/Subscription/components/SubscriptionContent.ets index cc27ec91..5e3c7bb8 100644 --- a/entry/src/main/ets/pages/view/Subscription/components/SubscriptionContent.ets +++ b/entry/src/main/ets/pages/view/Subscription/components/SubscriptionContent.ets @@ -263,7 +263,7 @@ export default struct SubscriptionContent{ @Builder newSourcesBuilder(){ - Flex(){ + Column(){ newSources({ isEdit:true, hideNewSources:()=>{ diff --git a/entry/src/main/ets/pages/view/bookShelf/BookFolder.ets b/entry/src/main/ets/pages/view/bookShelf/BookFolder.ets index 8939db25..87383ec2 100644 --- a/entry/src/main/ets/pages/view/bookShelf/BookFolder.ets +++ b/entry/src/main/ets/pages/view/bookShelf/BookFolder.ets @@ -73,7 +73,6 @@ export default struct BookFolder { }) } @Prop clickGroup:BookGroups - @Provide searchBookList:number[] = [] @Builder bookFolderInfoDialog(){ Column(){ BookManageDialog({ diff --git a/entry/src/main/ets/pages/view/bookShelf/IndexShelf.ets b/entry/src/main/ets/pages/view/bookShelf/IndexShelf.ets index 955f678b..fecad9b4 100644 --- a/entry/src/main/ets/pages/view/bookShelf/IndexShelf.ets +++ b/entry/src/main/ets/pages/view/bookShelf/IndexShelf.ets @@ -20,8 +20,6 @@ export default struct IndexShelf { this.bookTypeNumber = 2 } } - @State searchValue: string = '最近阅读' - @State isShowImport: boolean = false @State isShowCloudImport: boolean = false @State isShowImportBookList: boolean = false @@ -174,7 +172,6 @@ export default struct IndexShelf { currentIndex: this.currentIndex, EXHIBIT: this.EXHIBIT, GROUP: this.GROUP, - searchValue: this.searchValue, bookTypeNumber:this.bookTypeNumber }) } diff --git a/entry/src/main/ets/pages/view/bookShelf/Manage/bookManage/newAddShelf.ets b/entry/src/main/ets/pages/view/bookShelf/Manage/bookManage/newAddShelf.ets index 2a9ee540..944ed160 100644 --- a/entry/src/main/ets/pages/view/bookShelf/Manage/bookManage/newAddShelf.ets +++ b/entry/src/main/ets/pages/view/bookShelf/Manage/bookManage/newAddShelf.ets @@ -22,7 +22,7 @@ export default struct newAddShelf{ @StorageLink('bottomRectHeight') bottomRectHeight: number = 0 @State @Watch('getBookList')bookTypeNumber:number = 2 @State groupCoverShow: boolean = false - @Provide @Watch('searchBook')searchBookList:number[] = [] + @State @Watch('searchBook')searchBookList:number[] = [] //用于分组弹窗添加书籍 searchBook(){ if (this.searchBookList.length === 0 ) return @@ -102,7 +102,8 @@ export default struct newAddShelf{ Stack(){ groupTypeSearch({ bookTypeNumber:this.bookTypeNumber, - groupCoverShow:this.groupCoverShow + groupCoverShow:this.groupCoverShow, + searchBookList:this.searchBookList }) .zIndex(9) Column(){ diff --git a/entry/src/main/ets/pages/view/bookShelf/Manage/bookManage/newBookShelf.ets b/entry/src/main/ets/pages/view/bookShelf/Manage/bookManage/newBookShelf.ets index 63fbf91d..218dd77d 100644 --- a/entry/src/main/ets/pages/view/bookShelf/Manage/bookManage/newBookShelf.ets +++ b/entry/src/main/ets/pages/view/bookShelf/Manage/bookManage/newBookShelf.ets @@ -15,6 +15,8 @@ import newAddShelf from './newAddShelf' @Component export default struct newBookShelf{ + @StorageLink('topRectHeight') topRectHeight: number = 0 + @StorageLink('bottomRectHeight') bottomRectHeight: number = 0 @Prop currentIndex:number @State TextRecommend:Record = {} @State delCache:boolean = false @@ -272,6 +274,10 @@ export default struct newBookShelf{ } }) } + .padding({ + top:this.topRectHeight, + bottom:this.bottomRectHeight + }) } @Builder newAddBook(){ @@ -281,7 +287,7 @@ export default struct newBookShelf{ addBookList:(selectBookId:number[])=>{ this.newBookIds = selectBookId this.isShowAddBook = false; - showMessage('加入书单成功,提交生效!', 1000) + showMessage('加入书单成功,提交生效!') }, close:() => { this.isShowAddBook = false; diff --git a/entry/src/main/ets/pages/view/bookShelf/Manage/components/catalogAddShelf.ets b/entry/src/main/ets/pages/view/bookShelf/Manage/components/catalogAddShelf.ets index b24dbab6..f1effc8b 100644 --- a/entry/src/main/ets/pages/view/bookShelf/Manage/components/catalogAddShelf.ets +++ b/entry/src/main/ets/pages/view/bookShelf/Manage/components/catalogAddShelf.ets @@ -23,8 +23,6 @@ export default struct catalogAddShelf{ @Prop showNumber:number = 0 @State worksBook:WorksLists = new WorksLists() @State worksLists:WorksLists[] =[] - @StorageLink('topRectHeight') topRectHeight: number = 0 - @StorageLink('bottomRectHeight') bottomRectHeight: number = 0 @State newBookIds:number[] = [] getWorkLists() { worksListsDao.search({ @@ -128,10 +126,6 @@ export default struct catalogAddShelf{ bookIds: this.newBookIds }) } - .padding({ - top:this.topRectHeight, - bottom:this.bottomRectHeight - }) .backgroundColor(Color.White) } diff --git a/entry/src/main/ets/pages/view/bookShelf/Shelf/WorksBookLists.ets b/entry/src/main/ets/pages/view/bookShelf/Shelf/WorksBookLists.ets index 4f4d0d4b..bfe5a5ba 100644 --- a/entry/src/main/ets/pages/view/bookShelf/Shelf/WorksBookLists.ets +++ b/entry/src/main/ets/pages/view/bookShelf/Shelf/WorksBookLists.ets @@ -18,8 +18,6 @@ export default struct WorksBookLists { @Prop worksLists:WorksLists[] =[] @Prop isShowCheck:boolean = false @State worksBook:WorksLists = new WorksLists() - @StorageLink('topRectHeight') topRectHeight: number = 0 - @StorageLink('bottomRectHeight') bottomRectHeight: number = 0 @StorageLink('BOOK_IS_BOOK_WORKS_BOOK_LIST') @Watch('getWorkLists')isWorksBookListRefreshing: number = 0 aboutToAppear(): void { if (this.worksLists.length === 0) { @@ -116,10 +114,6 @@ export default struct WorksBookLists { lastWorkBookList:this.worksBook }) } - .padding({ - top:this.topRectHeight, - bottom:this.bottomRectHeight - }) .backgroundColor(Color.White) } shelfInfoDialog: CustomDialogController | null = new CustomDialogController({ 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 c6a5c5dd..6f2f19c0 100644 --- a/entry/src/main/ets/pages/view/bookShelf/components/BookBodyContent.ets +++ b/entry/src/main/ets/pages/view/bookShelf/components/BookBodyContent.ets @@ -19,7 +19,7 @@ export default struct BookBodyContent { @State GROUP_NAMES: string[] = ['标签', '文件夹'] @Link EXHIBIT: string @Link GROUP: string - @Link searchValue: string + @State searchValue: string = '最近阅读' @Link bookTypeNumber:number @State title: string = '最近阅读' @State groupCoverShow: boolean = false diff --git a/entry/src/main/ets/pages/view/bookShelf/components/BookContent.ets b/entry/src/main/ets/pages/view/bookShelf/components/BookContent.ets index d59badec..147fff73 100644 --- a/entry/src/main/ets/pages/view/bookShelf/components/BookContent.ets +++ b/entry/src/main/ets/pages/view/bookShelf/components/BookContent.ets @@ -11,7 +11,7 @@ export default struct BookContent { this.getBookList() } @Prop EXHIBIT:string - @Prop searchValue:string + @Prop @Watch('getBookList')searchValue:string @Prop @Watch('changeBookType')currentIndex: number @Prop @Watch('changeBookType')bookTypeNumber:number //更新数据累加刷新数据页面 @@ -29,7 +29,8 @@ export default struct BookContent { getBookList(){ booksDao.search({ type:this.currentIndex, - bookGroup:this.bookTypeNumber + bookGroup:this.bookTypeNumber, + order:this.searchValue }).then((val)=>{ this.bookList = val }) 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 e1bb7b3a..ef640bfc 100644 --- a/entry/src/main/ets/pages/view/bookShelf/components/BookContentRefresh.ets +++ b/entry/src/main/ets/pages/view/bookShelf/components/BookContentRefresh.ets @@ -22,7 +22,7 @@ export default struct BookContentRefresh { @Prop currentIndex: number = 0 @Link EXHIBIT: string @Link GROUP: string - @Link searchValue: string + @Prop searchValue: string @Link bookTypeNumber:number @State checkGroup:Record = {} changeRefreshing(){ diff --git a/entry/src/main/ets/pages/view/bookShelf/components/dialog/BookManageDialog.ets b/entry/src/main/ets/pages/view/bookShelf/components/dialog/BookManageDialog.ets index 586a9c7b..4253a26e 100644 --- a/entry/src/main/ets/pages/view/bookShelf/components/dialog/BookManageDialog.ets +++ b/entry/src/main/ets/pages/view/bookShelf/components/dialog/BookManageDialog.ets @@ -47,7 +47,6 @@ export default struct BookManageDialog { searchCheck:Function = (_checkListNumber?:number[])=>{ } - @Consume searchBookList:number[] // 用于添加书籍时将选中的书籍id返回 //判断是否全部置顶或取消置顶 selectIsAllTop(){ let allTopNumber = 0 @@ -385,8 +384,7 @@ export default struct BookManageDialog { } .onClick(async () => { if (this.isManageSearch) { - this.searchBookList = this.checkListNumber - this.searchCheck() + this.searchCheck(this.checkListNumber) } else { this.isManage = !this.isManage setTimeout(()=>{ diff --git a/entry/src/main/ets/pages/view/dialog/worksBookInfoDialog.ets b/entry/src/main/ets/pages/view/dialog/worksBookInfoDialog.ets index ec0e3e89..578be6bc 100644 --- a/entry/src/main/ets/pages/view/dialog/worksBookInfoDialog.ets +++ b/entry/src/main/ets/pages/view/dialog/worksBookInfoDialog.ets @@ -14,8 +14,6 @@ export default struct worksBookInfoDialog{ controller?: CustomDialogController //推送提醒 @Prop works:WorksLists - @StorageLink('topRectHeight') topRectHeight: number = 0 - @StorageLink('bottomRectHeight') bottomRectHeight: number = 0 @State buttonListInfo:buttonList[] = [ new buttonList(1,'编辑',$r('app.media.edit')), new buttonList(2,'分享',$r('app.media.icon_share')), @@ -98,10 +96,6 @@ export default struct worksBookInfoDialog{ lastWorkBookList:this.works }) } - .padding({ - top:this.topRectHeight, - bottom:this.bottomRectHeight - }) .backgroundColor(Color.White) }