style: error message toast
This commit is contained in:
@@ -0,0 +1,44 @@
|
|||||||
|
import { CheckCircleFilled, CopyOutlined } from '@ant-design/icons';
|
||||||
|
import { Typography } from 'antd';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
|
||||||
|
const Content = styled.div`
|
||||||
|
position: relative;
|
||||||
|
.cp-btn {
|
||||||
|
position: absolute;
|
||||||
|
top: 0px;
|
||||||
|
right: -4px;
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
&:hover .cp-btn {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
.msg {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const ErrorMessageContent: React.FC<{ errMsg: string }> = ({ errMsg }) => {
|
||||||
|
return (
|
||||||
|
<Content>
|
||||||
|
<Typography.Text
|
||||||
|
className="cp-btn"
|
||||||
|
copyable={{
|
||||||
|
text: errMsg,
|
||||||
|
icon: [
|
||||||
|
<CopyOutlined style={{ fontSize: 14 }} key="copy" />,
|
||||||
|
<CheckCircleFilled
|
||||||
|
style={{ color: 'var(--ant-color-success)', fontSize: 14 }}
|
||||||
|
key="copied"
|
||||||
|
/>
|
||||||
|
]
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<span className="msg">{errMsg}</span>
|
||||||
|
</Typography.Text>
|
||||||
|
{errMsg}
|
||||||
|
</Content>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ErrorMessageContent;
|
||||||
+15
-2
@@ -1,4 +1,5 @@
|
|||||||
import { createAxiosToken } from '@/hooks/use-chunk-request';
|
import { createAxiosToken } from '@/hooks/use-chunk-request';
|
||||||
|
import ErrorMessageContent from '@/pages/_components/error-message-content';
|
||||||
import { useRequest } from 'ahooks';
|
import { useRequest } from 'ahooks';
|
||||||
import { message } from 'antd';
|
import { message } from 'antd';
|
||||||
import { CancelTokenSource } from 'axios';
|
import { CancelTokenSource } from 'axios';
|
||||||
@@ -105,11 +106,23 @@ export const useTestProviderModel = () => {
|
|||||||
manual: true,
|
manual: true,
|
||||||
onSuccess: (response) => {
|
onSuccess: (response) => {
|
||||||
if (!response?.accessible) {
|
if (!response?.accessible) {
|
||||||
message.error(response?.error_message || 'Test model failed');
|
message.error({
|
||||||
|
content: (
|
||||||
|
<ErrorMessageContent
|
||||||
|
errMsg={response?.error_message || 'Test model failed'}
|
||||||
|
></ErrorMessageContent>
|
||||||
|
)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
message.error(error?.message || 'Test model failed');
|
message.error({
|
||||||
|
content: (
|
||||||
|
<ErrorMessageContent
|
||||||
|
errMsg={error?.message || 'Test model failed'}
|
||||||
|
></ErrorMessageContent>
|
||||||
|
)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
+3
-31
@@ -1,25 +1,9 @@
|
|||||||
import { userAtom } from '@/atoms/user';
|
import { userAtom } from '@/atoms/user';
|
||||||
import { clearAtomStorage } from '@/atoms/utils';
|
import { clearAtomStorage } from '@/atoms/utils';
|
||||||
import { history, RequestConfig } from '@umijs/max';
|
import { history, RequestConfig } from '@umijs/max';
|
||||||
import { message, Typography } from 'antd';
|
import { message } from 'antd';
|
||||||
import styled from 'styled-components';
|
|
||||||
import { DEFAULT_ENTER_PAGE } from './config/settings';
|
import { DEFAULT_ENTER_PAGE } from './config/settings';
|
||||||
|
import ErrorMessageContent from './pages/_components/error-message-content';
|
||||||
const Content = styled.div`
|
|
||||||
position: relative;
|
|
||||||
.cp-btn {
|
|
||||||
position: absolute;
|
|
||||||
top: 0px;
|
|
||||||
right: -4px;
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
&:hover .cp-btn {
|
|
||||||
display: inline-block;
|
|
||||||
}
|
|
||||||
.msg {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
// these APIs do not via the GPUSTACK_API_BASE_URL
|
// these APIs do not via the GPUSTACK_API_BASE_URL
|
||||||
const NoBaseURLAPIs = ['/auth', '/v1', '/version', '/proxy', '/update'];
|
const NoBaseURLAPIs = ['/auth', '/v1', '/version', '/proxy', '/update'];
|
||||||
@@ -42,19 +26,7 @@ export const requestConfig: RequestConfig = {
|
|||||||
|
|
||||||
if (!opts?.skipErrorHandler && response?.status) {
|
if (!opts?.skipErrorHandler && response?.status) {
|
||||||
message.error({
|
message.error({
|
||||||
content: (
|
content: <ErrorMessageContent errMsg={errMsg}></ErrorMessageContent>
|
||||||
<Content>
|
|
||||||
<Typography.Text
|
|
||||||
className="cp-btn"
|
|
||||||
copyable={{
|
|
||||||
text: errMsg
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<span className="msg">{errMsg}</span>
|
|
||||||
</Typography.Text>
|
|
||||||
{errMsg}
|
|
||||||
</Content>
|
|
||||||
)
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (response?.status === 401) {
|
if (response?.status === 401) {
|
||||||
|
|||||||
Reference in New Issue
Block a user