🎈 perf(尝试解决正式环境首次进入白屏问题):

This commit is contained in:
2022-12-06 14:33:39 +08:00
parent 3e7b70c190
commit ac56bfbd6d
3 changed files with 17 additions and 10 deletions
+3 -3
View File
@@ -61,7 +61,7 @@ const SideBar = ({
const getClassData = async(id) => {
const res = await fetchData({ id })
if (res.success) {
if (res.data?.list.length > 0) {
if (res.data?.list?.length > 0) {
res.data.list = [{ id: -1, name: '全部' }, ...res.data.list]
}
setClassList(() => res.data?.list)
@@ -130,8 +130,8 @@ const SideBar = ({
)
})}
</ScrollView>
<View className={styles.sideBar_con} style={{ paddingTop: classList.length > 0 ? '90rpx' : '20rpx' }}>
{classList.length > 0 && (
<View className={styles.sideBar_con} style={{ paddingTop: classList?.length > 0 ? '90rpx' : '20rpx' }}>
{classList?.length > 0 && (
<View className={styles.product_class} style={{ height: openClass ? '100%' : '' }}>
<ProductClass list={classList} open={openClass} onOpenClick={val => setOpenClass(val)} onSelect={getSelectClass} defaultSelectId={classId} />
</View>
+4 -4
View File
@@ -155,7 +155,7 @@ export const useRequest = (
data: stateRef.current.query,
}
: {
data: options.type?.toUpperCase() == 'FORMDATA' ? qs.stringify(stateRef.current.query) : stateRef.current.query,
data: options.type?.toUpperCase() == 'FORMDATA' ? qs.stringify(stateRef.current?.query) : stateRef.current.query,
}),
}
const result = await Taro.request(q as any)
@@ -181,14 +181,14 @@ export const useRequest = (
})
console.log('错误::', msg)
}
}
}
else {
if (statusCode === 401) {
removeToken()
removeSessionKey()
removeUserInfo()
login()
}
}
else {
Taro.showToast({
title: `错误:${showStatus(statusCode)}`,
@@ -196,7 +196,7 @@ export const useRequest = (
})
}
}
}
}
catch (e) {
stateRef.current.success = false
stateRef.current.error = true