首次提交

This commit is contained in:
2025-04-13 19:40:44 +08:00
commit eec6aef7d7
440 changed files with 44422 additions and 0 deletions

49
src/app.ts Normal file
View File

@@ -0,0 +1,49 @@
import {useEffect} from 'react'
import Taro, { useDidShow, useDidHide } from '@tarojs/taro'
// 全局样式
import './app.scss'
import {loginByOpenId} from "@/api/layout";
import {TenantId} from "@/utils/config";
import {saveStorageByLoginUser} from "@/utils/server";
function App(props) {
const reload = () => {
// 根据openid无感登录
if (!Taro.getStorageSync('access_token')) {
Taro.login({
success: (res) => {
loginByOpenId({
code: res.code,
tenantId: TenantId
}).then(data => {
if(data){
saveStorageByLoginUser(data.access_token, data.user)
}
})
}
})
}
};
// 可以使用所有的 React Hooks
useEffect(() => {
// Taro.getSetting获取用户的当前设置。返回值中只会出现小程序已经向用户请求过的权限。
Taro.getSetting({
success: (res) => {
if (res.authSetting['scope.userInfo']) {
reload();
}
}
});
}, []);
// 对应 onShow
useDidShow(() => {})
// 对应 onHide
useDidHide(() => {})
return props.children
}
export default App