mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-08-27 14:31:41 +08:00
fix(comp): fix the memory overflow problem of component containing keywords
This commit is contained in:
@@ -1,6 +1,24 @@
|
||||
import { defineAsyncComponent } from 'vue';
|
||||
import {
|
||||
defineAsyncComponent,
|
||||
// FunctionalComponent, CSSProperties
|
||||
} from 'vue';
|
||||
import { Spin } from 'ant-design-vue';
|
||||
import { noop } from '/@/utils/index';
|
||||
|
||||
// const Loading: FunctionalComponent<{ size: 'small' | 'default' | 'large' }> = (props) => {
|
||||
// const style: CSSProperties = {
|
||||
// position: 'absolute',
|
||||
// display: 'flex',
|
||||
// justifyContent: 'center',
|
||||
// alignItems: 'center',
|
||||
// };
|
||||
// return (
|
||||
// <div style={style}>
|
||||
// <Spin spinning={true} size={props.size} />
|
||||
// </div>
|
||||
// );
|
||||
// };
|
||||
|
||||
interface Options {
|
||||
size?: 'default' | 'small' | 'large';
|
||||
delay?: number;
|
||||
@@ -10,7 +28,7 @@ interface Options {
|
||||
}
|
||||
|
||||
export function createAsyncComponent(loader: Fn, options: Options = {}) {
|
||||
const { size = 'small', delay = 100, timeout = 3000, loading = true, retry = true } = options;
|
||||
const { size = 'small', delay = 100, timeout = 30000, loading = false, retry = true } = options;
|
||||
return defineAsyncComponent({
|
||||
loader,
|
||||
loadingComponent: loading ? <Spin spinning={true} size={size} /> : undefined,
|
||||
|
@@ -106,7 +106,7 @@ const transform: AxiosTransform = {
|
||||
if (apiUrl && isString(apiUrl)) {
|
||||
config.url = `${apiUrl}${config.url}`;
|
||||
}
|
||||
if (config.method === RequestEnum.GET) {
|
||||
if (config.method?.toUpperCase() === RequestEnum.GET) {
|
||||
const now = new Date().getTime();
|
||||
if (!isString(config.params)) {
|
||||
config.data = {
|
||||
@@ -157,14 +157,13 @@ const transform: AxiosTransform = {
|
||||
const { t } = useI18n();
|
||||
errorStore.setupErrorHandle(error);
|
||||
const { response, code, message } = error || {};
|
||||
const msg: string =
|
||||
response && response.data && response.data.error ? response.data.error.message : '';
|
||||
const err: string = error.toString();
|
||||
const msg: string = response?.data?.error ? response.data.error.message : '';
|
||||
const err: string = error?.toString();
|
||||
try {
|
||||
if (code === 'ECONNABORTED' && message.indexOf('timeout') !== -1) {
|
||||
createMessage.error(t('sys.api.apiTimeoutMessage'));
|
||||
}
|
||||
if (err && err.includes('Network Error')) {
|
||||
if (err?.includes('Network Error')) {
|
||||
createErrorModal({
|
||||
title: t('sys.api.networkException'),
|
||||
content: t('sys.api.networkExceptionMsg'),
|
||||
@@ -173,7 +172,7 @@ const transform: AxiosTransform = {
|
||||
} catch (error) {
|
||||
throw new Error(error);
|
||||
}
|
||||
checkStatus(error.response && error.response.status, msg);
|
||||
checkStatus(error?.response?.status, msg);
|
||||
return Promise.reject(error);
|
||||
},
|
||||
};
|
||||
|
Reference in New Issue
Block a user