Files
mini-programs/src/app.ts
2025-09-14 01:18:23 +08:00

58 lines
1.3 KiB
TypeScript

import { Component, ReactNode } from "react";
import "./nutui-theme.scss";
import "./app.scss";
import "qweather-icons/font/qweather-icons.css";
import { useDictionaryStore } from "./store/dictionaryStore";
import { useGlobalStore } from "./store/global";
interface AppProps {
children: ReactNode;
}
class App extends Component<AppProps> {
onLaunch(options) {
console.log('launch options: ', options)
console.log("小程序启动,初始化逻辑写这里");
}
componentDidMount() {
// 初始化字典数据
this.initDictionaryData();
this.getNavBarHeight();
// this.getLocation()
}
componentDidShow() {}
componentDidHide() {}
// 初始化字典数据
private async initDictionaryData() {
try {
const { fetchDictionary } = useDictionaryStore.getState();
await fetchDictionary();
} catch (error) {
console.error("初始化字典数据失败:", error);
}
}
// 获取导航高度
getNavBarHeight = () => {
const { getNavbarHeightInfo } = useGlobalStore.getState();
getNavbarHeightInfo();
};
// 获取位置信息
// getLocation = () => {
// const { getCurrentLocationInfo } = useGlobalStore.getState()
// getCurrentLocationInfo()
// }
render() {
// this.props.children 是将要会渲染的页面
return this.props.children;
}
}
export default App;