zhengyiming
2025-02-10 0f686ea1fe4700a909a6159efcf1fcb0e1f88a17
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
<template>
  <div v-if="loading" class="loading-layout-loading-content-wrapper">
    <IconFont name="loading" />
    <div class="list-empty-hint-text">数据加载中......</div>
  </div>
  <nut-empty
    v-else-if="error"
    class="loading-layout-error-wrapper"
    status="error"
    description="加载失败"
  >
    <div :style="{ marginTop: '10px' }">
      <nut-button type="primary" @click="loadError"> 重试 </nut-button>
    </div>
  </nut-empty>
  <template v-else>
    <NoData v-if="showNoData" />
    <slot v-else></slot>
  </template>
</template>
 
<script setup lang="ts">
import { loadingLayoutProps } from './layout';
import { IconFont } from '@nutui/icons-vue-taro';
import NoData from '../NoData/NoData.vue';
 
defineOptions({
  name: 'LoadingLayout',
});
 
const props = defineProps(loadingLayoutProps);
</script>
 
<style lang="scss">
@import '@/styles/common.scss';
 
.loading-layout-loading-content-wrapper {
  padding: 40px;
  display: flex;
  justify-content: center;
  align-items: center;
 
  .nut-icon {
    color: boleGetCssVar('text-color', 'primary');
    margin-right: 8px;
  }
 
  .list-empty-hint-text {
    line-height: 1;
    font-size: 30px;
    color: boleGetCssVar('text-color', 'primary');
  }
}
 
.loading-layout-error-wrapper {
  height: 100%;
}
</style>