From 4c60b72bae453ff91e742855ed1275884f1b9a7a Mon Sep 17 00:00:00 2001 From: 2008 <49343738+MaoXiaoone@users.noreply.github.com> Date: Fri, 17 May 2024 00:49:48 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=A1=E7=90=86=E9=A1=B5=E9=9A=90=E8=97=8F?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E3=80=81=E9=9A=90=E8=97=8F=E5=BC=B9=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 管理页隐藏文件、隐藏弹窗 --- .../main/ets/componets/common/hideDialog.ets | 44 +++++++++++ .../ets/componets/dataList/folderList.ets | 5 +- .../view/bookShelf/Manage/BookManagePage.ets | 76 +++++++++++++++---- .../Manage/bookManage/BookFolderManages.ets | 29 +++---- entry/src/main/ets/viewData/bookData.ets | 2 +- 5 files changed, 127 insertions(+), 29 deletions(-) create mode 100644 entry/src/main/ets/componets/common/hideDialog.ets diff --git a/entry/src/main/ets/componets/common/hideDialog.ets b/entry/src/main/ets/componets/common/hideDialog.ets new file mode 100644 index 00000000..c9db9488 --- /dev/null +++ b/entry/src/main/ets/componets/common/hideDialog.ets @@ -0,0 +1,44 @@ + +@CustomDialog +export default struct hideDialogExample { + + controller?: CustomDialogController + // 若尝试在CustomDialog中传入多个其他的Controller,以实现在CustomDialog中打开另一个或另一些CustomDialog,那么此处需要将指向自己的controller放在所有controller的后面 + cancel: () => void = () => { + } + confirm: () => void = () => { + } + @Prop title:string + + build() { + Column() { + Text(`确定隐藏吗?` ).fontWeight(600).maxLines(1).minFontSize(12).maxFontSize(20).margin({ top: 20, bottom: 10 }) + Text('隐藏后可点击分组标签栏右侧分组管理入口查看隐藏分组并进入').width('70%').textAlign(TextAlign.Center) + .fontColor('rgba(0, 0, 0, 0.45)').fontSize(14).fontWeight(400).lineHeight(22) + Row({space:24}) { + Text('取消') + .onClick(() => { + if (this.controller != undefined) { + this.controller.close() + this.cancel() + } + }) + .borderRadius(15) + .padding({left:30,right:30,top:10,bottom:10}) + .fontColor($r('app.color.theme_color')) + .backgroundColor('rgba(255,120,0,0.12)') + Text('确认') + .onClick(() => { + if (this.controller != undefined) { + this.controller.close() + this.confirm() + } + }) + .borderRadius(15) + .padding({left:30,right:30,top:10,bottom:10}) + .fontColor(Color.White) + .backgroundColor($r('app.color.theme_color')) + }.padding({top:20,bottom:20}) + } + } +} \ No newline at end of file diff --git a/entry/src/main/ets/componets/dataList/folderList.ets b/entry/src/main/ets/componets/dataList/folderList.ets index b51b8c33..5a8ab7ce 100644 --- a/entry/src/main/ets/componets/dataList/folderList.ets +++ b/entry/src/main/ets/componets/dataList/folderList.ets @@ -34,13 +34,15 @@ export class folderList { */ isTop:boolean + isShow:boolean + newUpdateBook:string topUpdateTime:Date - constructor(id:number,title:string,countNumber:number,bookImage:Resource,bookType:string,newUpdateBook:string = '',isTop:boolean = false,describe:string = '', topUpdateTime:Date = new Date()) { + constructor(id:number,title:string,countNumber:number,bookImage:Resource,bookType:string,newUpdateBook:string = '',isShow:boolean = false,isTop:boolean = false,describe:string = '', topUpdateTime:Date = new Date()) { this.id = id this.title = title this.bookType = bookType @@ -50,5 +52,6 @@ export class folderList { this.bookImage = bookImage this.newUpdateBook = newUpdateBook this.topUpdateTime = topUpdateTime + this.isShow = isShow } } 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 fecb33b2..f6d1988c 100644 --- a/entry/src/main/ets/pages/view/bookShelf/Manage/BookManagePage.ets +++ b/entry/src/main/ets/pages/view/bookShelf/Manage/BookManagePage.ets @@ -10,6 +10,7 @@ import { folderList } from '../../../../componets/dataList/folderList'; import BookFolderManages from './bookManage/BookFolderManages'; import newBookShelf from './bookManage/newBookShelf'; import newAddShelf from './bookManage/newAddShelf'; +import hideDialogExample from '../../../../componets/common/hideDialog'; class routerParams { currentIndex:number @@ -345,7 +346,11 @@ struct BookManagePage { Text('隐藏分组').fontSize(14).fontWeight(500) } .onClick(()=>{ - + if (this.folderCheckList.length === 0) { + showMessage('请选择要隐藏的选项') + return + } + this.clickHideDialog?.open() }) } @@ -361,6 +366,48 @@ struct BookManagePage { .height('10%') .padding(20) } + showFolderType(){ + console.log(JSON.stringify(this.folderCheckList)) + for (let i = 0; i < this.folderCheckList.length; i++) { + for (let j = 0; j < this.novelPageList.length; j++) { + if (this.folderCheckList[i].id === this.novelPageList[j].id) { + this.novelPageList[j].isShow = true + console.log(JSON.stringify(this.novelPageList[j])) + break + } + } + } + this.allCheck = false + this.folderCheckList = [] + this.showFolderSort() + showMessage('隐藏成功') + } + + //是否确认移动分组 + clickBookTypeDialog: CustomDialogController | null = new CustomDialogController({ + builder: hideDialogExample({ + cancel: ()=> { this.clickBookCancel() }, + confirm: ()=> { this.clickBookAccept() } + }), + cancel: this.clickExitDialog, + autoCancel: true, + alignment: DialogAlignment.Center, + gridCount: 4, + customStyle: false, + cornerRadius: 25, + }) + + clickBookCancel() { + this.clickBookType = '' + } + + clickBookAccept() { + this.mobileBookType() + } + + clickExitDialog() { + this.clickBookType = '' + } cancelShowTop(){ //循环遍历checkBookList当bookId和showBookList中的bookId相同时,将showBookList isTop改为false @@ -570,14 +617,14 @@ struct BookManagePage { }) } - //是否确认移动分组 - clickBookTypeDialog: CustomDialogController | null = new CustomDialogController({ - builder: confirmDialogExample({ - cancel: ()=> { this.clickBookCancel() }, - confirm: ()=> { this.clickBookAccept() }, - title:`移动到${this.clickBookType}` + //是否隐藏分组 + clickHideDialog: CustomDialogController | null = new CustomDialogController({ + builder: hideDialogExample({ + cancel: ()=> { this.clickHideCancel() }, + confirm: ()=> { this.clickHideAccept() }, + title:`` }), - cancel: this.clickExitDialog, + cancel: this.hideDialog, autoCancel: true, alignment: DialogAlignment.Center, gridCount: 4, @@ -585,16 +632,17 @@ struct BookManagePage { cornerRadius: 25, }) - clickBookCancel() { - this.clickBookType = '' + clickHideCancel() { + } - clickBookAccept() { - this.mobileBookType() + clickHideAccept() { + this.showFolderType() + } - clickExitDialog() { - this.clickBookType = '' + hideDialog() { + } mobileBookType(){ 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 8236cd53..e4e7a3b3 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 @@ -71,22 +71,25 @@ export default struct BookFolderManages { Flex({ direction: FlexDirection.Row, wrap: FlexWrap.Wrap,alignContent:FlexAlign.Center}){ if (this.EXHIBIT === '列表') { ForEach(this.folderList, (item: folderList) => { - BookFolderInfoManage({ - folderList:item, - changeTop:this.changeTop, - allCheck:this.allCheck, - folderCheckList:this.folderCheckList - }) + if (!item.isShow) { + BookFolderInfoManage({ + folderList:item, + changeTop:this.changeTop, + allCheck:this.allCheck, + folderCheckList:this.folderCheckList + }) + } }) - } else { ForEach(this.folderList, (item: folderList) => { - BookFolderGridManage({ - folderList:item, - changeTop:this.changeTop, - allCheck:this.allCheck, - folderCheckList:this.folderCheckList - }).width('33%') + if (!item.isShow) { + BookFolderGridManage({ + folderList:item, + changeTop:this.changeTop, + allCheck:this.allCheck, + folderCheckList:this.folderCheckList + }).width('33%') + } }) } } diff --git a/entry/src/main/ets/viewData/bookData.ets b/entry/src/main/ets/viewData/bookData.ets index 5460d36b..85296044 100644 --- a/entry/src/main/ets/viewData/bookData.ets +++ b/entry/src/main/ets/viewData/bookData.ets @@ -1,7 +1,7 @@ import { folderList } from '../componets/dataList/folderList' export const novelPageList:folderList[] = [ - new folderList(1,'玄幻',12,$r('app.media.folder_test'),'玄幻','宿命之环等3本有更新'), + new folderList(1,'玄幻',12,$r('app.media.folder_test'),'玄幻','宿命之环等3本有更新',true), new folderList(2,'都市',13,$r('app.media.folder_test'),'都市'), new folderList(3,'仙侠',12,$r('app.media.folder_test'),'仙侠'), new folderList(4,'武侠',12,$r('app.media.folder_test'),'武侠'),