Commit 0e46664d authored by 田翔's avatar 田翔

fix: 代码优化

parent 86655bcc
Pipeline #84311 passed with stages
import React, { useState, useRef, useContext, useMemo, useEffect } from 'react'
import { Checkbox, Row, Col, Button, message } from 'antd'
import { Checkbox, Row, Col, Button, message, Input } from 'antd'
import { useDrag, useDrop, DndProvider } from 'react-dnd'
import { CaretRightOutlined } from '@ant-design/icons'
import styles from './index.less'
import { GlobalStore } from '../index'
import { getCardVersion, upgradeCardVersion } from '@/services/mobileConfig/api'
const { Search } = Input
const cardTypes = ['管理', '执行', '运营']
const tabs = ['产品组件', '项目组件']
......@@ -180,17 +182,18 @@ const Left = () => {
const [cardType, setCardType] = useState(cardTypes)
const [version, setVersion] = useState({ Version: '', lastVersion: '' })
const [activeIndex, setActiveIndex] = useState(0)
const [inputValue, setInputValue] = useState('')
const cardsFilter = useMemo(() => {
let array = []
cards[activeIndex].forEach(v => {
let children = v.children.filter(s => cardType.includes(s.type))
let children = v.children.filter(s => cardType.includes(s.type) && (!inputValue || s.name.includes(inputValue)))
if (children.length) {
array.push({ ...v, children })
}
})
return array
}, [cards, cardType, activeIndex])
}, [cards, cardType, activeIndex, inputValue])
const cardTypeChange = (value) => {
setCardType(value)
......@@ -254,6 +257,14 @@ const Left = () => {
})}
</div>
<div className={styles.item}>
<div className={styles.search}>
<Search
placeholder="请输入关键字搜索"
value={inputValue}
onChange={(e) => setInputValue(e.target.value)}
style={{ width: 250 }}
/>
</div>
<div className={styles['g-checks']}>
<Checkbox.Group
style={{ width: '100%' }}
......
......@@ -44,11 +44,17 @@
overflow: auto;
padding-bottom: 10px;
.item {
position: relative;
.g-title {
padding: 10px;
font-size: 14px;
font-weight: 700;
}
.search {
position: absolute;
right: 10px;
top: 0;
}
.g-checks {
margin: 10px 0 5px 0;
}
......@@ -172,12 +178,11 @@
background-size: 100% 100%;
}
}
}
&:hover {
.swiper {
height: 25px;
}
}
} // &:hover {
// .swiper {
// height: 25px;
// }
// }
.cardType {
position: absolute;
right: 0;
......@@ -206,7 +211,7 @@
left: 0;
width: 100%;
text-align: center;
height: 0;
height: 25px;
line-height: 25px;
border-radius: 0 0 4px 4px;
background: rgba(0, 0, 0, 0.3);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment