From 4938b660f7a52ee9cabe561d9cef9601294ce557 Mon Sep 17 00:00:00 2001 From: Marvin <63292605+yi-boide@users.noreply.github.com> Date: Sun, 21 Jul 2024 03:09:33 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=8F=91=E7=8E=B0=20=E7=AD=9B=E9=80=89?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=EF=BC=8C=E7=BD=AE=E9=A1=B6=EF=BC=8C=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=EF=BC=8C=E9=9A=90=E8=97=8F=20(#213)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ets/componets/source/SourceCommon.ets | 44 +++--- .../main/ets/componets/source/SourceView.ets | 101 +++++++++++-- .../main/ets/database/AppDatabase/index.ets | 18 ++- .../main/ets/database/dao/BookSourceDao.ets | 62 +++++--- .../main/ets/database/entities/BookSource.ets | 140 ++++-------------- .../ets/database/entities/BookSourcePart.ets | 5 +- .../view/Find/BookSource/AddSourcePage.ets | 6 +- .../Find/BookSource/components/SourceView.ets | 8 +- .../view/Find/components/BodyContent.ets | 12 +- .../pages/view/Find/components/CardItem.ets | 2 +- .../view/Find/components/ContentRefresh.ets | 13 +- entry/src/main/ets/storage/findData.ets | 8 + 12 files changed, 240 insertions(+), 179 deletions(-) diff --git a/entry/src/main/ets/componets/source/SourceCommon.ets b/entry/src/main/ets/componets/source/SourceCommon.ets index f1ac00d4..da2d6fee 100644 --- a/entry/src/main/ets/componets/source/SourceCommon.ets +++ b/entry/src/main/ets/componets/source/SourceCommon.ets @@ -8,7 +8,6 @@ import ImageConstants from '../../common/constants/ImageConstants' import PaddingConstants from '../../common/constants/PaddingConstants' import { IconTitleVo } from '../../componetsmodel/IconTitleVo' import dialogTitleFuction from '../common/dialogTitleFuction' -import noSourceFind from '../common/noSourceFind' import { showMessage } from '../common/promptShow' import { dataItem } from '../dataList/dataItem' import { sourceTabs } from './sourceTabs' @@ -29,6 +28,7 @@ export default struct SourceCommon { @State showMoreDialog: boolean = false @State searchValue: string = '' @State isBatch: boolean = false + @Link refreshCount: number changeSourceIndex() { this.sourceController.changeIndex(this.readIndex) @@ -49,7 +49,6 @@ export default struct SourceCommon { .width('90%') .onChange((value: string) => { this.searchValue = value - // this.getList() }) Image($r('app.media.more_vertical')) @@ -105,27 +104,22 @@ export default struct SourceCommon { barPosition: BarPosition.Start, controller: this.sourceController }) { - TabContent() { - SourceView({ - searchValue: this.searchValue, - isBatch: this.isBatch, - type: this.currentIndex, - index: 0 - }) - } - .height('100%') - .align(Alignment.Top) - - TabContent() { - SourceView({ - searchValue: this.searchValue, - isBatch: this.isBatch, - type: this.currentIndex, - index: 1 - }) - } - .height('100%') - .align(Alignment.Top) + ForEach([0, 1], (item: number) => { + TabContent() { + SourceView({ + searchValue: this.searchValue, + isBatch: this.isBatch, + type: this.currentIndex, + index: item, + refreshCount: this.refreshCount, + closeDialog: () => { + this.showDialog = false + } + }) + } + .height('100%') + .align(Alignment.Top) + }) } .barWidth(0) .barHeight(0) @@ -141,10 +135,10 @@ export default struct SourceCommon { } More_Right_Dialog_Data: IconTitleVo[] = [ - new IconTitleVo($r('app.media.ic_folder'), '按时间排序'), + new IconTitleVo($r('app.media.appointment_time'), '按时间排序'), new IconTitleVo($r('app.media.icon_no_source_find'), '按评分排序'), new IconTitleVo($r('app.media.add_book_shelf'), '书源管理'), - new IconTitleVo($r('app.media.icon_rule_batch'), '批量'), + new IconTitleVo($r('app.media.icon_rule_batch'), '批量管理'), ] @Builder diff --git a/entry/src/main/ets/componets/source/SourceView.ets b/entry/src/main/ets/componets/source/SourceView.ets index ced08234..751d3c3d 100644 --- a/entry/src/main/ets/componets/source/SourceView.ets +++ b/entry/src/main/ets/componets/source/SourceView.ets @@ -9,6 +9,8 @@ import { showMessage } from '../common/promptShow' import Score from '../common/Score' import SideBar from '../common/SideBar' import Tag from '../common/Tag' +import { router } from '@kit.ArkUI' +import noFind from '../common/noFind' @Component export default struct SourceView { @@ -17,7 +19,7 @@ export default struct SourceView { titleArray: Array = ['小说', '漫画', '有声书'] index: number = 0 type: number = 0 - @Link searchValue: string + @Link @Watch('getList') searchValue: string @State activeNameMap: Record = {} @State fullActive: boolean = false @State groupList: GroupPartList[] = [] @@ -27,6 +29,10 @@ export default struct SourceView { @Link isBatch: boolean @State showRightDialogMap: Record = {} @State currentIndex: number = 0 + @State topToggle: boolean = false + @Link @Watch('getList') refreshCount: number + closeDialog: () => void = () => { + } private scroll: Scroller = new Scroller() private secondScroll = new Scroller() @@ -185,22 +191,47 @@ export default struct SourceView { Row() { Row() { Column() { - Text('置顶') + Text(this.topToggle ? '取消置顶' : '置顶') .fontSize(16) } .layoutWeight(1) - .onClick(() => { - showMessage('置顶') + .onClick(async () => { + if (!Object.values(this.activeNameMap).filter(o => o).length) { + showMessage('请至少选择一个') + return + } + this.sourceList.forEach((item, i) => { + if (this.activeNameMap[item.bookSourceUrl]) { + item.isTop = !this.topToggle + this.sourceList[i] = item + } + }) + await BookSourceDao.batchUpdateFlow(this.sourceList) + this.activeNameMap = {} + this.refreshCount += 1 + this.topToggle = !this.topToggle }) Row().width(12) Column() { - Text('隐藏') + Text(this.index === 0 ? '隐藏' : '显示') .fontSize(16) } .layoutWeight(1) .onClick(async () => { - showMessage('隐藏') + if (!Object.values(this.activeNameMap).filter(o => o).length) { + showMessage('请至少选择一个') + return + } + this.sourceList.forEach((item, i) => { + if (this.activeNameMap[item.bookSourceUrl]) { + item.enabled = this.index !== 0 + this.sourceList[i] = item + } + }) + await BookSourceDao.batchUpdateFlow(this.sourceList) + this.activeNameMap = {} + this.refreshCount += 1 }) } .padding({ @@ -219,6 +250,30 @@ export default struct SourceView { duration: 500 }) .padding({ bottom: this.bottomRectHeight }) + + Column() { + if (this.loading) { + LoadingProgress() + .color(0xff6600) + .width('50%') + Text('加载中...') + } else if (this.errorText) { + noFind() + } else if (!this.sourceList.length) { + noFind({ + hintIndex: 0 + }) + } + } + .justifyContent(FlexAlign.Center) + .zIndex(this.loading || (this.errorText && !this.sourceList.length) ? 9 : -1) + .opacity(this.loading || (this.errorText && !this.sourceList.length) ? 1 : 0) + .width('100%') + .height('100%') + .backgroundColor('#f5f5f5') + .animation({ + duration: 300 + }) } .alignContent(Alignment.Top) } @@ -295,15 +350,38 @@ export default struct SourceView { .width(24).fillColor('#73000000') .bindMenu( this.showRightDialogMap[item.bookSourceUrl], - this.rightDialogBuilder(this.Item_Right_Dialog_Data, async (index: number) => { + this.rightDialogBuilder(this.Item_Right_Dialog_Data.map((itemData, index) => { + if (index === 1) { + itemData.title = item.isTop ? '取消置顶' : '置顶' + } + if (index === 3) { + itemData.title = item.enabled ? '隐藏' : '显示' + } + return itemData + }), async (index: number) => { switch (index) { case 0: + this.closeDialog() + router.pushUrl({ + url: 'pages/view/Find/BookSource/AddSourcePage', params: { + id: item.bookSourceUrl + } + }) + break; case 1: + item.isTop = !item.isTop + this.showRightDialogMap[item.bookSourceUrl] = false + await BookSourceDao.updateFlow(item) + this.refreshCount += 1 case 2: - case 3: - case 4: showMessage(this.Item_Right_Dialog_Data[index].title) break; + case 3: + item.enabled = !item.enabled + this.showRightDialogMap[item.bookSourceUrl] = false + await BookSourceDao.updateFlow(item) + this.refreshCount += 1 + break; } }), { @@ -364,10 +442,9 @@ export default struct SourceView { Item_Right_Dialog_Data: IconTitleVo[] = [ new IconTitleVo($r('app.media.edit'), '编辑'), - new IconTitleVo($r('app.media.icon_no_source_find'), '置顶'), + new IconTitleVo($r('app.media.top'), '置顶'), new IconTitleVo($r('app.media.search'), '搜索'), - new IconTitleVo($r('app.media.ic_logout'), '登录'), - new IconTitleVo($r('app.media.icon_rule_help'), '取消收藏'), + new IconTitleVo($r('app.media.ic_logout'), '显示'), ] @Builder diff --git a/entry/src/main/ets/database/AppDatabase/index.ets b/entry/src/main/ets/database/AppDatabase/index.ets index e84bd2c0..e4976a47 100644 --- a/entry/src/main/ets/database/AppDatabase/index.ets +++ b/entry/src/main/ets/database/AppDatabase/index.ets @@ -297,7 +297,7 @@ export default { }, { "tableName": "book_sources", - "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`bookSourceUrl` TEXT NOT NULL, `bookSourceName` TEXT NOT NULL, `bookSourceGroup` TEXT, `bookSourceType` INTEGER NOT NULL, `bookUrlPattern` TEXT, `bookSourceGrade` INTEGER NOT NULL DEFAULT 2, `bookSourceScore` TEXT NOT NULL DEFAULT `5.0分`, `customOrder` INTEGER NOT NULL DEFAULT 0, `enabled` INTEGER NOT NULL DEFAULT 1, `enabledExplore` INTEGER NOT NULL DEFAULT 1, `jsLib` TEXT, `enabledCookieJar` INTEGER DEFAULT 0, `concurrentRate` TEXT, `header` TEXT, `loginUrl` TEXT, `loginUi` TEXT, `loginCheckJs` TEXT, `coverDecodeJs` TEXT, `bookSourceComment` TEXT, `variableComment` TEXT, `lastUpdateTime` INTEGER NOT NULL, `respondTime` INTEGER NOT NULL, `weight` INTEGER NOT NULL, `exploreUrl` TEXT, `exploreScreen` TEXT, `ruleExplore` TEXT, `searchUrl` TEXT, `ruleSearch` TEXT, `ruleBookInfo` TEXT, `ruleToc` TEXT, `ruleContent` TEXT, `ruleReview` TEXT, PRIMARY KEY(`bookSourceUrl`))", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`bookSourceUrl` TEXT NOT NULL, `bookSourceName` TEXT NOT NULL, `bookSourceGroup` TEXT, `bookSourceType` INTEGER NOT NULL, `bookUrlPattern` TEXT, `bookSourceGrade` INTEGER NOT NULL DEFAULT 2, `isTop` INTEGER NOT NULL DEFAULT 0, `showRecentIcon` INTEGER NOT NULL DEFAULT 1, `bookSourceScore` TEXT NOT NULL DEFAULT `5.0分`, `customOrder` INTEGER NOT NULL DEFAULT 0, `enabled` INTEGER NOT NULL DEFAULT 1, `enabledExplore` INTEGER NOT NULL DEFAULT 1, `jsLib` TEXT, `enabledCookieJar` INTEGER DEFAULT 0, `concurrentRate` TEXT, `header` TEXT, `loginUrl` TEXT, `loginUi` TEXT, `loginCheckJs` TEXT, `coverDecodeJs` TEXT, `bookSourceComment` TEXT, `variableComment` TEXT, `lastUpdateTime` INTEGER NOT NULL, `respondTime` INTEGER NOT NULL, `weight` INTEGER NOT NULL, `exploreUrl` TEXT, `exploreScreen` TEXT, `ruleExplore` TEXT, `searchUrl` TEXT, `ruleSearch` TEXT, `ruleBookInfo` TEXT, `ruleToc` TEXT, `ruleContent` TEXT, `ruleReview` TEXT, PRIMARY KEY(`bookSourceUrl`))", "fields": [ { "fieldPath": "bookSourceUrl", @@ -497,6 +497,22 @@ export default { "columnName": "ruleReview", "affinity": "TEXT", "notNull": false + }, + { + "fieldPath": "isTop", + "columnName": "isTop", + "affinity": "INTEGER", + "boolean": true, + "notNull": true, + "defaultValue": "0" + }, + { + "fieldPath": "showRecentIcon", + "columnName": "showRecentIcon", + "affinity": "INTEGER", + "boolean": true, + "notNull": true, + "defaultValue": "1" } ], "primaryKey": { diff --git a/entry/src/main/ets/database/dao/BookSourceDao.ets b/entry/src/main/ets/database/dao/BookSourceDao.ets index 7b4175f8..33bd2a65 100644 --- a/entry/src/main/ets/database/dao/BookSourceDao.ets +++ b/entry/src/main/ets/database/dao/BookSourceDao.ets @@ -1,5 +1,5 @@ import { ColumnInfo, ColumnType } from '../types/ColumnInfo'; -import { BookSource, BookSourceDb, ToBookSource, ToBookSourceDb } from '../entities/BookSource'; +import { BookSource, BookSourceDb, ToBookSource, ToBookSourceDb, ToBookSourcePart } from '../entities/BookSource'; import AppDatabaseUtil from '../AppDatabaseUtil' import { JSON } from '@kit.ArkTS'; import DbUtil from '../../common/utils/DbUtil'; @@ -27,7 +27,7 @@ class BookSourceDao { getFlowColumn() { const column: ColumnInfo[] = AppDatabaseUtil.getAssignColumn(this.TABLE_NAME, ['bookSourceUrl', 'bookSourceName', 'bookSourceGroup', 'bookSourceGrade', 'bookSourceScore', 'customOrder', - 'enabled', 'enabledExplore', 'lastUpdateTime', 'respondTime', 'weight']); + 'enabled', 'enabledExplore', 'lastUpdateTime', 'respondTime', 'weight', 'isTop', 'showRecentIcon']); column.push(...[ { name: 'hasLoginUrl', @@ -46,7 +46,7 @@ class BookSourceDao { async flowAll(): Promise { try { const sql = `select bookSourceUrl, bookSourceName, bookSourceGroup, bookSourceGrade, bookSourceScore, customOrder, enabled, enabledExplore, - trim(loginUrl) <> '' hasLoginUrl, lastUpdateTime, respondTime, weight, trim(exploreUrl) <> '' hasExploreUrl + trim(loginUrl) <> '' hasLoginUrl, lastUpdateTime, respondTime, weight, trim(exploreUrl) <> '' hasExploreUrl, isTop, showRecentIcon from book_sources order by customOrder asc` const column: ColumnInfo[] = this.getFlowColumn() return await DbUtil.querySqlForList(sql, column) @@ -77,7 +77,9 @@ class BookSourceDao { lastUpdateTime, respondTime, weight, - trim(exploreUrl) <> '' AS hasExploreUrl + trim(exploreUrl) <> '' AS hasExploreUrl, + isTop, + showRecentIcon FROM book_sources `; @@ -112,7 +114,7 @@ class BookSourceDao { sql += ` ORDER BY - customOrder ASC + isTop DESC, customOrder ASC `; const column: ColumnInfo[] = this.getFlowColumn() return await DbUtil.querySqlForList(sql, column) @@ -157,7 +159,7 @@ class BookSourceDao { sql += ` ORDER BY - customOrder ASC + isTop DESC, customOrder ASC `; const bookSourceDbList = await DbUtil.querySqlForList(sql, column); const bookSourceList = bookSourceDbList.map((item): BookSource => ToBookSource(item)); @@ -177,6 +179,9 @@ class BookSourceDao { const bookSourceDbList = await DbUtil.queryForList(predicates, column); const bookSourceList = bookSourceDbList.map((item): BookSource => ToBookSource(item)); if (bookSourceList.length > 0) { + if (bookSourceList[0].showRecentIcon) { + this.updateRecentIcon(ToBookSourcePart(bookSourceList[0])) + } return bookSourceList[0] } return null @@ -220,25 +225,33 @@ class BookSourceDao { } } - async update(bookSource: BookSource | BookSourcePart) { + async updateFlow(bookSource: BookSourcePart) { + try { + const predicates = DbUtil.getPredicates(this.TABLE_NAME); + predicates.equalTo('bookSourceUrl', bookSource.bookSourceUrl) + bookSource.lastUpdateTime = Date.now() + const columnPart: ColumnInfo[] = this.getFlowColumn().slice(0, -2) + await DbUtil.update(predicates, bookSource, columnPart) + return true + } catch (err) { + console.log('TagInfo, Error, ', JSON.stringify(err)) + return false + } + } + + async update(bookSource: BookSource) { try { const column: ColumnInfo[] = AppDatabaseUtil.getColumn(this.TABLE_NAME); const predicates = DbUtil.getPredicates(this.TABLE_NAME); predicates.equalTo('bookSourceUrl', bookSource.bookSourceUrl) const count = await DbUtil.queryForCount(predicates, column) - if (count === 0 && bookSource instanceof BookSource) { + if (count === 0) { this.insert(bookSource) return true } - if (bookSource instanceof BookSource) { - const bookSourceDb = ToBookSourceDb(bookSource) - bookSourceDb.lastUpdateTime = Date.now() - await DbUtil.update(predicates, bookSourceDb, column) - return true - } - bookSource.lastUpdateTime = Date.now() - const columnPart: ColumnInfo[] = this.getFlowColumn().slice(0, -2) - await DbUtil.update(predicates, bookSource, columnPart) + const bookSourceDb = ToBookSourceDb(bookSource) + bookSourceDb.lastUpdateTime = Date.now() + await DbUtil.update(predicates, bookSourceDb, column) return true } catch (err) { console.log('TagInfo, Error, ', JSON.stringify(err)) @@ -246,11 +259,11 @@ class BookSourceDao { } } - async batchUpdate(bookSources: BookSource[] | BookSourcePart[]) { + async batchUpdateFlow(bookSources: BookSourcePart[]) { try { for (let index = 0; index < bookSources.length; index++) { const bookSource = bookSources[index]; - await this.update(bookSource) + await this.updateFlow(bookSource) } return true } catch (err) { @@ -259,6 +272,17 @@ class BookSourceDao { } } + async updateRecentIcon(bookSources: BookSourcePart) { + try { + bookSources.showRecentIcon = false + this.updateFlow(bookSources) + return true + } catch (err) { + console.log('TagInfo, Error, ', JSON.stringify(err)) + return false + } + } + async delete(key: string) { try { const predicates = DbUtil.getPredicates(this.TABLE_NAME); diff --git a/entry/src/main/ets/database/entities/BookSource.ets b/entry/src/main/ets/database/entities/BookSource.ets index d122b968..4426f1f2 100644 --- a/entry/src/main/ets/database/entities/BookSource.ets +++ b/entry/src/main/ets/database/entities/BookSource.ets @@ -2,88 +2,6 @@ import { GSON } from '../../common/utils/utils' import { BookSourcePart } from './BookSourcePart' import { BookInfoRule, ContentRule, ExploreRule, ReviewRule, SearchRule, TocRule } from './rule' -// class BaseBookSource { -// // 地址,包括 http/https -// bookSourceUrl: string = "" -// // 名称 -// bookSourceName: string = "" -// // 分组 -// bookSourceGroup?: string -// // 类型,0 文本,1 音频, 2 图片, 3 文件(指的是类似知轩藏书只提供下载的网站) -// bookSourceType: number = 0 -// bookSourceGrade?: number = 2 -// bookSourceScore?: string -// // 详情页url正则 -// bookUrlPattern?: string -// // 手动排序编号 -// customOrder: number = 0 -// // 是否启用 -// enabled: boolean = true -// // 启用发现 -// enabledExplore: boolean = true -// // js库 -// jsLib?: String -// // 启用okhttp CookieJAr 自动保存每次请求的cookie -// enabledCookieJar?: boolean = true -// // 并发率 -// concurrentRate?: string -// // 请求头 -// header?: string -// // 登录地址 -// loginUrl?: string -// // 登录UI -// loginUi?: string -// // 登录检测js -// loginCheckJs?: string -// // 封面解密js -// coverDecodeJs?: string -// // 注释 -// bookSourceComment?: string -// // 自定义变量说明 -// variableComment?: string -// // 最后更新时间,用于排序 -// lastUpdateTime: number = 0 -// // 响应时间,用于排序 -// respondTime: number = 180000 -// // 智能排序的权重 -// weight: number = 0 -// // 发现url -// exploreUrl?: string -// // 发现筛选规则 -// exploreScreen?: string -// // 搜索url -// searchUrl?: string -// -// constructor(bookSource: Partial) { -// this.bookSourceUrl = bookSource.bookSourceUrl || ""; -// this.bookSourceName = bookSource.bookSourceName || ""; -// this.bookSourceGroup = bookSource.bookSourceGroup; -// this.bookSourceType = bookSource.bookSourceType ?? 0; -// this.bookSourceGrade = bookSource.bookSourceGrade; -// this.bookSourceScore = bookSource.bookSourceScore; -// this.bookUrlPattern = bookSource.bookUrlPattern; -// this.customOrder = bookSource.customOrder ?? 0; -// this.enabled = bookSource.enabled ?? true; -// this.enabledExplore = bookSource.enabledExplore ?? true; -// this.jsLib = bookSource.jsLib; -// this.enabledCookieJar = bookSource.enabledCookieJar ?? true; -// this.concurrentRate = bookSource.concurrentRate; -// this.header = bookSource.header; -// this.loginUrl = bookSource.loginUrl; -// this.loginUi = bookSource.loginUi; -// this.loginCheckJs = bookSource.loginCheckJs; -// this.coverDecodeJs = bookSource.coverDecodeJs; -// this.bookSourceComment = bookSource.bookSourceComment; -// this.variableComment = bookSource.variableComment; -// this.lastUpdateTime = bookSource.lastUpdateTime ?? 0; -// this.respondTime = bookSource.respondTime ?? 180000; -// this.weight = bookSource.weight ?? 0; -// this.exploreUrl = bookSource.exploreUrl; -// this.exploreScreen = bookSource.exploreScreen; -// this.searchUrl = bookSource.searchUrl; -// } -// } - @Observed export class BookSource { // 地址,包括 http/https @@ -148,35 +66,10 @@ export class BookSource { ruleContent?: ContentRule // 段评规则 ruleReview?: ReviewRule - - // constructor(bookSource: Partial) { - // this.bookSourceUrl = bookSource.bookSourceUrl || ""; - // this.bookSourceName = bookSource.bookSourceName || ""; - // this.bookSourceGroup = bookSource.bookSourceGroup; - // this.bookSourceType = bookSource.bookSourceType ?? 0; - // this.bookSourceGrade = bookSource.bookSourceGrade; - // this.bookSourceScore = bookSource.bookSourceScore; - // this.bookUrlPattern = bookSource.bookUrlPattern; - // this.customOrder = bookSource.customOrder ?? 0; - // this.enabled = bookSource.enabled ?? true; - // this.enabledExplore = bookSource.enabledExplore ?? true; - // this.jsLib = bookSource.jsLib; - // this.enabledCookieJar = bookSource.enabledCookieJar ?? true; - // this.concurrentRate = bookSource.concurrentRate; - // this.header = bookSource.header; - // this.loginUrl = bookSource.loginUrl; - // this.loginUi = bookSource.loginUi; - // this.loginCheckJs = bookSource.loginCheckJs; - // this.coverDecodeJs = bookSource.coverDecodeJs; - // this.bookSourceComment = bookSource.bookSourceComment; - // this.variableComment = bookSource.variableComment; - // this.lastUpdateTime = bookSource.lastUpdateTime ?? 0; - // this.respondTime = bookSource.respondTime ?? 180000; - // this.weight = bookSource.weight ?? 0; - // this.exploreUrl = bookSource.exploreUrl; - // this.exploreScreen = bookSource.exploreScreen; - // this.searchUrl = bookSource.searchUrl; - // } + // 是否置顶 + isTop: boolean = false + //是否新增或则更新点击过 + showRecentIcon: boolean = true } export interface GroupList { @@ -251,6 +144,8 @@ export const ToBookSource = (bookSourceDb: BookSourceDb) => { exploreUrl: bookSourceDb.exploreUrl, exploreScreen: bookSourceDb.exploreScreen, searchUrl: bookSourceDb.searchUrl, + isTop: bookSourceDb.isTop, + showRecentIcon: bookSourceDb.showRecentIcon, ruleExplore, ruleSearch, ruleBookInfo, @@ -295,6 +190,8 @@ export const ToBookSourceDb = (bookSource: BookSource) => { exploreUrl: bookSource.exploreUrl, exploreScreen: bookSource.exploreScreen, searchUrl: bookSource.searchUrl, + isTop: bookSource.isTop, + showRecentIcon: bookSource.showRecentIcon, ruleExplore, ruleSearch, ruleBookInfo, @@ -303,4 +200,25 @@ export const ToBookSourceDb = (bookSource: BookSource) => { ruleReview } return bookSourceDb +} + +export const ToBookSourcePart = (bookSource: BookSource) => { + const bookSourcePart: BookSourcePart = { + bookSourceUrl: bookSource.bookSourceUrl, + bookSourceName: bookSource.bookSourceName, + bookSourceGroup: bookSource.bookSourceGroup, + bookSourceGrade: bookSource.bookSourceGrade, + bookSourceScore: bookSource.bookSourceScore, + customOrder: bookSource.customOrder, + enabled: bookSource.enabled, + enabledExplore: bookSource.enabledExplore, + lastUpdateTime: bookSource.lastUpdateTime, + respondTime: bookSource.respondTime, + weight: bookSource.weight, + isTop: bookSource.isTop, + showRecentIcon: bookSource.showRecentIcon, + hasLoginUrl: false, + hasExploreUrl: false + } + return bookSourcePart } \ No newline at end of file diff --git a/entry/src/main/ets/database/entities/BookSourcePart.ets b/entry/src/main/ets/database/entities/BookSourcePart.ets index 4c230fa5..dc181bb0 100644 --- a/entry/src/main/ets/database/entities/BookSourcePart.ets +++ b/entry/src/main/ets/database/entities/BookSourcePart.ets @@ -1,4 +1,3 @@ - @Observed export class BookSourcePart { // 地址,包括 http/https @@ -25,4 +24,8 @@ export class BookSourcePart { weight: number = 0 // 是否有发现url hasExploreUrl: boolean = false + // 是否置顶 + isTop: boolean = false + //是否新增或则更新点击过 + showRecentIcon: boolean = true } \ No newline at end of file diff --git a/entry/src/main/ets/pages/view/Find/BookSource/AddSourcePage.ets b/entry/src/main/ets/pages/view/Find/BookSource/AddSourcePage.ets index b8d20adc..b28a3e07 100644 --- a/entry/src/main/ets/pages/view/Find/BookSource/AddSourcePage.ets +++ b/entry/src/main/ets/pages/view/Find/BookSource/AddSourcePage.ets @@ -46,13 +46,16 @@ struct AddSourcePage { lastUpdateTime: 0, respondTime: 180000, customOrder: 0, - weight: 0 + weight: 0, + isTop: false, + showRecentIcon: false } async aboutToAppear() { const params = router.getParams() as RouteParams; console.log('TagInfo', JSON.stringify(params)) const localItem = await BookSourceDao.getBookSource(params.id) + console.info('TagInfo :', JSON.stringify(localItem)) if (localItem) { this.formModel = localItem } @@ -168,6 +171,7 @@ struct AddSourcePage { this.scroller.scrollEdge(Edge.Top) showMessage('红星标记的内容不能为空') } + console.info('TagInfo 修改的数据:', JSON.stringify(this.formModel)) await BookSourceDao.insert(this.formModel) showMessage('保存成功') setTimeout(() => { 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 b7987f5f..9b48b659 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 @@ -66,7 +66,7 @@ export default struct SourceView { background: '#FF6600', fontColor: '#FFFFFF', action: async () => { - await BookSourceDao.update(this.dialogItem as BookSourcePart) + await BookSourceDao.updateFlow(this.dialogItem as BookSourcePart) this.getList() this.dialogItem = {} this.dialogController.close() @@ -305,7 +305,7 @@ export default struct SourceView { this.sourceList[i] = item } }) - await BookSourceDao.batchUpdate(this.sourceList) + await BookSourceDao.batchUpdateFlow(this.sourceList) this.getList() }) @@ -434,7 +434,7 @@ export default struct SourceView { .onClick(async () => { this.isBatch = false this.activeNameMap = {} - BookSourceDao.batchUpdate(this.sourceList) + BookSourceDao.batchUpdateFlow(this.sourceList) this.getList() }) } @@ -674,7 +674,7 @@ export default struct SourceView { .selectedColor(0xff6600) .onChange(async (val: boolean) => { item.enabled = val - await BookSourceDao.update(item) + await BookSourceDao.updateFlow(item) }) } .width('100%') diff --git a/entry/src/main/ets/pages/view/Find/components/BodyContent.ets b/entry/src/main/ets/pages/view/Find/components/BodyContent.ets index 0cba6c3a..540b238d 100644 --- a/entry/src/main/ets/pages/view/Find/components/BodyContent.ets +++ b/entry/src/main/ets/pages/view/Find/components/BodyContent.ets @@ -4,7 +4,6 @@ * @className: BodyContent */ import CommonConstants from '../../../../common/constants/CommonConstants' -import { showMessage } from '../../../../componets/common/promptShow' import sourceType from '../../../../componets/common/sourceType' import SourceCommon from '../../../../componets/source/SourceCommon' import BookSourceDao from '../../../../database/dao/BookSourceDao' @@ -21,11 +20,16 @@ export default struct BodyContent { @Prop currentIndex: number @StorageLink(CommonConstants.HAS_EXPLORE_URL) @Watch('getList') hasExploreUrl?: boolean = undefined tabsBodyController: TabsController = new TabsController(); + @State @Watch('getList')refreshCount: number = 0 aboutToAppear() { this.getList() } + onPageShow() { + this.getList() + } + getList() { this.loading = true BookSourceDao.search({ @@ -135,7 +139,8 @@ export default struct BodyContent { ContentRefresh({ currentIndex: this.currentIndex, bookSource: item, - hasExploreUrl: this.hasExploreUrl + hasExploreUrl: this.hasExploreUrl, + refreshCount: this.refreshCount }) } .height('100%') @@ -160,7 +165,8 @@ export default struct BodyContent { Column() { SourceCommon({ showDialog: this.isShowDialog, - currentIndex: this.currentIndex + currentIndex: this.currentIndex, + refreshCount: this.refreshCount }) }.height('100%') } diff --git a/entry/src/main/ets/pages/view/Find/components/CardItem.ets b/entry/src/main/ets/pages/view/Find/components/CardItem.ets index c205b45a..840944e4 100644 --- a/entry/src/main/ets/pages/view/Find/components/CardItem.ets +++ b/entry/src/main/ets/pages/view/Find/components/CardItem.ets @@ -8,13 +8,13 @@ export struct CardItem { build() { Row() { Image(this.item.coverUrl ?? $r('app.media.no_record')) + .alt($r('app.media.find_empty')) .width(63) .height(84) .objectFit(ImageFit.Contain) .borderRadius(4) .margin({ right: 12 }) - Column() { Text(this.item.name) .fontSize(16) diff --git a/entry/src/main/ets/pages/view/Find/components/ContentRefresh.ets b/entry/src/main/ets/pages/view/Find/components/ContentRefresh.ets index c2f22f32..262a43a4 100644 --- a/entry/src/main/ets/pages/view/Find/components/ContentRefresh.ets +++ b/entry/src/main/ets/pages/view/Find/components/ContentRefresh.ets @@ -11,6 +11,7 @@ import AllCategory, { GroupExploreList } from './AllCategory' @Component export default struct ContentRefresh { @StorageLink('bottomRectHeight') bottomRectHeight: number = 0 + @Link @Watch('onRefresh')refreshCount: number currentIndex: number = 0 @Prop bookSource: BookSource = { bookSourceUrl: '', @@ -21,7 +22,9 @@ export default struct ContentRefresh { enabledExplore: false, lastUpdateTime: 0, respondTime: 0, - weight: 0 + weight: 0, + isTop: false, + showRecentIcon: false } @State isRefreshing: boolean = false @State RefreshingTitle: string = '松开刷新' @@ -36,6 +39,14 @@ export default struct ContentRefresh { @State showSheet: boolean = false aboutToAppear() { + this.getList() + } + + onRefresh() { + setTimeout(this.getList, 500) + } + + getList () { try { this.exploreRule = this.bookSource.ruleExplore console.info('TagInfo: 书源地址:', this.bookSource.bookSourceUrl) diff --git a/entry/src/main/ets/storage/findData.ets b/entry/src/main/ets/storage/findData.ets index bc595db9..48a8aec2 100644 --- a/entry/src/main/ets/storage/findData.ets +++ b/entry/src/main/ets/storage/findData.ets @@ -2,4 +2,12 @@ import CommonConstants from '../common/constants/CommonConstants' export const initFindData = () => { AppStorage.setOrCreate(CommonConstants.HAS_EXPLORE_URL, true) +} + +const initSourceList = async () => { + +} + +const initSourcePartList = async () => { + } \ No newline at end of file