调整 发布

This commit is contained in:
浅念
2026-03-12 16:47:27 +08:00
parent 12bc0f8ba9
commit f892dbcb32
13 changed files with 536 additions and 111 deletions
+16 -4
View File
@@ -18,7 +18,7 @@
</template>
<script>
import { getVisibleTabBar, getCurrentTabIndex, getUserRole } from '@/common/tabbar.js'
import { getVisibleTabBar, getCurrentTabIndex } from '@/common/tabbar.js'
export default {
name: 'CustomTabBar',
@@ -27,19 +27,27 @@
current: 0,
safeAreaInsets: {
bottom: 0
}
},
forceUpdate: 0
}
},
computed: {
tabList() {
// 根据权限获取可见的 tabbar 列表
const userRole = getUserRole()
return getVisibleTabBar(userRole)
// 添加 forceUpdate 依赖,确保角色变化时重新计算
void this.forceUpdate
return getVisibleTabBar()
}
},
onLoad() {
this.updateCurrent()
this.initSafeArea()
// 监听角色变化事件
uni.$on('userRoleChanged', this.onRoleChanged)
},
onUnload() {
// 移除监听
uni.$off('userRoleChanged', this.onRoleChanged)
},
onShow() {
// 页面显示时更新当前 tab 索引
@@ -55,6 +63,10 @@
}
},
methods: {
// 角色变化时触发更新
onRoleChanged() {
this.forceUpdate++
},
initSafeArea() {
// 获取安全区域信息(适配 iPhone X 等)
// #ifdef APP-PLUS || H5