🌈 style(eslint): add eslint rules
This commit is contained in:
@@ -1,20 +1,21 @@
|
||||
import { ScrollView, View } from '@tarojs/components'
|
||||
import React, { memo, ReactNode, useMemo, useState } from 'react'
|
||||
import type { ReactNode } from 'react'
|
||||
import React, { memo, useMemo, useState } from 'react'
|
||||
import LoadingCard from '../loadingCard'
|
||||
import style from './index.module.scss'
|
||||
import DotLoading from '@/components/dotLoading'
|
||||
import LoadingCard from '../loadingCard'
|
||||
import Empty from '@/components/empty'
|
||||
import { EMPTY_IMAGE, SEARCH_EMPTY_IMAGE } from '@/common/constant'
|
||||
|
||||
export type StatusParam = 0 | 1 | 2 | 3
|
||||
|
||||
type Params = {
|
||||
interface Params {
|
||||
styleObj?: React.CSSProperties
|
||||
selfonScrollToLower?: () => void
|
||||
enableLoadMoreStatus?: boolean
|
||||
safeAreaInsetBottom?: boolean
|
||||
moreStatus?: boolean
|
||||
statusMore?: StatusParam //0:数据从无到有加载数据,1,没有任何数据, 2:下拉加载,3:下拉没有数据
|
||||
statusMore?: StatusParam // 0:数据从无到有加载数据,1,没有任何数据, 2:下拉加载,3:下拉没有数据
|
||||
children?: ReactNode
|
||||
lowerThresholdNum?: number
|
||||
selfOnScrollToUpper?: () => void
|
||||
@@ -49,7 +50,7 @@ export default memo(
|
||||
moreStatus = true,
|
||||
statusMore = 0,
|
||||
enableBackToTop = true,
|
||||
emptySlot
|
||||
emptySlot,
|
||||
}: Params) => {
|
||||
const scrollToLower = () => {
|
||||
selfonScrollToLower?.()
|
||||
@@ -57,7 +58,7 @@ export default memo(
|
||||
const scrollToUpper = () => {
|
||||
selfOnScrollToUpper?.()
|
||||
}
|
||||
const scroll = e => {
|
||||
const scroll = (e) => {
|
||||
selfOnScroll?.(e)
|
||||
}
|
||||
const refresherPulling = () => {
|
||||
@@ -73,7 +74,7 @@ export default memo(
|
||||
selfOnRefresherAbort?.()
|
||||
}
|
||||
|
||||
//返回顶部
|
||||
// 返回顶部
|
||||
const scrollTop = useMemo(() => {
|
||||
if (statusMore == 0) {
|
||||
return 0.1
|
||||
@@ -84,36 +85,40 @@ export default memo(
|
||||
if (enableLoadMoreStatus) {
|
||||
if (!moreStatus) {
|
||||
return (
|
||||
<View style={{ paddingBottom: paddingBottom + 'rpx' }} className={style.scrollViewCon}>
|
||||
<View style={{ paddingBottom: `${paddingBottom}rpx` }} className={style.scrollViewCon}>
|
||||
{children}
|
||||
</View>
|
||||
)
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return (
|
||||
<>
|
||||
{(statusMore == 2 || statusMore == 3) && (
|
||||
<View style={{ paddingBottom: paddingBottom + 'rpx' }} className={style.scrollViewCon}>
|
||||
<View style={{ paddingBottom: `${paddingBottom}rpx` }} className={style.scrollViewCon}>
|
||||
{children}
|
||||
<View className={style.infinite_scroll}>
|
||||
{statusMore == 2 ? (
|
||||
<View className={style.loading_more}>
|
||||
{statusMore == 2
|
||||
? (
|
||||
<View className={style.loading_more}>
|
||||
加载中
|
||||
<DotLoading />
|
||||
</View>
|
||||
) : (
|
||||
<View className={style.noMore}>没有更多数据了</View>
|
||||
)}
|
||||
<DotLoading />
|
||||
</View>
|
||||
)
|
||||
: (
|
||||
<View className={style.noMore}>没有更多数据了</View>
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
)}
|
||||
{statusMore == 0 && <LoadingCard />}
|
||||
{statusMore == 1 && (emptySlot ? emptySlot : <Empty picUrl={SEARCH_EMPTY_IMAGE} text='暂无数据'/>)}
|
||||
{statusMore == 1 && (emptySlot || <Empty picUrl={SEARCH_EMPTY_IMAGE} text="暂无数据" />)}
|
||||
</>
|
||||
)
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return (
|
||||
<View style={{ paddingBottom: paddingBottom + 'rpx' }} className={style.scrollViewCon}>
|
||||
<View style={{ paddingBottom: `${paddingBottom}rpx` }} className={style.scrollViewCon}>
|
||||
{children}
|
||||
</View>
|
||||
)
|
||||
@@ -123,7 +128,7 @@ export default memo(
|
||||
return (
|
||||
<>
|
||||
<ScrollView
|
||||
id='infiniteScroll'
|
||||
id="infiniteScroll"
|
||||
style={styleObj}
|
||||
className={style.scroll_main}
|
||||
scrollY
|
||||
@@ -137,11 +142,12 @@ export default memo(
|
||||
onRefresherRefresh={() => refresherRefresh()}
|
||||
onRefresherRestore={() => refresherRestore()}
|
||||
onRefresherAbort={() => refresherAbort()}
|
||||
refresherBackground='#F8F8F8'
|
||||
refresherBackground="#F8F8F8"
|
||||
enableBackToTop={enableBackToTop}
|
||||
scrollTop={scrollTop}>
|
||||
scrollTop={scrollTop}
|
||||
>
|
||||
{component()}
|
||||
{safeAreaInsetBottom && <View className='common_safe_area_y'></View>}
|
||||
{safeAreaInsetBottom && <View className="common_safe_area_y"></View>}
|
||||
</ScrollView>
|
||||
</>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user