Skip to content

Commit

Permalink
fix: bugs 修复
Browse files Browse the repository at this point in the history
  • Loading branch information
EmbraceAn committed Dec 20, 2024
1 parent daed59d commit c146d43
Show file tree
Hide file tree
Showing 11 changed files with 112 additions and 56 deletions.
3 changes: 3 additions & 0 deletions src/compoments/WizardProFilterDrawer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ interface TWizardProFilterDrawerProps {
tableHeight: number;
wizardScrollHeight: number;
layout?: FormLayout;
handleScrollToFirstRow: () => void;
}

const WizardProFilterDrawer: FC<TWizardProFilterDrawerProps> = memo(
Expand All @@ -21,6 +22,7 @@ const WizardProFilterDrawer: FC<TWizardProFilterDrawerProps> = memo(
tableHeight,
wizardScrollHeight,
layout = 'vertical',
handleScrollToFirstRow,
}) => {
const [form] = Form.useForm();

Expand All @@ -33,6 +35,7 @@ const WizardProFilterDrawer: FC<TWizardProFilterDrawerProps> = memo(

const headFieldsChange = () => {
const fieldsValue = form.getFieldsValue();
handleScrollToFirstRow();
filterDispatch &&
filterDispatch({
filter: { ...state?.filter, ...fieldsValue },
Expand Down
7 changes: 3 additions & 4 deletions src/compoments/WizardTable/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useCallback, useEffect, useMemo, useReducer, useRef } from 'react';
import { Button, message, Spin, Table } from 'antd';
import { message, Spin, Table } from 'antd';
import { AnyObject } from 'antd/es/_util/type';
import { useRequest, useSafeState } from 'ahooks';

Expand Down Expand Up @@ -212,7 +212,7 @@ const WizardTable = <T extends AnyObject = AnyObject>(
// 手动触发
page.onLoad = async (arg) => {
handleScrollToFirstRow();
await runAsync(request, false, arg);
await runAsync(request, true, arg);
};

// 获取表格参数
Expand Down Expand Up @@ -321,8 +321,6 @@ const WizardTable = <T extends AnyObject = AnyObject>(
},
dataSource: [], // 清空数据源
});

runAsync(request, true);
}
};

Expand Down Expand Up @@ -437,6 +435,7 @@ const WizardTable = <T extends AnyObject = AnyObject>(
trigger={tableHeader?.options?.ProFilterSwitch?.trigger}
layout={tableHeader?.options?.ProFilterSwitch?.layout}
wizardScrollHeight={wizardScrollHeight}
handleScrollToFirstRow={handleScrollToFirstRow}
/>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
import { FC } from 'react';
import { Button, Form, Radio } from 'antd';
import { Button, Form, Radio, Select } from 'antd';

import { UsePageRef } from '@/hooks/usePage';
import { difficultyList, levelList, orderList, routeList } from '../data';
import {
difficultyList,
ExecutionOrderOptions,
levelList,
orderList,
routeList,
} from '../data';
import { FilterTag } from './FilterTag';
import { useSafeState } from 'ahooks';

const CveLoopholeFilterDrawer: FC<{ page: UsePageRef }> = ({ page }) => {
const { Item } = Form;
const [executionOrderValue, setExecutionOrderValue] = useSafeState<
'CVEPublishedTime' | 'CVELastModifiedTime'
>();

const headReset = () => {
page.editFilter({
AccessVector: [],
AccessComplexity: [],
Severity: [],
order: undefined,
order_by: undefined,
access_vector: [],
access_complexity: [],
CVESeverity: [],
});
};
return (
Expand All @@ -28,43 +40,54 @@ const CveLoopholeFilterDrawer: FC<{ page: UsePageRef }> = ({ page }) => {
重置
</Button>
</div>
<div className="flex align-center gap-2">
<div className="leading-8">披露时间</div>
<Item name={'order'} initialValue={'desc'}>
<Radio.Group
options={orderList}
optionType="button"
buttonStyle="solid"
/>
</Item>
</div>

<div className="flex align-center gap-2">
<div className="leading-8">更新时间</div>
<Item name={'order'} initialValue={'desc'}>
<div className="leading-6">排序时间</div>
<Item name={'order'}>
<Radio.Group
options={orderList}
optionType="button"
buttonStyle="solid"
options={ExecutionOrderOptions}
onChange={(e) => {
setExecutionOrderValue((value) => {
value &&
page.editFilter({
[value]: undefined,
[e.target.value]: undefined,
});
return e.target.value;
});
}}
/>
</Item>
</div>

{executionOrderValue ? (
<div className="flex align-center gap-2 mb-4 w-full">
<div className="leading-9">执行顺序</div>
<Item name={'order_by'} noStyle>
<Select
options={orderList}
placeholder="请选择"
className="w-46"
/>
</Item>
</div>
) : null}

<div className="flex align-center gap-2">
<div className="leading-6">利用路径</div>
<Item name={'AccessVector'} initialValue={[]}>
<Item name={'access_vector'} initialValue={[]}>
<FilterTag data={routeList} />
</Item>
</div>
<div className="flex align-center gap-2">
<div>利用难度</div>
<Item name={'AccessComplexity'} initialValue={[]}>
<Item name={'access_complexity'} initialValue={[]}>
<FilterTag data={difficultyList} />
</Item>
</div>
<div className="flex align-center gap-2">
<div>漏洞级别</div>
<Item name={'Severity'} initialValue={[]}>
<Item name={'CVESeverity'} initialValue={[]}>
<FilterTag data={levelList} />
</Item>
</div>
Expand Down
19 changes: 18 additions & 1 deletion src/pages/DataService/CveLoophole/data.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
const ExecutionOrderOptions = [
{
label: '披露时间',
value: 'published_time',
},
{
label: '更新时间',
value: 'last_modified_time',
},
];

const difficultyList = [
{ value: 'HIGH', label: '困难' },
{ value: 'MEDIUM', label: '一般' },
Expand Down Expand Up @@ -29,4 +40,10 @@ const orderList = [
},
];

export { difficultyList, routeList, levelList, orderList };
export {
difficultyList,
routeList,
levelList,
orderList,
ExecutionOrderOptions,
};
11 changes: 1 addition & 10 deletions src/pages/DataService/CveLoophole/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,18 +161,10 @@ const CveLoophole: FC = () => {
(it) => it.value !== search.key,
)[0].value;

await page.onLoad({
await page.editFilter({
[search.key]: value,
[uselessKey]: undefined,
});
console.log(
{
[search.key]: value,
[uselessKey]: undefined,
},
'uuu',
);

setSearch((cur) => ({ ...cur, value }));
}}
/>
Expand Down Expand Up @@ -207,7 +199,6 @@ const CveLoophole: FC = () => {
const { data } = await postCveQuery({
...params,
...filter,
// cve: ['CVE-2010-0213'],
});

return {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/NetworkError.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const NetworkError = () => {
<div className="color-[#31343F] text-sm font-semibold">
请检查网络连接
</div>
<div>连网后才可访问 Yakit 插件商店</div>
<div>联网后才可访问</div>
<Button color="primary" variant="outlined" onClick={headClean}>
<SyncOutlined />
刷新页面
Expand Down
11 changes: 10 additions & 1 deletion src/pages/TaskDetail/TaskDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ export type TDetailDatailOptions = Array<{
| 'risk_num';
}>;

enum exprotFileName {
'端口资产' = 1,
'漏洞与风险',
'资产数据',
}

const TaskDetail: FC = () => {
const [page] = WizardTable.usePage();
const { id, task_id } = useParams(); // 获取路径参数
Expand Down Expand Up @@ -288,7 +294,10 @@ const TaskDetail: FC = () => {
),
options: {
dowloadFile: {
fileName: '端口资产 (' + dayjs().unix() + ').csv',
fileName:
`${exprotFileName[headerGroupValue]} (` +
dayjs().unix() +
').csv',
params: {
typ: ExportRequestKey?.[headerGroupValue],
data: {
Expand Down
4 changes: 2 additions & 2 deletions src/pages/TaskDetail/compoments/Columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const ProtColumns: CreateTableProps<TGetAssetsProtsResponse>['columns'] = [
},
{
title: '端口',
dataIndex: 'ports',
dataIndex: 'port',
columnsHeaderFilterType: 'input',
width: 120,
render: (_, render) =>
Expand All @@ -54,12 +54,12 @@ const ProtColumns: CreateTableProps<TGetAssetsProtsResponse>['columns'] = [
{
title: '协议',
dataIndex: 'proto',
columnsHeaderFilterType: 'input',
width: 120,
render: (value) => (value ? <Tag color="success">{value}</Tag> : '-'),
},
{
title: '服务指纹',
columnsHeaderFilterType: 'input',
dataIndex: 'service_type',
width: 180,
},
Expand Down
2 changes: 2 additions & 0 deletions src/pages/TaskPageList/compoment/TaskOperateTableRender.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ const PublicAndExecutionOperateRender: FC<TCommonTasksColumnsRenderProps> = ({
// : [],
},
};

console.log(transformModalFormdata, 'transformModalFormdata');
itemsRef.current = transformModalFormdata;
runAsyncGroup();
});
Expand Down
39 changes: 26 additions & 13 deletions src/pages/TaskScript/compoment/CreateTaskItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,12 @@ const CreateTaskItems: TCreateTaskItemsProps = (
.exhaustive();
});

const [copyScriptGroupList, setCopyScriptGroupLis] =
const [copyScriptGroupList, setCopyScriptGroupList] =
useSafeState<TScriptGrounpList>([]);
const scriptGroupListRef = useRef<TScriptGrounpList>();

useEffect(() => {
setCopyScriptGroupLis(scriptGroupList);
setCopyScriptGroupList(scriptGroupList);
scriptGroupListRef.current = scriptGroupList ?? [];
}, [scriptGroupList]);

Expand Down Expand Up @@ -266,18 +266,31 @@ const CreateTaskItems: TCreateTaskItemsProps = (
placeholder="请选择..."
showSearch
optionFilterProp="label"
onBlur={() => {
const targetScriptGroup =
scriptGroupListRef.current?.filter(
(item) => item.label,
) ?? [];
setCopyScriptGroupList(targetScriptGroup);
}}
onSearch={(value) => {
setTimeout(() => {
setCopyScriptGroupLis((list) =>
list.findIndex(
(it) => it.value === value,
) === -1
? list.concat({
label: `${value}`,
value,
})
: list,
);
setCopyScriptGroupList((list) => {
const concatList =
list.findIndex(
(it) => it.value === value,
) === -1
? list.concat({
label: `${value}`,
value,
})
: list;
const resultGroupList =
concatList?.filter(
(item) => item.label,
) ?? [];
return resultGroupList;
});
}, 500);
}}
onSelect={(_, options) => {
Expand All @@ -293,7 +306,7 @@ const CreateTaskItems: TCreateTaskItemsProps = (
) === index,
);
scriptGroupListRef.current = resultList;
setCopyScriptGroupLis(resultList);
setCopyScriptGroupList(resultList);
}}
options={copyScriptGroupList ?? scriptGroupList}
/>
Expand Down
1 change: 0 additions & 1 deletion src/pages/TaskScript/compoment/StartUpScriptModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ const StartUpScriptModal = forwardRef<
async open(items, scriptGroupList) {
await runAsync()
.then(() => {
console.log(items, 'items');
const targetSetFormData = {
task_id: `[${items?.script_name}]-[${dayjs().format('M月DD日')}]-[${randomString(6)}]-`,
// script_type: items?.script_type,
Expand Down

0 comments on commit c146d43

Please sign in to comment.