添加重置ql reset命令,支持批量操作ck

This commit is contained in:
hanhh
2021-06-07 21:54:49 +08:00
parent 64aadb7eb8
commit 9e666f4348
11 changed files with 166 additions and 39 deletions
+3 -3
View File
@@ -6,7 +6,7 @@ import { Controlled as CodeMirror } from 'react-codemirror2';
import { request } from '@/utils/http';
const Config = () => {
const [width, setWdith] = useState('100%');
const [width, setWidth] = useState('100%');
const [marginLeft, setMarginLeft] = useState(0);
const [marginTop, setMarginTop] = useState(-72);
const [value, setValue] = useState('');
@@ -34,11 +34,11 @@ const Config = () => {
useEffect(() => {
if (document.body.clientWidth < 768) {
setWdith('auto');
setWidth('auto');
setMarginLeft(0);
setMarginTop(0);
} else {
setWdith('100%');
setWidth('100%');
setMarginLeft(0);
setMarginTop(-72);
}
+103 -16
View File
@@ -42,6 +42,16 @@ enum StatusColor {
'error',
}
enum OperationName {
'启用',
'禁用',
}
enum OperationPath {
'enable',
'disable',
}
const type = 'DragableBodyRow';
const DragableBodyRow = ({
@@ -105,17 +115,6 @@ const Config = () => {
return <span style={{ cursor: 'text' }}>{index + 1} </span>;
},
},
// {
// title: '用户名',
// dataIndex: 'pin',
// key: 'pin',
// align: 'center' as const,
// render: (text: string, record: any) => {
// const match = record.value.match(/pt_pin=([^; ]+)(?=;?)/);
// const val = (match && match[1]) || '未匹配用户名';
// return <span style={{ cursor: 'text' }}>{decodeUrl(val)}</span>;
// },
// },
{
title: '昵称',
dataIndex: 'nickname',
@@ -123,8 +122,10 @@ const Config = () => {
align: 'center' as const,
width: '15%',
render: (text: string, record: any, index: number) => {
const match = record.value.match(/pt_pin=([^; ]+)(?=;?)/);
const val = (match && match[1]) || '未匹配用户名';
return (
<span style={{ cursor: 'text' }}>{record.nickname || '-'} </span>
<span style={{ cursor: 'text' }}>{record.nickname || val} </span>
);
},
},
@@ -204,13 +205,14 @@ const Config = () => {
),
},
];
const [width, setWdith] = useState('100%');
const [width, setWidth] = useState('100%');
const [marginLeft, setMarginLeft] = useState(0);
const [marginTop, setMarginTop] = useState(-72);
const [value, setValue] = useState<any[]>([]);
const [loading, setLoading] = useState(true);
const [isModalVisible, setIsModalVisible] = useState(false);
const [editedCookie, setEditedCookie] = useState();
const [selectedRowIds, setSelectedRowIds] = useState<string[]>([]);
const getCookies = () => {
setLoading(true);
@@ -376,13 +378,68 @@ const Config = () => {
[value],
);
const onSelectChange = (selectedIds: any[]) => {
setSelectedRowIds(selectedIds);
};
const rowSelection = {
selectedRowIds,
onChange: onSelectChange,
};
const delCookies = () => {
Modal.confirm({
title: '确认删除',
content: <>Cookie吗</>,
onOk() {
request
.delete(`${config.apiPrefix}cookies`, { data: selectedRowIds })
.then((data: any) => {
if (data.code === 200) {
message.success('批量删除成功');
setSelectedRowIds([]);
getCookies();
} else {
message.error(data);
}
});
},
onCancel() {
console.log('Cancel');
},
});
};
const operateCookies = (operationStatus: number) => {
Modal.confirm({
title: `确认${OperationName[operationStatus]}`,
content: <>{OperationName[operationStatus]}Cookie吗</>,
onOk() {
request
.put(`${config.apiPrefix}cookies/${OperationPath[operationStatus]}`, {
data: selectedRowIds,
})
.then((data: any) => {
if (data.code === 200) {
getCookies();
} else {
message.error(data);
}
});
},
onCancel() {
console.log('Cancel');
},
});
};
useEffect(() => {
if (document.body.clientWidth < 768) {
setWdith('auto');
setWidth('auto');
setMarginLeft(0);
setMarginTop(0);
} else {
setWdith('100%');
setWidth('100%');
setMarginLeft(0);
setMarginTop(-72);
}
@@ -411,12 +468,42 @@ const Config = () => {
},
}}
>
{selectedRowIds.length > 0 && (
<div style={{ marginBottom: 16 }}>
<Button
type="primary"
style={{ marginBottom: 5 }}
onClick={delCookies}
>
</Button>
<Button
type="primary"
onClick={() => operateCookies(0)}
style={{ marginLeft: 8, marginBottom: 5 }}
>
</Button>
<Button
type="primary"
onClick={() => operateCookies(1)}
style={{ marginLeft: 8, marginRight: 8 }}
>
</Button>
<span style={{ marginLeft: 8 }}>
<a>{selectedRowIds?.length}</a>
</span>
</div>
)}
<DndProvider backend={HTML5Backend}>
<Table
columns={columns}
rowSelection={rowSelection}
pagination={false}
dataSource={value}
rowKey="value"
rowKey="_id"
size="middle"
scroll={{ x: 768 }}
components={components}
+3 -3
View File
@@ -176,7 +176,7 @@ const Crontab = () => {
},
];
const [width, setWdith] = useState('100%');
const [width, setWidth] = useState('100%');
const [marginLeft, setMarginLeft] = useState(0);
const [marginTop, setMarginTop] = useState(-72);
const [value, setValue] = useState<any[]>([]);
@@ -524,11 +524,11 @@ const Crontab = () => {
useEffect(() => {
if (document.body.clientWidth < 768) {
setWdith('auto');
setWidth('auto');
setMarginLeft(0);
setMarginTop(0);
} else {
setWdith('100%');
setWidth('100%');
setMarginLeft(0);
setMarginTop(-72);
}
+17 -1
View File
@@ -27,6 +27,7 @@ const CronLogModal = ({
const [value, setValue] = useState<string>('启动中...');
const [loading, setLoading] = useState<any>(true);
const [excuting, setExcuting] = useState<any>(true);
const [isPhone, setIsPhone] = useState(false);
const getCronLog = (isFirst?: boolean) => {
if (isFirst) {
@@ -86,6 +87,10 @@ const CronLogModal = ({
}
}, [cron]);
useEffect(() => {
setIsPhone(document.body.clientWidth < 768);
}, []);
return (
<Modal
title={titleElement()}
@@ -100,7 +105,18 @@ const CronLogModal = ({
onCancel={() => cancel()}
>
{!loading && value && (
<pre style={{ whiteSpace: 'break-spaces', lineHeight: '17px' }}>
<pre
style={
!isPhone
? { whiteSpace: 'break-spaces', lineHeight: '17px' }
: {
whiteSpace: 'break-spaces',
lineHeight: '17px',
width: 375,
zoom: 0.88,
}
}
>
{value}
</pre>
)}
+3 -3
View File
@@ -7,7 +7,7 @@ import ReactDiffViewer from 'react-diff-viewer';
import './index.less';
const Crontab = () => {
const [width, setWdith] = useState('100%');
const [width, setWidth] = useState('100%');
const [marginLeft, setMarginLeft] = useState(0);
const [marginTop, setMarginTop] = useState(-72);
const [value, setValue] = useState('');
@@ -32,11 +32,11 @@ const Crontab = () => {
useEffect(() => {
if (document.body.clientWidth < 768) {
setWdith('auto');
setWidth('auto');
setMarginLeft(0);
setMarginTop(0);
} else {
setWdith('100%');
setWidth('100%');
setMarginLeft(0);
setMarginTop(-72);
}
+3 -3
View File
@@ -6,7 +6,7 @@ import { Controlled as CodeMirror } from 'react-codemirror2';
import { request } from '@/utils/http';
const Crontab = () => {
const [width, setWdith] = useState('100%');
const [width, setWidth] = useState('100%');
const [marginLeft, setMarginLeft] = useState(0);
const [marginTop, setMarginTop] = useState(-72);
const [value, setValue] = useState('');
@@ -34,11 +34,11 @@ const Crontab = () => {
useEffect(() => {
if (document.body.clientWidth < 768) {
setWdith('auto');
setWidth('auto');
setMarginLeft(0);
setMarginTop(0);
} else {
setWdith('100%');
setWidth('100%');
setMarginLeft(0);
setMarginTop(-72);
}
+3 -3
View File
@@ -36,7 +36,7 @@ function getFilterData(keyword: string, data: any) {
}
const Log = () => {
const [width, setWdith] = useState('100%');
const [width, setWidth] = useState('100%');
const [marginLeft, setMarginLeft] = useState(0);
const [marginTop, setMarginTop] = useState(-72);
const [title, setTitle] = useState('请选择日志文件');
@@ -103,12 +103,12 @@ const Log = () => {
useEffect(() => {
if (document.body.clientWidth < 768) {
setWdith('auto');
setWidth('auto');
setMarginLeft(0);
setMarginTop(0);
setIsPhone(true);
} else {
setWdith('100%');
setWidth('100%');
setMarginLeft(0);
setMarginTop(-72);
setIsPhone(false);
+3 -3
View File
@@ -18,7 +18,7 @@ const optionsWithDisabled = [
];
const Password = () => {
const [width, setWdith] = useState('100%');
const [width, setWidth] = useState('100%');
const [marginLeft, setMarginLeft] = useState(0);
const [marginTop, setMarginTop] = useState(-72);
const [value, setValue] = useState('');
@@ -56,11 +56,11 @@ const Password = () => {
useEffect(() => {
if (document.body.clientWidth < 768) {
setWdith('auto');
setWidth('auto');
setMarginLeft(0);
setMarginTop(0);
} else {
setWdith('100%');
setWidth('100%');
setMarginLeft(0);
setMarginTop(-72);
}