- 自定义 tabBar(首页/管理/我的),悬浮胶囊样式,点击 switchTab 切换 - 首页按 ttstd_family_care 布局实现:设备概览、实时位置、最近截图、 今日使用时长、设备操作、常用功能 4 列网格 - 未接入功能统一 showTodo 占位提示,重启/关机保留二次确认 - 管理、我的为占位页,列出待迁移模块与设置项 - 移除模板页 pages/index、pages/logs 与 utils/util.ts - AGENTS.md 补充界面与交互约定、首页与 Tab 现状
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
interface TabItem {
|
|
pagePath: string
|
|
text: string
|
|
icon: string
|
|
}
|
|
|
|
Component({
|
|
data: {
|
|
selected: 0,
|
|
list: [
|
|
{ pagePath: '/pages/home/index', text: '首页', icon: 'home' },
|
|
{ pagePath: '/pages/manage/index', text: '管理', icon: 'grid' },
|
|
{ pagePath: '/pages/profile/index', text: '我的', icon: 'user' }
|
|
] as TabItem[]
|
|
},
|
|
lifetimes: {
|
|
/** 首次挂载时按当前路由选中,避免 from 默认 0 造成的高亮闪烁。 */
|
|
attached() {
|
|
const pages = getCurrentPages()
|
|
const current = pages[pages.length - 1] as unknown as
|
|
| { route?: string }
|
|
| undefined
|
|
if (!current || !current.route) return
|
|
const index = this.data.list.findIndex(
|
|
(item) => item.pagePath === `/${current.route}`
|
|
)
|
|
if (index >= 0 && index !== this.data.selected) {
|
|
this.setData({ selected: index })
|
|
}
|
|
}
|
|
},
|
|
methods: {
|
|
onTabTap(e: WechatMiniprogram.TouchEvent) {
|
|
const index = Number(e.currentTarget.dataset.index)
|
|
if (!Number.isInteger(index) || index === this.data.selected) return
|
|
const target = this.data.list[index]
|
|
if (!target) return
|
|
wx.switchTab({ url: target.pagePath })
|
|
}
|
|
}
|
|
})
|