feat: 调整样式
This commit is contained in:
@@ -110,10 +110,20 @@ Page({
|
||||
const type = isFavorited ? 2 : 1;
|
||||
|
||||
request.get('/wiki/star', { id, type }).then(() => {
|
||||
const newStatus = !isFavorited;
|
||||
this.setData({
|
||||
'plant.isFavorited': !isFavorited
|
||||
'plant.isFavorited': newStatus
|
||||
});
|
||||
wx.showToast({ title: type === 1 ? '已收藏' : '已取消', icon: 'success' });
|
||||
|
||||
// Sync with previous page (Wiki List)
|
||||
const pages = getCurrentPages();
|
||||
if (pages.length > 1) {
|
||||
const prevPage = pages[pages.length - 2];
|
||||
if (prevPage.updateItemFavoriteStatus) {
|
||||
prevPage.updateItemFavoriteStatus(id, newStatus);
|
||||
}
|
||||
}
|
||||
}).catch(err => {
|
||||
console.error('Toggle favorite failed', err);
|
||||
wx.showToast({ title: '操作失败', icon: 'none' });
|
||||
|
||||
@@ -146,6 +146,16 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
updateItemFavoriteStatus(id, isFavorited) {
|
||||
const index = this.data.displayedList.findIndex(i => i.id == id);
|
||||
if (index === -1) return;
|
||||
|
||||
const key = `displayedList[${index}].isFavorited`;
|
||||
this.setData({
|
||||
[key]: isFavorited
|
||||
});
|
||||
},
|
||||
|
||||
// Search Input Handler (debounced)
|
||||
onSearchInput(e) {
|
||||
const value = e.detail.value;
|
||||
|
||||
Reference in New Issue
Block a user