Skip to content

Commit

Permalink
Merge pull request #210 from mgz0227/dev_2008
Browse files Browse the repository at this point in the history
订阅源全部删除只留收藏夹
  • Loading branch information
MaoXiaoone authored Jul 20, 2024
2 parents 52f46ef + 402324c commit eab7647
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 40 deletions.
6 changes: 3 additions & 3 deletions entry/src/main/ets/database/dao/RssSourcesHistoryDao.ets
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class RssSourcesHistoryDao {
async deleteRssSourcesHistoryList(rssHistory: rssSourcesHistory[]) {
try {
for (let index = 0; index < rssHistory.length; index++) {
await this.deleteRssSourcesHistory(rssHistory[index])
await this.deleteRssSourcesHistory(rssHistory[index].sourceUrl)
}
return true
} catch (err) {
Expand All @@ -122,10 +122,10 @@ class RssSourcesHistoryDao {
}

//删除订阅源历史记录
async deleteRssSourcesHistory(rssHistory: rssSourcesHistory) {
async deleteRssSourcesHistory(rssHistoryUrl: string) {
try {
const predicates = DbUtil.getPredicates(this.TABLE_NAME);
predicates.equalTo('sourceUrl', rssHistory.sourceUrl)
predicates.equalTo('sourceUrl', rssHistoryUrl)
await DbUtil.delete(predicates)
return true
} catch (err) {
Expand Down
2 changes: 2 additions & 0 deletions entry/src/main/ets/database/dao/SubscriptionDao.ets
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import AppDatabaseUtil from '../AppDatabaseUtil';
import { rssSourceDb, rssSources, ToRssSources, ToRssSourcesDb } from '../entities/rssSources';
import { ColumnInfo } from '../types/ColumnInfo';
import { rssSourcesTypeParams } from '../types/rssSourcesType';
import rssSourcesHistoryDao from './RssSourcesHistoryDao';

class SubscriptionDao {
TABLE_NAME: string = 'rssSources'
Expand Down Expand Up @@ -165,6 +166,7 @@ class SubscriptionDao {
try {
const predicates = DbUtil.getPredicates(this.TABLE_NAME);
predicates.equalTo('sourceUrl', rssSource.sourceUrl)
rssSourcesHistoryDao.deleteRssSourcesHistory(rssSource.sourceUrl)
await DbUtil.delete(predicates)
return true
} catch (err) {
Expand Down
19 changes: 6 additions & 13 deletions entry/src/main/ets/pages/view/Subscription/SubscriptionIndex.ets
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* 新版订阅页面
*/
import CommonConstants from '../../../common/constants/CommonConstants'
import FontConstants from '../../../common/constants/FontConstants'
import ImageConstants from '../../../common/constants/ImageConstants'
import PaddingConstants from '../../../common/constants/PaddingConstants'
import { IconTitleVo } from '../../../componetsmodel/IconTitleVo'
Expand Down Expand Up @@ -142,18 +141,12 @@ export default struct SubscriptionIndex {
.justifyContent(FlexAlign.Center)
.layoutWeight(1)
} else if (!this.groupList.length) {
Column() {
Image($r('app.media.find_empty'))
.width(124)
.height(120)

Text(`暂无订阅源,点击右上角加号添加吧~`)
.fontSize(14)
.fontColor('#73000000')
.margin({ top: 32 })
}
.justifyContent(FlexAlign.Center)
.layoutWeight(1)
SubscriptionContent({
subscriptionTitle: '收藏',
showAddDialog:()=>{
this.isShowNewSources = true
}
})
} else {
Scroll(){
Column(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,14 @@ export default struct PreviewEffectImage{
.zIndex(9)
.fontColor(Color.White)
}
if (this.sourceIcon){
Image(this.sourceIcon.indexOf('app.media.')>-1?$r(this.sourceIcon):this.sourceIcon)
.width(this.PreviewWidth)
.height(this.PreviewHeight)
.animation(({
duration:1000
}))
.borderRadius(this.ImageRadius)
} else {
Image($r('app.media.icon'))
.width(this.PreviewWidth)
.height(this.PreviewHeight)
.animation(({
duration:1000
}))
.borderRadius(4)
}
Image(this.sourceIcon.indexOf('app.media.')>-1?$r(this.sourceIcon):this.sourceIcon)
.alt($r('app.media.icon'))
.width(this.PreviewWidth)
.height(this.PreviewHeight)
.animation(({
duration:1000
}))
.borderRadius(this.ImageRadius)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ export default struct SubscriptionContent{
// controller: web_webview.WebviewController = new web_webview.WebviewController()
refresh: () => void = () => {

}
showAddDialog:() => void=() => {

}
build() {
Column(){
Expand Down Expand Up @@ -101,6 +104,26 @@ export default struct SubscriptionContent{

})
}
if (this.contentList.length === 0 && this.subscriptionTitle === '收藏'){
Flex({
justifyContent:FlexAlign.Start
}){
Column(){
Image($r('app.media.icon_rule_add'))
.fillColor($r('app.string.color_black_45'))
.width(24)
.height(24)
.margin(10)
}
.align(Alignment.Start)
.justifyContent(FlexAlign.Center)
.borderRadius(10)
.backgroundColor($r('app.string.color_black_6'))
}
.onClick(()=>{
this.showAddDialog()
})
}

GridRow({
columns:2
Expand Down Expand Up @@ -385,14 +408,17 @@ export default struct SubscriptionContent{
direction:FlexDirection.Column
}){
ForEach(list, (item: IconTitleVo, index) => {
dialogTitleFuction({
title: item.title,
icon: item.icon,
isBorder: list.length !== index + 1
})
.onClick(() => {
dialogRightChange(index)
if (!(this.subscriptionTitle === '收藏' && item.title === '删除')){
dialogTitleFuction({
title: item.title,
icon: item.icon,
isBorder: list.length !== index + 1
})
.onClick(() => {
dialogRightChange(index)
})
}

})
}

Expand Down

0 comments on commit eab7647

Please sign in to comment.