刘光辉
10 小时以前 0dfe84494048ce27ba8449831782128412d3eb13
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<script lang="ts">
  import { defineComponent, PropType } from 'vue';
 
  import { Spin } from 'ant-design-vue';
 
  import { SizeEnum } from './typing';
 
  export default defineComponent({
    components: { Spin },
    name: 'Loading',
    props: {
      absolute: {
        default: false,
        type: Boolean as PropType<boolean>,
      },
      background: {
        type: String as PropType<string>,
      },
      loading: {
        default: false,
        type: Boolean as PropType<boolean>,
      },
      size: {
        default: SizeEnum.LARGE,
        type: String as PropType<SizeEnum>,
        validator: (v: SizeEnum): boolean => {
          return [SizeEnum.DEFAULT, SizeEnum.LARGE, SizeEnum.SMALL].includes(v);
        },
      },
      theme: {
        type: String as PropType<'dark' | 'light'>,
      },
      tip: {
        default: '',
        type: String as PropType<string>,
      },
    },
  });
</script>
<template>
  <section class="full-loading" :class="{ absolute }" :style="[background ? `background-color: ${background}` : '']" v-show="loading">
    <Spin v-bind="$attrs" :tip="tip" :size="size" :spinning="loading" />
  </section>
</template>
<style lang="scss" scoped>
  .full-loading {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background-color: #fff;
 
    &.absolute {
      position: absolute;
      top: 0;
      left: 0;
      z-index: 300;
    }
  }
 
  .dark {
    .full-loading:not(.light) {
      background-color: rgb(0 0 0 / 5%);
    }
  }
 
  .full-loading.dark {
    background-color: rgb(0 0 0 / 5%);
  }
</style>