Files
sundynix-pets/pets-fe/custom-tab-bar/index.js
T
Blizzard b49bf0f0f9 feat(fe): 隐藏社区 tab(只留首页/报告/我的)+ 别人主页关注粉丝不可再点开
- custom-tab-bar 去掉社区入口(页面与 app.json 注册保留,加回一行即可恢复)
- profile-head 新增 relationsClickable,别人主页传 false:从关注/粉丝列表进对方
  主页后,对方的关注/粉丝数字只展示不可点开,避免无限套娃;「我的」页不受影响

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-04 09:51:09 +08:00

36 lines
1.3 KiB
JavaScript

// 社区 tab 暂时下线:从这里去掉入口即可(页面与 app.json 里的注册都保留,
// 需要恢复时把社区那行加回来就行)
const LIST = [
{ pagePath: '/pages/home/home', text: '首页', icon: 'home' },
{ pagePath: '/pages/report/report', text: '报告', icon: 'report' },
// { pagePath: '/pages/community/community', text: '社区', icon: 'community' },
{ pagePath: '/pages/mine/mine', text: '我的', icon: 'user' },
];
Component({
data: { selected: 0, hidden: false, list: LIST },
lifetimes: {
attached() {
this.syncSelected();
},
},
methods: {
// 高亮由当前页面路径算出来,页面那边不写死 0/1/2/3/4,
// 调 tab 顺序只改上面的 LIST 就够了。
//
// 触发时机必须由页面 onShow 推(见 utils/tabbar.js):自定义 tabBar 不在
// 页面节点树里,组件自己的 pageLifetimes.show 拿不到可靠时机,实测切到
// 「我的」时高亮还留在「首页」。
syncSelected() {
const pages = getCurrentPages();
const cur = pages[pages.length - 1];
if (!cur) return;
const i = LIST.findIndex((t) => t.pagePath === '/' + cur.route);
if (i >= 0) this.setData({ selected: i });
},
switchTab(e) {
wx.switchTab({ url: LIST[e.currentTarget.dataset.index].pagePath });
},
},
});