🌈 style(eslint): 修复eslint的报错❌
This commit is contained in:
@@ -8,7 +8,7 @@ import SearchInput from '@/components/searchInput'
|
||||
import Popup from '@/components/bluetooth/Popup'
|
||||
import useCheckAuthorize from '@/use/useCheckAuthorize'
|
||||
|
||||
export default memo(() => {
|
||||
const LinkBlueTooth = () => {
|
||||
const { state, init, startScan, connect, disconnect } = useBluetooth()
|
||||
|
||||
const { check } = useCheckAuthorize({ scope: 'scope.bluetooth', msg: '请开启小程序蓝牙权限' })
|
||||
@@ -21,10 +21,10 @@ export default memo(() => {
|
||||
useEffect(() => {
|
||||
if (!state.available) {
|
||||
setLinkStatus(1)
|
||||
}
|
||||
}
|
||||
else if (state.available && state.connected?.name) {
|
||||
setLinkStatus(3)
|
||||
}
|
||||
}
|
||||
else {
|
||||
setLinkStatus(2)
|
||||
}
|
||||
@@ -40,6 +40,9 @@ export default memo(() => {
|
||||
}
|
||||
|
||||
const [popupShow, setPopupShow] = useState(false)
|
||||
const onFindEven = () => {
|
||||
if (!state.discovering && !state.connected && !state.connecting) { startScan() }
|
||||
}
|
||||
// 显示设备列表
|
||||
const onFindDevice = () => {
|
||||
check().then((res) => {
|
||||
@@ -48,16 +51,13 @@ export default memo(() => {
|
||||
title: '请打开手机蓝牙',
|
||||
icon: 'none',
|
||||
})
|
||||
}
|
||||
}
|
||||
else {
|
||||
setPopupShow(true)
|
||||
onFindEven()
|
||||
}
|
||||
})
|
||||
}
|
||||
const onFindEven = () => {
|
||||
if (!state.discovering && !state.connected && !state.connecting) { startScan() }
|
||||
}
|
||||
|
||||
// 断开链接
|
||||
const onDisconnect = () => {
|
||||
@@ -72,9 +72,11 @@ export default memo(() => {
|
||||
<View className={styles.bluetooth_link} onClick={onFindDevice}>
|
||||
<View className={classnames(styles.link_status, linkStatus == 3 && styles.link_statused, linkStatus == 2 && styles.link_statused_no)}></View>
|
||||
{
|
||||
linkStatus == 1 && <View className={classnames(styles.link_name, styles.link_name_no)}>请开启蓝牙</View>
|
||||
|| linkStatus == 2 && <View className={classnames(styles.link_name, styles.link_name_no_link)}>未连接设备</View>
|
||||
|| linkStatus == 3 && <View className={classnames(styles.link_name)}>{linkName}</View>
|
||||
linkStatus == 1
|
||||
? <View className={classnames(styles.link_name, styles.link_name_no)}>请开启蓝牙</View>
|
||||
: linkStatus == 2
|
||||
? <View className={classnames(styles.link_name, styles.link_name_no_link)}>未连接设备</View>
|
||||
: linkStatus == 3 ? <View className={classnames(styles.link_name)}>{linkName}</View> : null
|
||||
}
|
||||
</View>
|
||||
</SearchInput>
|
||||
@@ -89,5 +91,6 @@ export default memo(() => {
|
||||
</View>
|
||||
</>
|
||||
|
||||
)
|
||||
})
|
||||
)
|
||||
}
|
||||
export default memo(LinkBlueTooth)
|
||||
|
||||
@@ -12,8 +12,7 @@ interface params {
|
||||
onOff: () => void
|
||||
onFind: () => void
|
||||
}
|
||||
|
||||
export default memo(({ state, show = false, onClose, onLink, onOff, onFind }: params) => {
|
||||
const Bluetooth = ({ state, show = false, onClose, onLink, onOff, onFind }: params) => {
|
||||
const [popupShow, setPopupShow] = useState(show)
|
||||
useEffect(() => {
|
||||
setPopupShow(show)
|
||||
@@ -31,38 +30,46 @@ export default memo(({ state, show = false, onClose, onLink, onOff, onFind }: pa
|
||||
<View className={style.list}>
|
||||
<ScrollView scrollY className={style.scroll}>
|
||||
{
|
||||
(state.devices && state.devices.length > 0) && state?.devices.map((item) => {
|
||||
return (
|
||||
<View className={style.item} onClick={() => onLink(item)}>
|
||||
<View>{item.name}</View>
|
||||
{
|
||||
(!state.connecting && !state.connected) && <View >链接</View>
|
||||
|| (state.connecting && item.deviceId == state.connecting.deviceId) && <View className={style.link_ing}>正在链接...</View>
|
||||
|| (state.connected && item.deviceId == state.connected.deviceId) && <View className={style.link_success}>链接成功</View>
|
||||
}
|
||||
</View>
|
||||
)
|
||||
})
|
||||
|| <View className={style.noDevice}>
|
||||
{
|
||||
(!state.discovering) && <>
|
||||
<View>暂无设备,请按以下条件检查</View>
|
||||
<View className={style.n_item}>1.请确保取色仪处于激活状态</View>
|
||||
<View className={style.n_item}>2.请确保取色仪没有链接其他设备</View>
|
||||
<View className={style.n_item}>3.请打开手机定位</View>
|
||||
</>
|
||||
|| <View>设备搜索中</View>
|
||||
}
|
||||
(state.devices && state.devices.length > 0)
|
||||
? state?.devices.map((item, key) => {
|
||||
return (
|
||||
<View key={key} className={style.item} onClick={() => onLink(item)}>
|
||||
<View>{item.name}</View>
|
||||
{
|
||||
(!state.connecting && !state.connected)
|
||||
? <View >链接</View>
|
||||
: (state.connecting && item.deviceId == state.connecting.deviceId)
|
||||
? <View className={style.link_ing}>正在链接...</View>
|
||||
: (state.connected && item.deviceId == state.connected.deviceId)
|
||||
? <View className={style.link_success}>链接成功</View>
|
||||
: null
|
||||
}
|
||||
</View>
|
||||
)
|
||||
})
|
||||
: <View className={style.noDevice}>
|
||||
{
|
||||
(!state.discovering)
|
||||
? <>
|
||||
<View>暂无设备,请按以下条件检查</View>
|
||||
<View className={style.n_item}>1.请确保取色仪处于激活状态</View>
|
||||
<View className={style.n_item}>2.请确保取色仪没有链接其他设备</View>
|
||||
<View className={style.n_item}>3.请打开手机定位</View>
|
||||
</>
|
||||
: <View>设备搜索中</View>
|
||||
}
|
||||
|
||||
</View>
|
||||
</View>
|
||||
|
||||
}
|
||||
</ScrollView>
|
||||
</View>
|
||||
{
|
||||
state.connected && <View className={`${style.footer} ${style.footer_off}`} onClick={onOff}>断开链接</View>
|
||||
|| (!state.connected && state.discovering) && <View className={`${style.footer} ${style.finding}`}>搜索中<Loading width={30} color="orange" /></View>
|
||||
|| <View className={style.footer} onClick={onFind}>重新搜索</View>
|
||||
state.connected
|
||||
? <View className={`${style.footer} ${style.footer_off}`} onClick={onOff}>断开链接</View>
|
||||
: (!state.connected && state.discovering)
|
||||
? <View className={`${style.footer} ${style.finding}`}>搜索中<Loading width={30} color="orange" /></View>
|
||||
: <View className={style.footer} onClick={onFind}>重新搜索</View>
|
||||
}
|
||||
</View>
|
||||
<View className={style.mask} onClick={onCloseListener}></View>
|
||||
@@ -70,4 +77,5 @@ export default memo(({ state, show = false, onClose, onLink, onOff, onFind }: pa
|
||||
}
|
||||
</>
|
||||
)
|
||||
})
|
||||
}
|
||||
export default memo(Bluetooth)
|
||||
|
||||
Reference in New Issue
Block a user