import { ElLoading } from "element-plus";

let loading: ReturnType<typeof ElLoading.service> | null;

export const openLoading = () => {
  if (loading) return;

  loading = ElLoading.service({
    lock: true,
    text: "加载中",
    background: "rgba(255, 255, 255, 0.4)",
  });
};

export const closeLoading = () => {
  if (loading) {
    loading.close();
    loading = null;
  }
};
