项目初始化

This commit is contained in:
2026-03-19 10:57:24 +08:00
commit ee94d420ad
3822 changed files with 582614 additions and 0 deletions

View File

@@ -0,0 +1,65 @@
import {
defineAsyncComponent,
// FunctionalComponent, CSSProperties
} from 'vue';
import { noop } from '@jeesite/core/utils';
import { Icon } from '@jeesite/core/components/Icon';
import { ComponentPublicInstance } from 'vue';
// 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;
timeout?: number;
loading?: boolean;
retry?: boolean;
}
export function createAsyncComponent(loader: Fn, options: Options = {}): ComponentPublicInstance | any {
const { size = 'small', delay = 100, timeout = 30000, loading = false, retry = true } = options;
return defineAsyncComponent({
loader,
loadingComponent: loading ? (
<Icon spin={true} size={size} icon={'i-ant-design:loading3-quarters-outlined'} class="mr-2" />
) : undefined,
// The error component will be displayed if a timeout is
// provided and exceeded. Default: Infinity.
timeout,
// errorComponent
// Defining if component is suspensible. Default: true.
// suspensible: false,
delay,
/**
*
* @param {*} error Error message object
* @param {*} retry A function that indicating whether the async component should retry when the loader promise rejects
* @param {*} fail End of failure
* @param {*} attempts Maximum allowed retries number
*/
onError: !retry
? noop
: (error, retry, fail, attempts) => {
if (error.message.match(/fetch/) && attempts <= 3) {
// retry on fetch errors, 3 max attempts
retry();
} else {
// Note that retry/fail are like resolve/reject of a promise:
// one of them must be called for the error handling to continue.
fail();
}
},
});
}