Files
aiot-uniapp/src/App.vue
feige996 6f3d99402c fix(tabbar): 修复直接进入非首页时tabbar索引不正确的问题
添加 setAutoCurIdx 方法根据当前路径自动设置正确的 tabbar 索引
2025-08-13 20:15:08 +08:00

42 lines
1.0 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<script setup lang="ts">
import { onHide, onLaunch, onShow } from '@dcloudio/uni-app'
import { navigateToInterceptor } from '@/router/interceptor'
import { tabbarStore } from './tabbar/store'
import 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only'
onLaunch((options) => {
// 处理直接进入页面路由的情况如h5直接输入路由、微信小程序分享后进入等
// https://github.com/unibest-tech/unibest/issues/192
console.log('App Launch', options)
if (options?.path) {
navigateToInterceptor.invoke({ url: `/${options.path}` })
}
else {
navigateToInterceptor.invoke({ url: '/' })
}
// 处理直接进入路由非首页时tabbarIndex 不正确的问题
tabbarStore.setAutoCurIdx(options.path)
})
onShow((options) => {
console.log('App Show', options)
})
onHide(() => {
console.log('App Hide')
})
</script>
<style lang="scss">
swiper,
scroll-view {
flex: 1;
height: 100%;
overflow: hidden;
}
image {
width: 100%;
height: 100%;
vertical-align: middle;
}
</style>