🌈 style(eslint): add eslint rules

This commit is contained in:
xuan
2022-11-26 14:35:05 +08:00
parent f3aa20f049
commit 99a920975f
245 changed files with 14909 additions and 14349 deletions
+44 -44
View File
@@ -1,48 +1,48 @@
import {Textarea, View } from "@tarojs/components";
import { memo, useEffect, useMemo, useState } from "react";
import styles from './index.module.scss'
import classnames from "classnames";
import { Textarea, View } from '@tarojs/components'
import { memo, useEffect, useMemo, useState } from 'react'
import classnames from 'classnames'
import styles from './index.module.scss'
//其他说明
type Param = {
title?: string,
onChange?: (val: string) => void,
placeholder?: string,
defaultValue?: string,
onlyRead?: false|true
// 其他说明
interface Param {
title?: string
onChange?: (val: string) => void
placeholder?: string
defaultValue?: string
onlyRead?: false|true
}
export default memo(({onChange, title = '', placeholder = '请输入', defaultValue, onlyRead = false}:Param) => {
const [descData, setDescData] = useState({
number: 0,
value: '',
count: 200,
show: false
})
const getDesc = (value = '') => {
let res = value
if(value.length > descData.count) {
res = value.slice(0, descData.count)
export default memo(({ onChange, title = '', placeholder = '请输入', defaultValue, onlyRead = false }: Param) => {
const [descData, setDescData] = useState({
number: 0,
value: '',
count: 200,
show: false,
})
const getDesc = (value = '') => {
let res = value
if (value.length > descData.count) {
res = value.slice(0, descData.count)
}
setDescData({ ...descData, number: res.length, value: res })
onChange?.(res)
}
useEffect(() => {
getDesc(defaultValue)
}, [defaultValue])
const toggleShowRealTextarea = (show) => {
setDescData({ ...descData, show })
}
return (
<View className={styles.other_desc}>
<View className={styles.title}>{title}</View>
<View className={styles.textarea}>
{(descData.show && !onlyRead) && <Textarea autoFocus value={descData.value} onBlur={() => toggleShowRealTextarea(false)} className={styles.textarea_con} cursorSpacing={100} maxlength={descData.count} onInput={e => getDesc(e.detail.value)}></Textarea>
|| <View className={classnames(styles.textarea_con_pretend, descData.value && styles.textarea_con_pretend_ed)} onClick={() => toggleShowRealTextarea(true)}>{descData.value || placeholder}</View>
}
setDescData({...descData, number:res.length, value: res})
onChange?.(res)
}
useEffect(() => {
getDesc(defaultValue)
}, [defaultValue])
const toggleShowRealTextarea = (show) => {
setDescData({...descData, show:show})
}
return (
<View className={styles.other_desc}>
<View className={styles.title}>{title}</View>
<View className={styles.textarea}>
{(descData.show && !onlyRead)&&<Textarea autoFocus value={descData.value} onBlur={() => toggleShowRealTextarea(false)} className={styles.textarea_con} cursorSpacing={100} maxlength={descData.count} onInput={(e) => getDesc(e.detail.value)}></Textarea>||
<View className={classnames(styles.textarea_con_pretend, descData.value&&styles.textarea_con_pretend_ed)} onClick={() => toggleShowRealTextarea(true)}>{descData.value||placeholder}</View>
}
<View className={styles.descDataNum}>{descData.number +'/'+ descData.count}</View>
</View>
</View>
)
<View className={styles.descDataNum}>{`${descData.number}/${descData.count}`}</View>
</View>
</View>
)
})