From 1d995b8c04406263b9359550baa70673780914f8 Mon Sep 17 00:00:00 2001 From: Marvin <63292605+yi-boide@users.noreply.github.com> Date: Sat, 27 Jul 2024 02:03:57 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=89=B9=E9=87=8F=E6=89=93=E5=88=86=20?= =?UTF-8?q?(#233)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: 批量打分 * feat: 批量打分 --- .../main/ets/database/dao/BookSourceDao.ets | 4 ++++ .../Find/BookSource/components/SourceView.ets | 21 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/entry/src/main/ets/database/dao/BookSourceDao.ets b/entry/src/main/ets/database/dao/BookSourceDao.ets index 7e217e0e..69b6341d 100644 --- a/entry/src/main/ets/database/dao/BookSourceDao.ets +++ b/entry/src/main/ets/database/dao/BookSourceDao.ets @@ -134,6 +134,7 @@ class BookSourceDao { const type = searchParams?.type; const enabled = searchParams?.enabled; const hasExploreUrl = searchParams?.hasExploreUrl; + const showExplore = searchParams?.showExplore; try { const column: ColumnInfo[] = AppDatabaseUtil.getColumn(this.TABLE_NAME); let sql = `SELECT * FROM book_sources`; @@ -148,6 +149,9 @@ class BookSourceDao { if (hasExploreUrl !== undefined) { whereClause.push(`COALESCE(exploreUrl, '') ${hasExploreUrl ? '<>' : '='} ''`); } + if (showExplore !== undefined) { + whereClause.push(`showExplore = ${showExplore ? 1 : 0}`); + } if (searchKey) { // 确保 searchKey 不为空或未定义 whereClause.push(`( bookSourceName LIKE '%${searchKey}%' diff --git a/entry/src/main/ets/pages/view/Find/BookSource/components/SourceView.ets b/entry/src/main/ets/pages/view/Find/BookSource/components/SourceView.ets index a996664b..630df8ba 100644 --- a/entry/src/main/ets/pages/view/Find/BookSource/components/SourceView.ets +++ b/entry/src/main/ets/pages/view/Find/BookSource/components/SourceView.ets @@ -69,6 +69,22 @@ export default struct SourceView { background: '#FF6600', fontColor: '#FFFFFF', action: async () => { + if (this.isBatch) { + const sourceList: BookSourcePart[] = [] + this.sourceList.forEach((item, i) => { + if (this.activeNameMap[item.bookSourceUrl]) { + item.bookSourceGrade = this.dialogItem.bookSourceGrade + item.bookSourceScore = this.dialogItem.bookSourceScore + sourceList.push(item) + } + }) + await BookSourceDao.batchUpdateFlow(sourceList) + this.getList() + this.activeNameMap = {} + this.dialogController.close() + this.dialogItem = {} + return + } await BookSourceDao.updateFlow(this.dialogItem as BookSourcePart) this.getList() this.dialogItem = {} @@ -382,6 +398,11 @@ export default struct SourceView { this.isShowGroup = true; break; case 1: + if (!Object.values(this.activeNameMap).filter(o => o).length) { + showMessage('请至少选择一个') + return + } + this.dialogItem = this.sourceList.filter(item => this.activeNameMap[item.bookSourceUrl])[0] this.dialogController.open() break; case 2: