feat: 整体页面优化,删除无用svg

This commit is contained in:
Blizzard
2026-02-14 08:32:47 +08:00
parent daea00ca60
commit cbbe82ef63
59 changed files with 1265 additions and 342 deletions
+32
View File
@@ -18,6 +18,7 @@ Page({
pageSize: 10,
isLoading: false,
hasMore: true,
scrollTop: 0,
// Modal State
showIdentifyModal: false
@@ -35,6 +36,10 @@ Page({
}
},
onTabItemTap() {
this.setData({ scrollTop: Math.random() * 0.01 });
},
// Fetch categories from API
fetchCategories() {
request.get('/wiki-class/list').then(res => {
@@ -84,6 +89,7 @@ Page({
genus: item.genus || '',
difficulty: item.difficulty || 0,
isHot: item.isHot === 1,
isFavorited: item.hasStar === 1,
image: (item.imgList && item.imgList.length > 0) ? item.imgList[0].url : '',
classes: (item.classes || []).map(c => c.name),
// Pass the full item for detail navigation
@@ -115,6 +121,31 @@ Page({
});
},
// Toggle Favorite
async toggleFavorite(e) {
const id = e.currentTarget.dataset.id;
const index = this.data.displayedList.findIndex(i => i.id === id);
if (index === -1) return;
const item = this.data.displayedList[index];
const type = item.isFavorited ? 2 : 1;
try {
// Attempting consistent API pattern
await request.get('/wiki/star', { id, type });
const key = `displayedList[${index}].isFavorited`;
this.setData({
[key]: !item.isFavorited
});
wx.showToast({ title: type === 1 ? '已收藏' : '已取消', icon: 'success' });
} catch (err) {
console.error('Toggle favorite failed', err);
wx.showToast({ title: '操作失败', icon: 'none' });
}
},
// Search Input Handler (debounced)
onSearchInput(e) {
const value = e.detail.value;
@@ -149,6 +180,7 @@ Page({
goToDetail(e) {
const item = e.currentTarget.dataset.item;
wx.navigateTo({
url: `/pages/wiki/detail/index?id=${item.id}`,
success: (res) => {