wupengfei
2025-09-12 ec76c13fac4f9937e62e6244624c3fb98c398538
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import { ElLoading } from 'element-plus';
 
export function useLoading(config?: { text: string; background?: string }) {
  return new Promise<() => void>((resolve, _reject) => {
    const loading = ElLoading.service({
      lock: true,
      text: config?.text ?? '加载中',
      background: config?.background ?? 'rgba(0, 0, 0, 0)',
    });
 
    resolve(() => {
      loading.close();
    });
  });
}