Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into pr/228
Browse files Browse the repository at this point in the history
# Conflicts:
#	entry/src/main/ets/pages/view/bookShelf/IndexShelf.ets
  • Loading branch information
MaoXiaoone committed Jul 25, 2024
2 parents d3f02b9 + 50cbfa0 commit 6036f4b
Show file tree
Hide file tree
Showing 9 changed files with 335 additions and 58 deletions.
1 change: 1 addition & 0 deletions entry/src/main/ets/common/constants/CommonConstants.ets
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ export default class CommonConstants {
static readonly SHELF_LIST_DATA:string = 'SHELF_LIST_DATA'
static readonly HAS_EXPLORE_URL:string = 'HAS_EXPLORE_URL'
static readonly BOOK_IS_BOOK_REFRESHING:string = 'BOOK_IS_BOOK_REFRESHING'
static readonly BOOK_IS_BOOK_GROUPS_REFRESHING:string = 'BOOK_IS_BOOK_GROUPS_REFRESHING'
// 订阅源分组数据
//分组是否初始化key
static readonly RSS_SOURCES_GROUP_INIT:string = 'RSS_SOURCES_GROUP_INIT'
Expand Down
3 changes: 3 additions & 0 deletions entry/src/main/ets/common/utils/booksUtils.ets
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import BooksDao from '../../database/dao/BooksDao'
import { Books } from '../../database/entities/Books'

class booksUtils{
async isTopBook(id: number): Promise<boolean> {
return BooksDao.isUpdateBookTop(id)
}
async addBooks(books: Books){
BooksDao.insert(books)
}
Expand Down
2 changes: 1 addition & 1 deletion entry/src/main/ets/componets/common/InsideCircleIcon.ets
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { buttonList } from '../dataList/buttonList'

@Component
export default struct InsideCircleIcon{
export default struct InsideCircleIcon{
@Prop item:buttonList
build() {
Column({
Expand Down
2 changes: 1 addition & 1 deletion entry/src/main/ets/componets/group/GroupType.ets
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default struct groupTypeComponent {
@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()
}
Expand Down
57 changes: 54 additions & 3 deletions entry/src/main/ets/database/dao/BooksDao.ets
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class BooksDao {
if (type !== undefined) {
whereClause.push(`bookType = ${type}`);
}
if (bookGroup !== undefined) {
if (bookGroup !== undefined && bookGroup !== 2) {
whereClause.push(`bookGroup = ${bookGroup}`);
}
if (searchKey) {
Expand Down Expand Up @@ -110,7 +110,6 @@ class BooksDao {
predicates.equalTo('id', books.id)
const count = await DbUtil.queryForCount(predicates, column)
if (count === 0 && books instanceof Books) {
// books.createTime = Date.now()
this.insert(books)
return true
}
Expand All @@ -120,7 +119,59 @@ class BooksDao {
console.log('TagInfo, Error, ', JSON.stringify(err))
return false
}

}
//置顶
async isUpdateBookTop(id: number) {
try {
const column: ColumnInfo[] = AppDatabaseUtil.getColumn(this.TABLE_NAME);
const predicates = DbUtil.getPredicates(this.TABLE_NAME);
predicates.equalTo('id', id)
const count = await DbUtil.queryForList<Books>(predicates, column)
if (column.length > 0) {
count.forEach((item) => {
item.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 batchUpdateBookGroup(id: number[],groupId:number) {
try {
for (let index = 0; index < id.length; index++) {
this.updateBookGroup(id[index],groupId)
}
return true
} catch (err) {
console.log('TagInfo, Error, ', JSON.stringify(err))
return false
}
}
//更新书籍分组
async updateBookGroup(id: number,groupId:number) {
try {
const column: ColumnInfo[] = AppDatabaseUtil.getColumn(this.TABLE_NAME);
const predicates = DbUtil.getPredicates(this.TABLE_NAME);
predicates.equalTo('id', id)
const count = await DbUtil.queryForList<Books>(predicates, column)
if (column.length > 0) {
count.forEach((item) => {
item.bookGroup = groupId
this.update(item)
})
return true
}
return false
} catch (err) {
console.log('TagInfo, Error, ', JSON.stringify(err))
return false
}
}

//批量删除订阅源历史记录
Expand Down
88 changes: 48 additions & 40 deletions entry/src/main/ets/pages/view/bookShelf/IndexShelf.ets
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import BookMark from '../../../componets/head/BookMark'
import { router } from '@kit.ArkUI'
import BookBodyContent from './components/BookBodyContent'
import { picker } from '@kit.CoreFileKit'
import { FileHandler } from '../../../common/utils/FileHandler'
import Dialog from '../../../componets/common/Dialog'

Expand All @@ -9,32 +10,19 @@ export default struct IndexShelf {
@State currentIndex: number = 0
THEME_NAMES: string[] = ['书籍导入', '下载管理', '导入书单', '批量管理']
titleArray: Array<string> = ['小说', '漫画', '有声书']
@State bookType: string = '全部'
@State bookTypeNumber: number = 2

@State bookType:string = '全部'
@State bookTypeNumber:number = 2
@State EXHIBIT: string = '列表'
@State GROUP: string = '标签'
@State searchValue: string = '最近阅读'
@State isClear: boolean = false

@State isShowImport: boolean = false
@State isShowCloudImport: boolean = false
@State isShowImportBookList: boolean = false
@StorageLink('topRectHeight') topRectHeight: number = 0
@StorageProp('APP_INDEX_SCROLLABLE') APP_INDEX_SCROLLABLE: boolean = false
@StorageLink('BOOK_IS_BOOK_REFRESHING') isBookRefreshing: number = 0
// 网址导入dialog
dialogController: CustomDialogController = new CustomDialogController({
builder: Dialog({
title: '网址导入',
child: () => {
this.DialogInput("请输入书籍目录或详情页", 10)
}
}),
cornerRadius: 8,
offset: { dx: 0, dy: 0 }
})
tabsController: TabsController = new TabsController();
private scrollController: Scroller = new Scroller();

build() {
Column() {
Flex({
Expand Down Expand Up @@ -163,17 +151,17 @@ export default struct IndexShelf {
}) {
ForEach(this.titleArray, () => {
TabContent() {
Column() {
BookBodyContent({
currentIndex: this.currentIndex,
EXHIBIT: this.EXHIBIT,
GROUP: this.GROUP,
searchValue: this.searchValue,
isClear: this.isClear,
bookType: this.bookType,
bookTypeNumber: this.bookTypeNumber
})
}
Column(){
BookBodyContent({
currentIndex: this.currentIndex,
EXHIBIT: this.EXHIBIT,
GROUP: this.GROUP,
searchValue: this.searchValue,
isClear: this.isClear,
bookType: this.bookType,
bookTypeNumber:this.bookTypeNumber
})
}
}
})
}
Expand All @@ -196,13 +184,14 @@ export default struct IndexShelf {
.borderRadius({ bottomRight: 5, bottomLeft: 5 })
}


@Builder
TabBuilderImage(index: number, name: string) {
Column() {
Image($r('app.media.SUB_theme'))
}.width('100%')
}

@StorageLink('BOOK_IS_BOOK_REFRESHING') isBookRefreshing: number = 0
@Builder
// 书籍导入UI盒子
ImportClickBox(index: number, image: string, text: string) {
Expand Down Expand Up @@ -235,16 +224,21 @@ export default struct IndexShelf {
.onClick(async () => {
switch (index) {
case 0:
// 本地导入
// router.pushUrl({
// url: 'pages/view/bookShelf/LocalImportPage'
// });
let FileResult = await FileHandler.documentPickerFile(1, ['.txt', '.epub'])
FileHandler.CopyFile(FileResult[0], this.currentIndex)
// 本地导入
// router.pushUrl({
// url: 'pages/view/bookShelf/LocalImportPage'
// });
let documentSelectOptions = new picker.DocumentSelectOptions();
let documentPicker = new picker.DocumentViewPicker();
let filePath: string = ""
await documentPicker.select(documentSelectOptions).then((documentSelectResult: Array<string>) => {
filePath = documentSelectResult[0];
})
FileHandler.CopyFile(filePath,this.currentIndex)
this.isShowImport = false
setTimeout(() => {
setTimeout(()=>{
this.isBookRefreshing++
}, 500)
},500)
break
case 1:
// 云盘导入
Expand Down Expand Up @@ -304,6 +298,20 @@ export default struct IndexShelf {
}
}

// 网址导入dialog
dialogController: CustomDialogController = new CustomDialogController({
builder: Dialog({
title: '网址导入',
child: () => {
this.DialogInput("请输入书籍目录或详情页", 10)
}
}),
cornerRadius: 8,
offset: { dx: 0, dy: 0 }
})
tabsController: TabsController = new TabsController();
private scrollController: Scroller = new Scroller();

@Builder
DialogInput(placeholder: string, maxlength: number) {
Row() {
Expand Down Expand Up @@ -472,17 +480,17 @@ export default struct IndexShelf {
// 右上角更多
switch (themeNum) {
case 0:
// 书籍导入弹窗
// 书籍导入弹窗
this.isShowImport = true
break
case 1:
// 下载管理页
// 下载管理页
router.pushUrl({
url: 'pages/view/bookShelf/DownloadManagementPage'
});
break
case 2:
// 导入书单弹窗
// 导入书单弹窗
this.isShowImportBookList = true
break
case 3:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { showMessage } from '../../../../../componets/common/promptShow'
import confirmDialogExample from '../../../../../componets/common/confirmDialog'
import { sleep } from '../../../../../common/utils/utils'
import booksUtil from '../../../../../common/utils/booksUtils'
import BookSelectGroupDialog from './BookSelectGroupDialog'

@CustomDialog
/**
Expand All @@ -14,10 +15,10 @@ import booksUtil from '../../../../../common/utils/booksUtils'
export default struct BookInfoDialogs{
controller?: CustomDialogController
//推送提醒
@Link bookData:Books
@Prop bookData:Books
@State pushReminder:boolean = false
@State buttonListInfo:buttonList[] = [
new buttonList(1,'置顶',$r('app.media.top')),
new buttonList(1,this.bookData.isTop?'取消置顶':'置顶',$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'))
Expand Down Expand Up @@ -90,25 +91,16 @@ export default struct BookInfoDialogs{
bookInfoButton(id:number){
switch (id){
case 1 :
showMessage(!this.bookData.isTop?'置顶':'取消置顶');
this.isFolderTop(); break;
this.isTopBook(); break;
case 2 :
showMessage('移动至'); break;
this.bookMoveGroup?.open(); break;
case 3 :
showMessage('加入书单'); break;
case 4 :
this.bookDelDialog?.open(); break;
}
}

isFolderTop(){
this.bookData.isTop = !this.bookData.isTop
this.buttonListInfo[0].title = this.bookData.isTop?'取消置顶':'置顶'
//刷新数组buttonListInfo
this.buttonListInfo = this.buttonListInfo.slice(0)
this.bookData.updateTime = Date.now()
}

@State delCache:boolean = false
//弹窗
bookDelDialog: CustomDialogController | null = new CustomDialogController({
Expand Down Expand Up @@ -142,4 +134,36 @@ export default struct BookInfoDialogs{
showMessage('删除成功')
}

async isTopBook(){
booksUtil.isTopBook(this.bookData.id || 0).then((val)=>{
val?showMessage(this.bookData.isTop?'置顶成功':'取消置顶成功'):showMessage('数据更新失败')
})
setTimeout(()=>{
this.controller?.close()
this.isBookRefreshing++
},500)
}

//移动分组
//弹窗
bookMoveGroup: CustomDialogController | null = new CustomDialogController({
builder: BookSelectGroupDialog({
moveGroup: ()=> {
this.bookMoveGroup?.close()
setTimeout(()=>{
this.isBookRefreshing++
},500)
},
currentIndex:this.bookData.bookType,
booId:this.bookData.id
}),
height: 400,
cancel: this.exitApp,
autoCancel: true,
alignment: DialogAlignment.Center,
gridCount: 4,
customStyle: false,
cornerRadius: 25,
})

}
Loading

0 comments on commit 6036f4b

Please sign in to comment.