zhengyiming
2025-06-24 da9859ae52f7c90165cfe76dbe8b824d1505ab0b
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();
    });
  });
}