feat: 首页查看更多

This commit is contained in:
R524809
2026-04-30 17:19:04 +08:00
parent 7126d3a941
commit 44182d011d
5 changed files with 65 additions and 14 deletions
+17 -5
View File
@@ -1,4 +1,5 @@
import { NAV_INNER_PX } from '../../utils/navMetrics';
import { parseMiniProgramUrl } from '../../utils/index';
import {
HOME_CURRENT_CAPABILITY_DATA,
type HomeDisplayItem,
@@ -35,6 +36,7 @@ const AGE_BAND_ICONS = ['🌱', '🚀', '🎓', '🧠', '🏆'] as const;
const SECTION_ANCHOR_PREFIX = 'section-';
const TAB_BAR_PATHS = new Set([
'/pages/home/home',
'/pages/category/category',
'/pages/age/age',
'/pages/favorites/favorites',
'/pages/profile/profile',
@@ -65,7 +67,6 @@ function sortSectionsByTabs(
}
function navigateByPath(path?: string, fallbackTitle?: string) {
console.log('path-----:', path);
if (!path) {
wx.showToast({
title: fallbackTitle ? `${fallbackTitle} 即将上线` : '即将上线',
@@ -74,12 +75,23 @@ function navigateByPath(path?: string, fallbackTitle?: string) {
return;
}
if (TAB_BAR_PATHS.has(path)) {
wx.switchTab({ url: path });
const { path: basePath, query } = parseMiniProgramUrl(path);
if (TAB_BAR_PATHS.has(basePath)) {
// tabBar 页面不支持携带 query/hash,统一跳到 basePath
if (Object.keys(query).length > 0) {
console.warn(
'[navigateByPath] tabBar 不支持携带参数,已忽略 query:',
basePath,
query,
);
}
wx.switchTab({ url: basePath });
return;
}
wx.navigateTo({ url: path });
wx.navigateTo({ url: path }).catch((err) => {
console.error('navigateByPath error:', err);
});
}
// ── Skeleton data ──