feat: 预加载优化、nav-bar 箭头居中优化

This commit is contained in:
R524809
2026-05-26 11:20:36 +08:00
parent fbdad6e02b
commit 824e83c887
9 changed files with 75 additions and 14 deletions
+10 -2
View File
@@ -60,11 +60,19 @@
"preloadRule": { "preloadRule": {
"pages/home/home": { "pages/home/home": {
"network": "all", "network": "all",
"packages": ["mathPages", "focusPages"] "packages": ["mathPages", "pinyinPages", "chinesePages"]
}, },
"pages/category/category": { "pages/category/category": {
"network": "all", "network": "all",
"packages": ["focusPages", "englishPages"] "packages": ["focusPages", "englishPages", "chinesePages"]
},
"pages/age/age": {
"network": "all",
"packages": ["focusPages", "englishPages", "pinyinPages"]
},
"pages/favorites/favorites": {
"network": "all",
"packages": ["focusPages", "mathPages", "chinesePages"]
}, },
"pages/profile/profile": { "pages/profile/profile": {
"network": "all", "network": "all",
@@ -63,6 +63,7 @@
font-size: 40rpx; font-size: 40rpx;
color: @color-nav-title; color: @color-nav-title;
line-height: 1; line-height: 1;
margin-top: 4rpx;
} }
.nav-bar__title { .nav-bar__title {
@@ -85,4 +86,4 @@
.nav-bar__placeholder { .nav-bar__placeholder {
width: 100%; width: 100%;
flex-shrink: 0; flex-shrink: 0;
} }
@@ -54,7 +54,8 @@ Component({
}, },
methods: { methods: {
onTap() { onTap() {
this.triggerEvent('tap', { // 使用 cardtap 避免与原生 tap 同名,防止安卓上父级 bindtap 重复触发 navigateTo
this.triggerEvent('cardtap', {
title: this.data.title, title: this.data.title,
path: this.data.path, path: this.data.path,
}); });
@@ -2,7 +2,7 @@
class="worksheet-card worksheet-card--{{variant}}" class="worksheet-card worksheet-card--{{variant}}"
hover-class="worksheet-card--active" hover-class="worksheet-card--active"
hover-stay-time="100" hover-stay-time="100"
bindtap="onTap"> catchtap="onTap">
<block wx:if="{{variant === 'track'}}"> <block wx:if="{{variant === 'track'}}">
<view class="worksheet-card__top"> <view class="worksheet-card__top">
<image <image
+22 -3
View File
@@ -19,7 +19,15 @@ const TAB_BAR_PATHS = new Set([
'/pages/profile/profile', '/pages/profile/profile',
]); ]);
let _navigating = false;
function releaseNavigateLock() {
_navigating = false;
}
function navigateByPath(path?: string, fallbackTitle?: string) { function navigateByPath(path?: string, fallbackTitle?: string) {
if (_navigating) return;
const p = String(path || '').trim(); const p = String(path || '').trim();
if (!p) { if (!p) {
wx.showToast({ wx.showToast({
@@ -37,11 +45,22 @@ function navigateByPath(path?: string, fallbackTitle?: string) {
query, query,
); );
} }
wx.switchTab({ url: basePath }); _navigating = true;
wx.switchTab({
url: basePath,
complete: releaseNavigateLock,
fail: releaseNavigateLock,
});
return; return;
} }
wx.navigateTo({ url: p }).catch((err) => { _navigating = true;
console.error('navigateByPath error:', err); wx.navigateTo({
url: p,
complete: releaseNavigateLock,
fail: (err) => {
console.error('navigateByPath error:', err);
releaseNavigateLock();
},
}); });
} }
+1 -1
View File
@@ -116,7 +116,7 @@
path="{{item.path}}" path="{{item.path}}"
data-title="{{item.title}}" data-title="{{item.title}}"
data-path="{{item.path}}" data-path="{{item.path}}"
bindtap="onTapCard" bind:cardtap="onTapCard"
/> />
</view> </view>
</view> </view>
+14 -1
View File
@@ -158,6 +158,8 @@ function formatDateKey(date: Date): string {
} }
Page({ Page({
_navigating: false,
data: { data: {
favScrollHeight: 0, favScrollHeight: 0,
activeTab: 'favorites' as FavoritesTab, activeTab: 'favorites' as FavoritesTab,
@@ -240,12 +242,23 @@ Page({
}, },
onCardTap(e: WechatMiniprogram.TouchEvent) { onCardTap(e: WechatMiniprogram.TouchEvent) {
if (this._navigating) return;
const path = e.currentTarget.dataset.path as string | undefined; const path = e.currentTarget.dataset.path as string | undefined;
if (!path) { if (!path) {
wx.showToast({ title: '该练习已下架', icon: 'none' }); wx.showToast({ title: '该练习已下架', icon: 'none' });
return; return;
} }
wx.navigateTo({ url: path }); this._navigating = true;
wx.navigateTo({
url: path,
complete: () => {
this._navigating = false;
},
fail: () => {
this._navigating = false;
},
});
}, },
onSearchTap() { onSearchTap() {
+22 -3
View File
@@ -71,7 +71,15 @@ function sortSectionsByTabs(
})); }));
} }
let _navigating = false;
function releaseNavigateLock() {
_navigating = false;
}
function navigateByPath(path?: string, fallbackTitle?: string) { function navigateByPath(path?: string, fallbackTitle?: string) {
if (_navigating) return;
if (!path) { if (!path) {
wx.showToast({ wx.showToast({
title: fallbackTitle ? `${fallbackTitle} 即将上线` : '即将上线', title: fallbackTitle ? `${fallbackTitle} 即将上线` : '即将上线',
@@ -96,11 +104,22 @@ function navigateByPath(path?: string, fallbackTitle?: string) {
query, query,
); );
} }
wx.switchTab({ url: basePath }); _navigating = true;
wx.switchTab({
url: basePath,
complete: releaseNavigateLock,
fail: releaseNavigateLock,
});
return; return;
} }
wx.navigateTo({ url: path }).catch((err) => { _navigating = true;
console.error('navigateByPath error:', err); wx.navigateTo({
url: path,
complete: releaseNavigateLock,
fail: (err) => {
console.error('navigateByPath error:', err);
releaseNavigateLock();
},
}); });
} }
+1 -1
View File
@@ -248,7 +248,7 @@
path="{{item.path}}" path="{{item.path}}"
data-title="{{item.title}}" data-title="{{item.title}}"
data-path="{{item.path}}" data-path="{{item.path}}"
bindtap="onTapCard" /> bind:cardtap="onTapCard" />
</view> </view>
</scroll-view> </scroll-view>
</view> </view>