index.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. <template>
  2. <div class="dashboard-container">
  3. <!-- github角标 -->
  4. <!-- <github-corner class="github-corner" />-->
  5. <el-card shadow="never">
  6. <el-row justify="space-between">
  7. <el-col :span="18" :xs="24">
  8. <div class="flex h-full items-center">
  9. <img
  10. class="w-20 h-20 mr-5 rounded-full"
  11. :src="userStore.user.avatar + '?imageView2/1/w/80/h/80'"
  12. />
  13. <div>
  14. <p>{{ greetings }}</p>
  15. <p class="text-sm text-gray">
  16. 今日天气晴朗,气温在15℃至25℃之间,东南风。
  17. </p>
  18. </div>
  19. </div>
  20. </el-col>
  21. <el-col :span="6" :xs="24">
  22. <div class="flex h-full items-center justify-around">
  23. <el-statistic :value="99">
  24. <template #title>
  25. <div class="flex items-center">
  26. <svg-icon icon-class="message" size="20px" />
  27. <span class="text-[16px] ml-1">消息</span>
  28. </div>
  29. </template>
  30. </el-statistic>
  31. <el-statistic :value="50">
  32. <template #title>
  33. <div class="flex items-center">
  34. <svg-icon icon-class="todolist" size="20px" />
  35. <span class="text-[16px] ml-1">待办</span>
  36. </div>
  37. </template>
  38. <template #suffix>/100</template>
  39. </el-statistic>
  40. <el-statistic :value="10">
  41. <template #title>
  42. <div class="flex items-center">
  43. <svg-icon icon-class="project" size="20px" />
  44. <span class="text-[16px] ml-1">项目</span>
  45. </div>
  46. </template>
  47. </el-statistic>
  48. </div>
  49. </el-col>
  50. </el-row>
  51. </el-card>
  52. <!-- 数据卡片 -->
  53. <el-row :gutter="10" class="mt-3">
  54. <el-col :xs="24" :sm="12" :lg="6">
  55. <el-card shadow="never">
  56. <template #header>
  57. <div class="flex items-center justify-between">
  58. <span class="text-[var(--el-text-color-secondary)]">访客数</span>
  59. <el-tag type="success">日</el-tag>
  60. </div>
  61. </template>
  62. <div class="flex items-center justify-between mt-5">
  63. <div class="text-lg text-right">
  64. {{ Math.round(visitCountOutput) }}
  65. </div>
  66. <svg-icon icon-class="visit" size="2em" />
  67. </div>
  68. <div
  69. class="flex items-center justify-between mt-5 text-sm text-[var(--el-text-color-secondary)]"
  70. >
  71. <span> 总访客数 </span>
  72. <span> {{ Math.round(visitCountOutput * 15) }} </span>
  73. </div>
  74. </el-card>
  75. </el-col>
  76. <!--消息数-->
  77. <el-col :xs="24" :sm="12" :lg="6">
  78. <el-card shadow="never">
  79. <template #header>
  80. <div class="flex items-center justify-between">
  81. <span class="text-[var(--el-text-color-secondary)]">IP数</span>
  82. <el-tag type="success">日</el-tag>
  83. </div>
  84. </template>
  85. <div class="flex items-center justify-between mt-5">
  86. <div class="text-lg text-right">
  87. {{ Math.round(dauCountOutput) }}
  88. </div>
  89. <svg-icon icon-class="ip" size="2em" />
  90. </div>
  91. <div
  92. class="flex items-center justify-between mt-5 text-sm text-[var(--el-text-color-secondary)]"
  93. >
  94. <span> 总IP数 </span>
  95. <span> {{ Math.round(dauCountOutput) }} </span>
  96. </div>
  97. </el-card>
  98. </el-col>
  99. <!--销售额-->
  100. <el-col :xs="24" :sm="12" :lg="6">
  101. <el-card shadow="never">
  102. <template #header>
  103. <div class="flex items-center justify-between">
  104. <span class="text-[var(--el-text-color-secondary)]">产品数</span>
  105. <el-tag>月</el-tag>
  106. </div>
  107. </template>
  108. <div class="flex items-center justify-between mt-5">
  109. <div class="text-lg text-right">
  110. {{ Math.round(amountOutput) }}
  111. </div>
  112. <svg-icon icon-class="money" size="2em" />
  113. </div>
  114. <div
  115. class="flex items-center justify-between mt-5 text-sm text-[var(--el-text-color-secondary)]"
  116. >
  117. <span> 总产品数 </span>
  118. <span> {{ Math.round(amountOutput * 15) }} </span>
  119. </div>
  120. </el-card>
  121. </el-col>
  122. <!--订单量-->
  123. <el-col :xs="24" :sm="12" :lg="6">
  124. <el-card shadow="never">
  125. <template #header>
  126. <div class="flex items-center justify-between">
  127. <span class="text-[var(--el-text-color-secondary)]">订单量</span>
  128. <el-tag type="danger">季</el-tag>
  129. </div>
  130. </template>
  131. <div class="flex items-center justify-between mt-5">
  132. <div class="text-lg text-right">
  133. {{ Math.round(orderCountOutput) }}
  134. </div>
  135. <svg-icon icon-class="order" size="2em" />
  136. </div>
  137. <div
  138. class="flex items-center justify-between mt-5 text-sm text-[var(--el-text-color-secondary)]"
  139. >
  140. <span> 总订单量 </span>
  141. <span> {{ Math.round(orderCountOutput * 15) }} </span>
  142. </div>
  143. </el-card>
  144. </el-col>
  145. </el-row>
  146. <!-- Echarts 图表 -->
  147. <el-row :gutter="10" class="mt-3">
  148. <el-col :sm="24" :lg="8" class="mb-2">
  149. <BarChart
  150. id="barChart"
  151. height="400px"
  152. width="100%"
  153. class="bg-[var(--el-bg-color-overlay)]"
  154. />
  155. </el-col>
  156. <el-col :xs="24" :sm="12" :lg="8" class="mb-2">
  157. <PieChart
  158. id="pieChart"
  159. height="400px"
  160. width="100%"
  161. class="bg-[var(--el-bg-color-overlay)]"
  162. />
  163. </el-col>
  164. <el-col :xs="24" :sm="12" :lg="8" class="mb-2">
  165. <RadarChart
  166. id="radarChart"
  167. height="400px"
  168. width="100%"
  169. class="bg-[var(--el-bg-color-overlay)]"
  170. />
  171. </el-col>
  172. </el-row>
  173. </div>
  174. </template>
  175. <script setup lang="ts">
  176. defineOptions({
  177. name: "Dashboard",
  178. inheritAttrs: false,
  179. });
  180. import { useUserStore } from "@/store/modules/user";
  181. import { useTransition, TransitionPresets } from "@vueuse/core";
  182. const userStore = useUserStore();
  183. const date: Date = new Date();
  184. const greetings = computed?.(() => {
  185. const hours = date.getHours();
  186. if (hours >= 6 && hours < 8) {
  187. return "晨起披衣出草堂,轩窗已自喜微凉🌅!";
  188. } else if (hours >= 8 && hours < 12) {
  189. return "上午好," + userStore.user.userName + "!";
  190. } else if (hours >= 12 && hours < 18) {
  191. return "下午好," + userStore.user.userName + "!";
  192. } else if (hours >= 18 && hours < 24) {
  193. return "晚上好," + userStore.user.userName + "!";
  194. } else if (hours >= 0 && hours < 6) {
  195. return "偷偷向银河要了一把碎星,只等你闭上眼睛撒入你的梦中,晚安🌛!";
  196. }
  197. });
  198. const duration = 5000;
  199. // 销售额
  200. const amount = ref(0);
  201. const amountOutput = useTransition(amount, {
  202. duration: duration,
  203. transition: TransitionPresets.easeOutExpo,
  204. });
  205. amount.value = 2000;
  206. // 访客数
  207. const visitCount = ref(0);
  208. const visitCountOutput = useTransition(visitCount, {
  209. duration: duration,
  210. transition: TransitionPresets.easeOutExpo,
  211. });
  212. visitCount.value = 2000;
  213. // IP数
  214. const dauCount = ref(0);
  215. const dauCountOutput = useTransition(dauCount, {
  216. duration: duration,
  217. transition: TransitionPresets.easeOutExpo,
  218. });
  219. dauCount.value = 2000;
  220. // 订单量
  221. const orderCount = ref(0);
  222. const orderCountOutput = useTransition(orderCount, {
  223. duration: duration,
  224. transition: TransitionPresets.easeOutExpo,
  225. });
  226. orderCount.value = 2000;
  227. </script>
  228. <style lang="scss" scoped>
  229. .dashboard-container {
  230. position: relative;
  231. padding: 24px;
  232. .user-avatar {
  233. width: 40px;
  234. height: 40px;
  235. border-radius: 50%;
  236. }
  237. .github-corner {
  238. position: absolute;
  239. top: 0;
  240. right: 0;
  241. z-index: 1;
  242. border: 0;
  243. }
  244. .data-box {
  245. display: flex;
  246. justify-content: space-between;
  247. padding: 20px;
  248. font-weight: bold;
  249. color: var(--el-text-color-regular);
  250. background: var(--el-bg-color-overlay);
  251. border-color: var(--el-border-color);
  252. box-shadow: var(--el-box-shadow-dark);
  253. }
  254. .svg-icon {
  255. fill: currentcolor !important;
  256. }
  257. }
  258. </style>