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, 6,
1, 1,
).toString()} * * *`, ).toString()} * * *`,
status: CrontabStatus.idle, status: CrontabStatus.disabled,
}, },
{ {
name: '删除日志', name: '删除日志',

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,5 @@
import React, { PureComponent, Fragment, useState, useEffect } from 'react'; 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 config from '@/utils/config';
import { PageContainer } from '@ant-design/pro-layout'; import { PageContainer } from '@ant-design/pro-layout';
import { request } from '@/utils/http'; import { request } from '@/utils/http';

View File

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

View File

@ -1,5 +1,5 @@
import React, { PureComponent, Fragment, useState, useEffect } from 'react'; 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 config from '@/utils/config';
import { PageContainer } from '@ant-design/pro-layout'; import { PageContainer } from '@ant-design/pro-layout';
import { Controlled as CodeMirror } from 'react-codemirror2'; import { Controlled as CodeMirror } from 'react-codemirror2';

View File

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

View File

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