diff --git a/src/pages/User/LocalAppList.tsx b/src/pages/User/LocalAppList.tsx new file mode 100644 index 0000000..729f230 --- /dev/null +++ b/src/pages/User/LocalAppList.tsx @@ -0,0 +1,144 @@ +import { SearchOutlined } from '@ant-design/icons'; +import { ProColumns, ProTable } from '@ant-design/pro-components'; +import { Button, Input, Modal, Space } from 'antd'; +import { useEffect, useState } from 'react'; + +import { evilAppList } from '@/services/matrix/superAdmin'; + +export type LocalAppListProps = { + data: API.UserBo; + onClose: () => void; +}; + +interface LocalApp { + appName?: string; + packageName?: string; + evil: boolean; +} + +const LocalAppList: React.FC = (props) => { + const [appArr, setAppArr] = useState(); + const [filteredAppArr, setFilteredAppArr] = useState(); + + const columns: ProColumns[] = [ + { + title: '应用名', + dataIndex: 'appName', + ellipsis: true, + hideInSearch: true, + filterDropdown: ({ setSelectedKeys, selectedKeys, confirm, clearFilters }) => ( +
+ setSelectedKeys(e.target.value ? [e.target.value] : [])} + onPressEnter={() => confirm()} + style={{ marginBottom: 8, display: 'block' }} + /> + + + + +
+ ), + onFilter: (value, record) => { + if (typeof value === 'string' && typeof record?.appName === 'string') { + return record.appName.includes(value); + } + return false; + }, + filterIcon: (filtered) => ( + + ), + }, + { + title: '应用包名', + dataIndex: 'packageName', + hideInSearch: true, + ellipsis: true, + filterDropdown: ({ setSelectedKeys, selectedKeys, confirm, clearFilters }) => ( +
+ setSelectedKeys(e.target.value ? [e.target.value] : [])} + onPressEnter={() => confirm()} + style={{ marginBottom: 8, display: 'block' }} + /> + + + + +
+ ), + onFilter: (value, record) => { + if (typeof value === 'string' && typeof record?.packageName === 'string') { + return record.packageName.includes(value); + } + return false; + }, + filterIcon: (filtered) => ( + + ), + }, + ]; + + const fetchApp = async () => { + const res = await evilAppList(); + if (res.data) { + let common: LocalApp[] = []; + let remain: LocalApp[] = []; + props.data.localAppList?.forEach((x) => { + if (res.data?.some((y) => y.packageName === x.packageName)) { + common.push({ ...x, evil: true }); + } else { + remain.push({ ...x, evil: false }); + } + }); + setAppArr([...common, ...remain]); + setFilteredAppArr([...common, ...remain]); + } + }; + + useEffect(() => { + fetchApp(); + }, []); + + return ( + + { + return { + style: { + backgroundColor: record.evil ? 'red' : 'transparent', + }, + }; + }} + search={false} + onReset={() => { + setFilteredAppArr(appArr); + }} + columns={columns} + dataSource={filteredAppArr} + /> + + ); +}; + +export default LocalAppList;