<template>
  <div class="loading" v-show="visible">
    <TnLoading show type="primary" size="30"/>
    <div class="title">{{ title || '加载中...' }}</div>
  </div>
</template>

<script lang="ts" setup>
import TnLoading from '@tncnt/loading/src/loading.vue';
import { ref } from 'vue';
const visible = ref(false);
const title = ref('');
defineExpose({
  show: (_title?: string) => {
    title.value = _title || '';
    visible.value = true;
  },
  hide: () => {
    visible.value = false;
    title.value = '';
  },
});


</script>

<style lang="scss">
.loading {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: #fff;
  background-color: rgba(0, 0, 0, 0.6);
  z-index: 3000;
  .title {
    margin-top: 16px;
    color: #fff !important;
  }
}
</style>
