zhengyiming
2025-02-10 958b79ed89b9e742540f714a80261d222c0fc09b
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
<template>
  <div :class="isDesktop ? 'desktop-no-data' : 'no-data'">
    <img v-if="type == 'content'" :src="noContent" />
    <img v-else-if="type == 'network'" :src="noNetwork" />
    <img v-else :src="noData" />
    <slot name="no-data-text">
      <div class="no-data-text">{{ noDataText }}</div>
    </slot>
  </div>
</template>
<script setup lang="ts">
import noContent from '@/assets/components/icon-no-data.png';
import noNetwork from '@/assets/components/icon-no-net.png';
import noData from '@/assets/components/icon-no-data.png';
const NoDataText = {
  content: '暂无内容',
  data: '暂无数据',
  network: '暂无网络',
};
 
type Props = {
  type?: keyof typeof NoDataText;
  text?: string;
  isDesktop?: boolean;
};
 
const props = withDefaults(defineProps<Props>(), {
  type: 'data',
  text: '',
  isDesktop: false,
});
 
const noDataText = computed(() => {
  return props.text ? props.text : NoDataText[props.type];
});
</script>
 
<style lang="scss" scoped>
.no-data {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  // margin-top: 10vh;
  flex: 1;
 
  img {
    display: block;
    margin: 0 auto;
  }
 
  .no-data-text {
    margin-top: 20px;
    font-size: 22px;
    text-align: center;
    color: #67666e;
  }
}
 
.desktop-no-data {
  padding-bottom: 16px;
 
  img {
    display: block;
    margin: 0 auto;
    width: 14%;
  }
 
  .no-data-text {
    font-size: 20px;
    text-align: center;
    color: #67666e;
  }
}
</style>