陈剑华

feat: 17492 功能缺陷-【uat】进入精选评论卡,点击点赞,未变成已点赞

// 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
PersistentStorage.persistProp('clickedIds', []);
function persistentStorage(id: string | number, type: 'add' | 'remove' | undefined = 'add') {
let _clickedIds = AppStorage.get<string[]>('clickedIds');
let clickedIds = _clickedIds?.toString()?.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
... ...