welcome.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <script setup lang="ts">
  2. import { ref, shallowRef, computed, onBeforeMount } from "vue";
  3. import { useAppStoreHook } from "/@/store/modules/app";
  4. import {
  5. ReGithub,
  6. ReInfinite,
  7. RePie,
  8. ReLine,
  9. ReBar
  10. } from "/@/components/ReCharts/index";
  11. const date: Date = new Date();
  12. let loading = ref<boolean>(true);
  13. const componentList = shallowRef<ForDataType<undefined>>([]);
  14. setTimeout(() => {
  15. loading.value = !loading.value;
  16. }, 500);
  17. let greetings = computed(() => {
  18. if (date.getHours() >= 0 && date.getHours() < 12) {
  19. return "上午阳光明媚,祝你薪水翻倍🌞!";
  20. } else if (date.getHours() >= 12 && date.getHours() < 18) {
  21. return "下午小风娇好,愿你青春不老😃!";
  22. } else {
  23. return "折一根天使羽毛,愿拂去您的疲惫烦恼忧伤🌛!";
  24. }
  25. });
  26. onBeforeMount(() => {
  27. if (useAppStoreHook().device === "mobile") {
  28. componentList.value = [
  29. {
  30. width: "20em",
  31. title: "GitHub饼图信息",
  32. component: RePie
  33. },
  34. {
  35. width: "20em",
  36. title: "GitHub折线图信息",
  37. component: ReLine
  38. },
  39. {
  40. width: "20em",
  41. title: "GitHub柱状图信息",
  42. component: ReBar
  43. }
  44. ];
  45. } else {
  46. componentList.value = [
  47. {
  48. width: "43em",
  49. title: "GitHub信息",
  50. component: ReGithub
  51. },
  52. {
  53. width: "43em",
  54. title: "GitHub滚动信息",
  55. component: ReInfinite
  56. },
  57. {
  58. width: "28.28em",
  59. title: "GitHub饼图信息",
  60. component: RePie
  61. },
  62. {
  63. width: "28.28em",
  64. title: "GitHub折线图信息",
  65. component: ReLine
  66. },
  67. {
  68. width: "28.28em",
  69. title: "GitHub柱状图信息",
  70. component: ReBar
  71. }
  72. ];
  73. }
  74. });
  75. const openDepot = (): void => {
  76. window.open("https://github.com/xiaoxian521/vue-pure-admin");
  77. };
  78. </script>
  79. <template>
  80. <div class="welcome">
  81. <el-card class="top-content">
  82. <div class="left-mark">
  83. <img
  84. src="https://avatars.githubusercontent.com/u/44761321?s=400&u=30907819abd29bb3779bc247910873e7c7f7c12f&v=4"
  85. title="直达仓库地址"
  86. alt
  87. @click="openDepot"
  88. />
  89. <span>{{ greetings }}</span>
  90. </div>
  91. </el-card>
  92. <el-space class="space" wrap size="large">
  93. <el-skeleton
  94. v-for="(item, key) in componentList"
  95. :key="key"
  96. animated
  97. :rows="7"
  98. :loading="loading"
  99. :class="$style.size"
  100. :style="{ width: item.width }"
  101. >
  102. <template #default>
  103. <div
  104. :class="['echart-card', $style.size]"
  105. :style="{ width: item.width }"
  106. >
  107. <h4>{{ item.title }}</h4>
  108. <component :is="item.component"></component>
  109. </div>
  110. </template>
  111. </el-skeleton>
  112. </el-space>
  113. </div>
  114. </template>
  115. <style module scoped>
  116. .size {
  117. height: 335px;
  118. }
  119. </style>
  120. <style lang="scss" scoped>
  121. .welcome {
  122. width: 100%;
  123. height: 100%;
  124. .top-content {
  125. display: flex;
  126. justify-content: space-between;
  127. align-items: center;
  128. height: 60px;
  129. background: #fff;
  130. .left-mark {
  131. display: flex;
  132. align-items: center;
  133. img {
  134. display: block;
  135. width: 50px;
  136. height: 50px;
  137. border-radius: 50%;
  138. margin-right: 10px;
  139. cursor: pointer;
  140. }
  141. span {
  142. font-size: 14px;
  143. }
  144. }
  145. }
  146. .space {
  147. display: flex;
  148. justify-content: center;
  149. align-items: center;
  150. margin-left: 8px;
  151. padding: 10px;
  152. .echart-card {
  153. box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 0 6px rgba(0, 0, 0, 0.04);
  154. h4 {
  155. margin: 0;
  156. padding: 20px;
  157. }
  158. }
  159. }
  160. }
  161. </style>