陈剑华

fix: 17293 功能缺陷--已读的文章刷新后置灰状态被重置

... ... @@ -6,6 +6,7 @@ import { CardMediaInfo } from '../cardCommon/CardMediaInfo';
import { CardSourceInfo } from '../cardCommon/CardSourceInfo';
import { Notes } from './notes';
import { onlyWifiLoadImg } from '../../utils/lazyloadImg';
import { persistentStorage, hasClicked } from '../../utils/persistentStorage';
const TAG: string = 'Card2Component';
... ... @@ -24,6 +25,7 @@ export struct Card2Component {
async aboutToAppear(): Promise<void> {
this.loadImg = await onlyWifiLoadImg();
this.clicked = hasClicked(this.contentDTO.objectId)
}
build() {
... ... @@ -75,6 +77,7 @@ export struct Card2Component {
})
.onClick((event: ClickEvent) => {
this.clicked = true;
persistentStorage(this.contentDTO.objectId);
ProcessUtils.processPage(this.contentDTO)
})
}
... ...
... ... @@ -5,6 +5,7 @@ import { CardSourceInfo } from '../cardCommon/CardSourceInfo';
import { CardMediaInfo } from '../cardCommon/CardMediaInfo';
import { Notes } from './notes';
import { onlyWifiLoadImg } from '../../utils/lazyloadImg';
import { persistentStorage, hasClicked } from '../../utils/persistentStorage';
const TAG: string = 'Card6Component-Card13Component';
... ... @@ -19,6 +20,7 @@ export struct Card6Component {
async aboutToAppear(): Promise<void> {
this.loadImg = await onlyWifiLoadImg();
this.clicked = hasClicked(this.contentDTO.objectId)
}
build() {
... ... @@ -78,6 +80,7 @@ export struct Card6Component {
}
.onClick((event: ClickEvent) => {
this.clicked = true;
persistentStorage(this.contentDTO.objectId);
ProcessUtils.processPage(this.contentDTO)
})
.padding({
... ...
PersistentStorage.persistProp('clickedIds', []);
function persistentStorage(id: string | number, type: 'add' | 'remove' | undefined = 'add') {
let clickedIds = AppStorage.get<string>('clickedIds')?.split(',') || [];
let index = clickedIds.indexOf(id.toString())
if (type === 'add') {
if (index >= 0) return;
clickedIds.push(id.toString());
} else if (type === 'remove') {
clickedIds.splice(index, 1);
}
AppStorage.set('clickedIds', clickedIds.join(','));
}
function hasClicked(id: string | number) {
let clickedIds = AppStorage.get<string>('clickedIds')?.split(',') || [];
let index = clickedIds.indexOf(id.toString())
if (index >= 0) return true;
return false;
}
export { persistentStorage, hasClicked }
\ No newline at end of file
... ...