From 0d923b88f890edcaecf8c2ec9cdabf9c3fdad666 Mon Sep 17 00:00:00 2001 From: 2008 <59199830@qq.com> Date: Fri, 19 Jul 2024 14:44:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9A=E5=AF=BC=E5=85=A5=E6=88=96=E6=9B=B4?= =?UTF-8?q?=E6=96=B024=E5=B0=8F=E6=97=B6=E5=86=85=E8=AE=A2=E9=98=85?= =?UTF-8?q?=E6=BA=90=E7=BA=A2=E7=82=B9=E8=BF=9B=E8=A1=8C=E6=A0=87=E8=AE=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 刚导入或更新24小时内订阅源红点进行标记 --- .../main/ets/database/AppDatabase/index.ets | 20 ++++++- .../main/ets/database/dao/SubscriptionDao.ets | 21 ++++++- .../main/ets/database/entities/rssSources.ets | 58 ++++++++++--------- .../ets/database/entities/rssSourcesPart.ets | 2 + .../Subscription/RssSources/newSources.ets | 5 +- .../RssSources/newSourcesNetWork.ets | 3 +- .../components/SubscriptionContent.ets | 47 ++++++++++++--- .../pages/view/Subscription/rssWebView.ets | 1 - 8 files changed, 117 insertions(+), 40 deletions(-) diff --git a/entry/src/main/ets/database/AppDatabase/index.ets b/entry/src/main/ets/database/AppDatabase/index.ets index b0a66311..945773a3 100644 --- a/entry/src/main/ets/database/AppDatabase/index.ets +++ b/entry/src/main/ets/database/AppDatabase/index.ets @@ -1001,7 +1001,7 @@ export default { }, { "tableName": "rssSources", - "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`sourceType` INTEGER NOT NULL ,`sourceUrl` TEXT NOT NULL, `sourceName` TEXT NOT NULL, `sourceIcon` TEXT NOT NULL, `sourceGroup` TEXT, `sourceComment` TEXT, `enabled` INTEGER NOT NULL, `variableComment` TEXT, `jsLib` TEXT, `enabledCookieJar` INTEGER DEFAULT 0, `concurrentRate` TEXT, `header` TEXT, `loginUrl` TEXT, `loginUi` TEXT, `loginCheckJs` TEXT, `coverDecodeJs` TEXT, `sortUrl` TEXT, `singleUrl` INTEGER NOT NULL, `articleStyle` INTEGER NOT NULL DEFAULT 0, `ruleArticles` TEXT, `ruleNextPage` TEXT, `ruleTitle` TEXT, `rulePubDate` TEXT, `ruleDescription` TEXT, `ruleImage` TEXT, `ruleLink` TEXT, `ruleContent` TEXT, `contentWhitelist` TEXT, `contentBlacklist` TEXT, `shouldOverrideUrlLoading` TEXT, `style` TEXT, `enableJs` INTEGER NOT NULL DEFAULT 1, `loadWithBaseUrl` INTEGER NOT NULL DEFAULT 1, `injectJs` TEXT, `lastUpdateTime` INTEGER NOT NULL DEFAULT 0, `customOrder` INTEGER NOT NULL DEFAULT 0, PRIMARY KEY(`sourceUrl`))", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`sourceType` INTEGER NOT NULL ,`sourceUrl` TEXT NOT NULL, `sourceName` TEXT NOT NULL, `sourceIcon` TEXT NOT NULL, `sourceGroup` TEXT, `sourceComment` TEXT, `enabled` INTEGER NOT NULL, `variableComment` TEXT, `jsLib` TEXT, `enabledCookieJar` INTEGER DEFAULT 0, `concurrentRate` TEXT, `header` TEXT, `loginUrl` TEXT, `loginUi` TEXT, `loginCheckJs` TEXT, `coverDecodeJs` TEXT, `sortUrl` TEXT, `singleUrl` INTEGER NOT NULL, `articleStyle` INTEGER NOT NULL DEFAULT 0, `ruleArticles` TEXT, `ruleNextPage` TEXT, `ruleTitle` TEXT, `rulePubDate` TEXT, `ruleDescription` TEXT, `ruleImage` TEXT, `ruleLink` TEXT, `ruleContent` TEXT, `contentWhitelist` TEXT, `contentBlacklist` TEXT, `shouldOverrideUrlLoading` TEXT, `style` TEXT, `enableJs` INTEGER NOT NULL DEFAULT 1, `loadWithBaseUrl` INTEGER NOT NULL DEFAULT 1, `injectJs` TEXT, `lastUpdateTime` INTEGER NOT NULL DEFAULT 0,`variable` TEXT, `sourceIconIsUrl` INTEGER ,`showRecentIcon` INTEGER NOT NULL DEFAULT 1, `customOrder` INTEGER NOT NULL DEFAULT 0, PRIMARY KEY(`sourceUrl`))", "fields": [ { "fieldPath": "sourceType", @@ -1212,6 +1212,24 @@ export default { "affinity": "TEXT", "notNull": false }, + { + "fieldPath": "sourceIconIsUrl", + "columnName": "sourceIconIsUrl", + "affinity": "INTEGER" + }, + { + "fieldPath": "variable", + "columnName": "variable", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "showRecentIcon", + "columnName": "showRecentIcon", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "1" + }, { "fieldPath": "lastUpdateTime", "columnName": "lastUpdateTime", diff --git a/entry/src/main/ets/database/dao/SubscriptionDao.ets b/entry/src/main/ets/database/dao/SubscriptionDao.ets index 26cfffd7..e06b8e04 100644 --- a/entry/src/main/ets/database/dao/SubscriptionDao.ets +++ b/entry/src/main/ets/database/dao/SubscriptionDao.ets @@ -118,10 +118,12 @@ class SubscriptionDao { if (rssSource instanceof rssSources) { const rssSourceDb = ToRssSourcesDb(rssSource) rssSourceDb.lastUpdateTime = Date.now() + rssSourceDb.showRecentIcon = true await DbUtil.update(predicates, rssSourceDb, column) return true } rssSource.lastUpdateTime = Date.now() + rssSource.showRecentIcon = true const columnPart: ColumnInfo[] = this.getFlowColumn().slice(0, -2) await DbUtil.update(predicates, rssSource, columnPart) return true @@ -132,6 +134,23 @@ class SubscriptionDao { } + async updateRecentIcon(rssSource: rssSources) { + try { + const column: ColumnInfo[] = AppDatabaseUtil.getColumn(this.TABLE_NAME); + const predicates = DbUtil.getPredicates(this.TABLE_NAME); + predicates.equalTo('sourceUrl', rssSource.sourceUrl) + const rssSourceDb = ToRssSourcesDb(rssSource) + rssSourceDb.showRecentIcon = false + await DbUtil.update(predicates, rssSourceDb, column) + return true + } catch (err) { + console.log('TagInfo, Error, ', JSON.stringify(err)) + return false + } + + } + + async getRssSources(key: string): Promise { try { const column: ColumnInfo[] = AppDatabaseUtil.getColumn(this.TABLE_NAME); @@ -152,7 +171,7 @@ class SubscriptionDao { getFlowColumn() { const column: ColumnInfo[] = AppDatabaseUtil.getAssignColumn(this.TABLE_NAME, ['sourceName', 'sourceUrl', 'sourceGroup', 'sourceGroup', 'enabled', 'variableComment', - 'sortUrl', 'singleUrl', 'lastUpdateTime','customOrder','variable','sourceType']); + 'sortUrl', 'singleUrl', 'lastUpdateTime','customOrder','variable','sourceType','showRecentIcon',]); return column; } } diff --git a/entry/src/main/ets/database/entities/rssSources.ets b/entry/src/main/ets/database/entities/rssSources.ets index 1ad5707f..5f414437 100644 --- a/entry/src/main/ets/database/entities/rssSources.ets +++ b/entry/src/main/ets/database/entities/rssSources.ets @@ -56,6 +56,8 @@ export class rssSources{ customOrder:number = 0 //设置源变量 variable?:string + //是否新增或则更新点击过 + showRecentIcon:boolean = true //自动补全 autoComplete:boolean = true //列表 @@ -155,6 +157,7 @@ export const ToRssSources = (rssSourceDb: rssSourceDb) => { customOrder: rssSourceDb.customOrder, variable: rssSourceDb.variable, autoComplete: rssSourceDb.autoComplete, + showRecentIcon:rssSourceDb.showRecentIcon, rssListRule, rssWebViewRule } @@ -162,34 +165,35 @@ export const ToRssSources = (rssSourceDb: rssSourceDb) => { } -export const ToRssSourcesDb = (rssSourceDb: rssSources) => { - const rssListRule = GSON.toString(rssSourceDb.rssListRule); - const rssWebViewRule = GSON.toString(rssSourceDb.rssWebViewRule); +export const ToRssSourcesDb = (rssSource: rssSources) => { + const rssListRule = GSON.toString(rssSource.rssListRule); + const rssWebViewRule = GSON.toString(rssSource.rssWebViewRule); const rssSourcesDb: rssSourceDb = { - sourceType: rssSourceDb.sourceType, - sourceName: rssSourceDb.sourceName, - sourceUrl: rssSourceDb.sourceUrl, - sourceIcon: rssSourceDb.sourceIcon, - sourceIconIsUrl: rssSourceDb.sourceIconIsUrl, - sourceGroup: rssSourceDb.sourceGroup, - sourceComment: rssSourceDb.sourceComment, - enabled: rssSourceDb.enabled, - variableComment: rssSourceDb.variableComment, - jsLib: rssSourceDb.jsLib, - enabledCookieJar: rssSourceDb.enabledCookieJar, - concurrentRate: rssSourceDb.concurrentRate, - header: rssSourceDb.header, - loginUrl: rssSourceDb.loginUrl, - loginUi: rssSourceDb.loginUi, - loginCheckJs: rssSourceDb.loginCheckJs, - coverDecodeJs: rssSourceDb.coverDecodeJs, - sortUrl: rssSourceDb.sortUrl, - singleUrl: rssSourceDb.singleUrl, - articleStyle: rssSourceDb.articleStyle, - lastUpdateTime: rssSourceDb.lastUpdateTime, - customOrder: rssSourceDb.customOrder, - variable: rssSourceDb.variable, - autoComplete: rssSourceDb.autoComplete, + sourceType: rssSource.sourceType, + sourceName: rssSource.sourceName, + sourceUrl: rssSource.sourceUrl, + sourceIcon: rssSource.sourceIcon, + sourceIconIsUrl: rssSource.sourceIconIsUrl, + sourceGroup: rssSource.sourceGroup, + sourceComment: rssSource.sourceComment, + enabled: rssSource.enabled, + variableComment: rssSource.variableComment, + jsLib: rssSource.jsLib, + enabledCookieJar: rssSource.enabledCookieJar, + concurrentRate: rssSource.concurrentRate, + header: rssSource.header, + loginUrl: rssSource.loginUrl, + loginUi: rssSource.loginUi, + loginCheckJs: rssSource.loginCheckJs, + coverDecodeJs: rssSource.coverDecodeJs, + sortUrl: rssSource.sortUrl, + singleUrl: rssSource.singleUrl, + articleStyle: rssSource.articleStyle, + lastUpdateTime: rssSource.lastUpdateTime, + customOrder: rssSource.customOrder, + variable: rssSource.variable, + autoComplete: rssSource.autoComplete, + showRecentIcon: rssSource.showRecentIcon, rssListRule, rssWebViewRule } diff --git a/entry/src/main/ets/database/entities/rssSourcesPart.ets b/entry/src/main/ets/database/entities/rssSourcesPart.ets index 3e6fb7ea..bc14ab74 100644 --- a/entry/src/main/ets/database/entities/rssSourcesPart.ets +++ b/entry/src/main/ets/database/entities/rssSourcesPart.ets @@ -29,6 +29,8 @@ export class rssSourcesPart { variable?:string //订阅源类型0.常规网站 1.订阅源 sourceType?: number = 1 + + showRecentIcon:boolean = true } diff --git a/entry/src/main/ets/pages/view/Subscription/RssSources/newSources.ets b/entry/src/main/ets/pages/view/Subscription/RssSources/newSources.ets index c04bc5a1..991d4730 100644 --- a/entry/src/main/ets/pages/view/Subscription/RssSources/newSources.ets +++ b/entry/src/main/ets/pages/view/Subscription/RssSources/newSources.ets @@ -11,6 +11,8 @@ import { showMessage } from '../../../../componets/common/promptShow' import FormItem from '../../../../componets/Form/FormItem' import SubscriptionDao from '../../../../database/dao/SubscriptionDao' import { rssSources, SUBSCRIPTION_GROUP_TYPE } from '../../../../database/entities/rssSources' +import { rssListRule } from '../../../../database/entities/rule/rssListRule' +import { rssWebViewRule } from '../../../../database/entities/rule/rssWebViewRule' import programDataPreferences from '../../../../preferences/programDataPreferences' @Component @@ -122,7 +124,8 @@ export default struct newSources{ autoComplete: false, sourceGroup: SUBSCRIPTION_GROUP_TYPE[0], enabled: true, - singleUrl: true + singleUrl: true, + showRecentIcon: true } @State sourceGroupList:SelectOption[] = [] diff --git a/entry/src/main/ets/pages/view/Subscription/RssSources/newSourcesNetWork.ets b/entry/src/main/ets/pages/view/Subscription/RssSources/newSourcesNetWork.ets index ca8d13da..b1401838 100644 --- a/entry/src/main/ets/pages/view/Subscription/RssSources/newSourcesNetWork.ets +++ b/entry/src/main/ets/pages/view/Subscription/RssSources/newSourcesNetWork.ets @@ -69,7 +69,8 @@ export default struct newSourcesNetWork{ autoComplete: false, sourceGroup: SUBSCRIPTION_GROUP_TYPE[0], enabled: true, - singleUrl: true + singleUrl: true, + showRecentIcon: true } @Builder baseForm() { 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 79b469d9..4054e33b 100644 --- a/entry/src/main/ets/pages/view/Subscription/components/SubscriptionContent.ets +++ b/entry/src/main/ets/pages/view/Subscription/components/SubscriptionContent.ets @@ -15,6 +15,7 @@ import { showMessage } from '../../../../componets/common/promptShow' import newSourcesNetWork from '../RssSources/newSourcesNetWork' import newSources from '../RssSources/newSources' import { router } from '@kit.ArkUI' +import SubscriptionDao from '../../../../database/dao/SubscriptionDao' @Component export default struct SubscriptionContent{ @@ -107,12 +108,14 @@ export default struct SubscriptionContent{ this.contentCoverBuilder(item) } .onClick(()=>{ + SubscriptionDao.updateRecentIcon(item) router.pushUrl({ url: 'pages/view/Subscription/rssWebView', params: { url: item.sourceUrl } }) + this.refresh() }) .gesture( LongPressGesture({ repeat: true,duration:1000 }) @@ -142,12 +145,14 @@ export default struct SubscriptionContent{ this.contentListBuilder(item) } .onClick(()=>{ + SubscriptionDao.updateRecentIcon(item) router.pushUrl({ url: 'pages/view/Subscription/rssWebView', params: { url: item.sourceUrl } }) + this.refresh() }) .gesture( LongPressGesture({ repeat: true,duration:500 }) @@ -261,10 +266,21 @@ export default struct SubscriptionContent{ // .width(ImageConstants.IMG_WIDTH_24) // .height(ImageConstants.IMG_HEIGHT_24) // .borderRadius(4) - Image($r('app.media.icon')) - .width(ImageConstants.IMG_WIDTH_40) - .height(ImageConstants.IMG_HEIGHT_40) - .borderRadius(4) + Stack(){ + Image($r('app.media.icon')) + .width(ImageConstants.IMG_WIDTH_40) + .height(ImageConstants.IMG_HEIGHT_40) + .borderRadius(4) + + if (this.isShowRecentIcon(item.lastUpdateTime) && item.showRecentIcon) + Row().width(8).height(8) + .borderRadius(8) + .backgroundColor('#EF4444') + .position({ + right: -2, + top:-2 + }) + }.alignContent(Alignment.TopEnd) Text(item.sourceName) .font({ size:14, @@ -281,6 +297,10 @@ export default struct SubscriptionContent{ .padding(PaddingConstants.PADDING_12) } + //刚导入的24小时内以红点进行标记,24小时后消失,或者手动点击该订阅查看后也会消失 + isShowRecentIcon(lastTime:number){ + return (new Date().getTime() - lastTime)/(1000 * 60 * 60) <= 24 + } @Builder contentListBuilder(item:rssSources){ @@ -291,10 +311,21 @@ export default struct SubscriptionContent{ // .width(ImageConstants.IMG_WIDTH_40) // .height(ImageConstants.IMG_HEIGHT_40) // .borderRadius(8) - Image($r('app.media.icon')) - .width(ImageConstants.IMG_WIDTH_40) - .height(ImageConstants.IMG_HEIGHT_40) - .borderRadius(4) + Stack(){ + Image($r('app.media.icon')) + .width(ImageConstants.IMG_WIDTH_40) + .height(ImageConstants.IMG_HEIGHT_40) + .borderRadius(4) + + if (this.isShowRecentIcon(item.lastUpdateTime) && item.showRecentIcon) + Row().width(8).height(8) + .borderRadius(8) + .backgroundColor('#EF4444') + .position({ + right: -2, + top:-2 + }) + }.alignContent(Alignment.TopEnd) Text(`${item.sourceName}`).fontSize(10) .fontColor($r('app.string.color_black_88')) diff --git a/entry/src/main/ets/pages/view/Subscription/rssWebView.ets b/entry/src/main/ets/pages/view/Subscription/rssWebView.ets index 69e44f2d..2ee0e7e9 100644 --- a/entry/src/main/ets/pages/view/Subscription/rssWebView.ets +++ b/entry/src/main/ets/pages/view/Subscription/rssWebView.ets @@ -16,7 +16,6 @@ struct RssWebView { aboutToAppear(): void { const params = router.getParams() as RouteParams; this.sourcesUrl = params.url - showMessage(this.sourcesUrl) } build() {