feat: 首页跳转到分类页指定分类优化
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
import { NAV_INNER_PX } from '../../utils/navMetrics';
|
||||
import { parseMiniProgramUrl } from '../../utils/index';
|
||||
import {
|
||||
parseMiniProgramUrl,
|
||||
stashPendingCategoryTabId,
|
||||
} from '../../utils/index';
|
||||
import {
|
||||
HOME_CURRENT_CAPABILITY_DATA,
|
||||
type HomeDisplayItem,
|
||||
@@ -78,8 +81,13 @@ function navigateByPath(path?: string, fallbackTitle?: string) {
|
||||
const { path: basePath, query } = parseMiniProgramUrl(path);
|
||||
|
||||
if (TAB_BAR_PATHS.has(basePath)) {
|
||||
// tabBar 页面不支持携带 query/hash,统一跳到 basePath
|
||||
if (Object.keys(query).length > 0) {
|
||||
if (
|
||||
basePath === '/pages/category/category' &&
|
||||
query.id &&
|
||||
String(query.id).trim() !== ''
|
||||
) {
|
||||
stashPendingCategoryTabId(String(query.id).trim());
|
||||
} else if (Object.keys(query).length > 0) {
|
||||
console.warn(
|
||||
'[navigateByPath] tabBar 不支持携带参数,已忽略 query:',
|
||||
basePath,
|
||||
@@ -245,7 +253,7 @@ Page({
|
||||
},
|
||||
|
||||
onTapHotMore() {
|
||||
wx.showToast({ title: '热门内容整理中', icon: 'none' });
|
||||
navigateByPath('/pages/category/category?id=hot');
|
||||
},
|
||||
|
||||
onTapTrackMore(e: WechatMiniprogram.TouchEvent) {
|
||||
@@ -257,8 +265,7 @@ Page({
|
||||
onTapCard(e: WechatMiniprogram.CustomEvent) {
|
||||
const detail = (e.detail || {}) as { title?: string; path?: string };
|
||||
const path =
|
||||
detail.path ||
|
||||
(e.currentTarget.dataset.path as string | undefined);
|
||||
detail.path || (e.currentTarget.dataset.path as string | undefined);
|
||||
const title =
|
||||
detail.title ||
|
||||
(e.currentTarget.dataset.title as string | undefined);
|
||||
|
||||
Reference in New Issue
Block a user