import { Component, ReactNode } from 'react' import Taro from '@tarojs/taro'; import './nutui-theme.scss' import './app.scss' import { useDictionaryStore } from './store/dictionaryStore' import { useGlobalStore } from './store/global' import { check_login_status } from './services/loginService'; // import { getNavbarHeight } from "@/utils/getNavbarHeight"; interface AppProps { children: ReactNode } class App extends Component { onLaunch() { console.log('小程序启动,初始化逻辑写这里') // 已经登录过就跳转到 列表页 let is_login = check_login_status() if (is_login) { Taro.redirectTo({ url: '/pages/list/index' }) } } componentDidMount() { // 初始化字典数据 this.initDictionaryData() this.getNavBarHeight() } componentDidShow() { } componentDidHide() { } // 初始化字典数据 private async initDictionaryData() { try { const { fetchDictionary } = useDictionaryStore.getState() await fetchDictionary() } catch (error) { console.error('初始化字典数据失败:', error) } } // 获取导航高度 getNavBarHeight = () => { const { getNavbarHeightInfo } = useGlobalStore.getState() getNavbarHeightInfo() } render() { // this.props.children 是将要会渲染的页面 return this.props.children } } export default App