antd notification改为message

This commit is contained in:
hanhh 2021-05-24 23:29:35 +08:00
parent 09162d503a
commit e28d84dc6b
12 changed files with 51 additions and 83 deletions

View File

@ -12,7 +12,7 @@ const initData = [
6,
1,
).toString()} * * *`,
status: CrontabStatus.idle,
status: CrontabStatus.disabled,
},
{
name: '删除日志',

View File

@ -6,6 +6,16 @@ body {
@import '~codemirror/lib/codemirror.css';
.CodeMirror {
height: auto;
}
.CodeMirror-scroll {
height: auto;
overflow-y: hidden;
overflow-x: auto;
}
.ql-container-wrapper {
.CodeMirror {
position: absolute;

View File

@ -1,5 +1,5 @@
import React, { PureComponent, Fragment, useState, useEffect } from 'react';
import { Button, notification, Modal } from 'antd';
import { Button, message, Modal } from 'antd';
import config from '@/utils/config';
import { PageContainer } from '@ant-design/pro-layout';
import { Controlled as CodeMirror } from 'react-codemirror2';
@ -16,7 +16,7 @@ const Config = () => {
setLoading(true);
request
.get(`${config.apiPrefix}config/config`)
.then((data) => {
.then((data: any) => {
setValue(data.data);
})
.finally(() => setLoading(false));
@ -27,10 +27,8 @@ const Config = () => {
.post(`${config.apiPrefix}save`, {
data: { content: value, name: 'config.sh' },
})
.then((data) => {
notification.success({
message: data.msg,
});
.then((data: any) => {
message.success(data.msg);
});
};

View File

@ -1,7 +1,7 @@
import React, { useCallback, useRef, useState, useEffect } from 'react';
import {
Button,
notification,
message,
Modal,
Table,
Tag,
@ -230,7 +230,7 @@ const Config = () => {
(value as any).splice(index, 1, data.data);
setValue([...(value as any)] as any);
} else {
notification.error({ message: '更新状态失败' });
message.error('更新状态失败');
}
});
};
@ -260,11 +260,9 @@ const Config = () => {
)
.then((data: any) => {
if (data.code === 200) {
notification.success({
message: `${
record.status === Status. ? '启用' : '禁用'
}`,
});
message.success(
`${record.status === Status. ? '启用' : '禁用'}成功`,
);
const newStatus =
record.status === Status. ? Status.未获取 : Status.已禁用;
const result = [...value];
@ -274,9 +272,7 @@ const Config = () => {
});
setValue(result);
} else {
notification.error({
message: data,
});
message.error(data);
}
});
},
@ -313,16 +309,12 @@ const Config = () => {
.delete(`${config.apiPrefix}cookies`, { data: [record._id] })
.then((data: any) => {
if (data.code === 200) {
notification.success({
message: '删除成功',
});
message.success('删除成功');
const result = [...value];
result.splice(index, 1);
setValue(result);
} else {
notification.error({
message: data,
});
message.error(data);
}
});
},
@ -377,9 +369,7 @@ const Config = () => {
})
.then((data: any) => {
if (data.code !== 200) {
notification.error({
message: data,
});
message.error(data);
}
});
},

View File

@ -1,5 +1,5 @@
import React, { useEffect, useState } from 'react';
import { Modal, notification, Input, Form } from 'antd';
import { Modal, message, Input, Form } from 'antd';
import { request } from '@/utils/http';
import config from '@/utils/config';
@ -22,7 +22,7 @@ const CookieModal = ({
let flag = false;
for (const coo of cookies) {
if (!/pt_key=\S*;\s*pt_pin=\S*;\s*/.test(coo)) {
notification.error({ message: `${coo}格式有误` });
message.error(`${coo}格式有误`);
flag = true;
break;
}
@ -37,13 +37,9 @@ const CookieModal = ({
data: payload,
});
if (code === 200) {
notification.success({
message: cookie ? '更新Cookie成功' : '添加Cookie成功',
});
message.success(cookie ? '更新Cookie成功' : '添加Cookie成功');
} else {
notification.error({
message: data,
});
message.error(data);
}
setLoading(false);
handleCancel(cookie ? [data] : data);

View File

@ -1,7 +1,7 @@
import React, { PureComponent, Fragment, useState, useEffect } from 'react';
import {
Button,
notification,
message,
Modal,
Table,
Tag,
@ -231,16 +231,12 @@ const Crontab = () => {
.delete(`${config.apiPrefix}crons`, { data: [record._id] })
.then((data: any) => {
if (data.code === 200) {
notification.success({
message: '删除成功',
});
message.success('删除成功');
const result = [...value];
result.splice(index, 1);
setValue(result);
} else {
notification.error({
message: data,
});
message.error(data);
}
});
},
@ -274,9 +270,7 @@ const Crontab = () => {
});
setValue(result);
} else {
notification.error({
message: data,
});
message.error(data);
}
});
},
@ -311,9 +305,7 @@ const Crontab = () => {
});
setValue(result);
} else {
notification.error({
message: data,
});
message.error(data);
}
});
},
@ -356,9 +348,7 @@ const Crontab = () => {
});
setValue(result);
} else {
notification.error({
message: data,
});
message.error(data);
}
});
},
@ -484,15 +474,11 @@ const Crontab = () => {
.delete(`${config.apiPrefix}crons`, { data: selectedRowIds })
.then((data: any) => {
if (data.code === 200) {
notification.success({
message: '批量删除成功',
});
message.success('批量删除成功');
setSelectedRowIds([]);
getCrons();
} else {
notification.error({
message: data,
});
message.error(data);
}
});
},
@ -515,9 +501,7 @@ const Crontab = () => {
if (data.code === 200) {
getCrons();
} else {
notification.error({
message: data,
});
message.error(data);
}
});
},

View File

@ -1,5 +1,5 @@
import React, { useEffect, useState } from 'react';
import { Modal, notification, Input, Form } from 'antd';
import { Modal, message, Input, Form } from 'antd';
import { request } from '@/utils/http';
import config from '@/utils/config';
import cronParse from 'cron-parser';
@ -27,13 +27,9 @@ const CronModal = ({
data: payload,
});
if (code === 200) {
notification.success({
message: cron ? '更新Cron成功' : '添加Cron成功',
});
message.success(cron ? '更新Cron成功' : '添加Cron成功');
} else {
notification.error({
message: data,
});
message.error(data);
}
setLoading(false);
handleCancel(data);

View File

@ -1,5 +1,5 @@
import React, { PureComponent, Fragment, useState, useEffect } from 'react';
import { Button, notification, Modal } from 'antd';
import { Button, message, Modal } from 'antd';
import config from '@/utils/config';
import { PageContainer } from '@ant-design/pro-layout';
import { request } from '@/utils/http';

View File

@ -1,5 +1,5 @@
import React, { PureComponent, Fragment, useState, useEffect } from 'react';
import { Button, notification, Modal } from 'antd';
import { Button, message, Modal } from 'antd';
import config from '@/utils/config';
import { PageContainer } from '@ant-design/pro-layout';
import { Controlled as CodeMirror } from 'react-codemirror2';
@ -28,9 +28,7 @@ const Crontab = () => {
data: { content: value, name: 'extra.sh' },
})
.then((data) => {
notification.success({
message: data.msg,
});
message.success(data.msg);
});
};

View File

@ -1,5 +1,5 @@
import React, { PureComponent, Fragment, useState, useEffect } from 'react';
import { Button, notification, Modal, TreeSelect } from 'antd';
import { Button, message, Modal, TreeSelect } from 'antd';
import config from '@/utils/config';
import { PageContainer } from '@ant-design/pro-layout';
import { Controlled as CodeMirror } from 'react-codemirror2';

View File

@ -1,5 +1,5 @@
import React, { Fragment, useEffect } from 'react';
import { Button, Row, Input, Form, notification } from 'antd';
import { Button, Row, Input, Form, message } from 'antd';
import config from '@/utils/config';
import { history, Link } from 'umi';
import styles from './index.less';
@ -21,13 +21,9 @@ const Login = () => {
localStorage.setItem(config.authKey, data.token);
history.push('/crontab');
} else if (data.code === 100) {
notification.warn({
message: data.msg,
});
message.warn(data.msg);
} else {
notification.error({
message: data.msg,
});
message.error(data.msg);
}
})
.catch(function (error) {

View File

@ -1,9 +1,9 @@
import { extend } from 'umi-request';
import { notification } from 'antd';
import { message } from 'antd';
import config from './config';
notification.config({
duration: 2,
message.config({
duration: 1.5,
});
const time = Date.now();
@ -13,7 +13,7 @@ const errorHandler = function (error: any) {
? error.data.message || error.data
: error.response.statusText;
if (error.response.status !== 401 && error.response.status !== 502) {
notification.error({ message });
message.error(message);
} else {
console.log(error.response);
}