index.vue 6.1 KB
Newer Older
1 2 3 4 5 6 7
<script lang="ts">
export default { name: 'Dashboard' };
</script>

<script setup lang="ts">
import GithubCorner from '@/components/GithubCorner/index.vue';
import SvgIcon from '@/components/SvgIcon/index.vue';
H
haoxr 已提交
8 9 10
import BarChart from './components/BarChart.vue';
import PieChart from './components/PieChart.vue';
import RadarChart from './components/RadarChart.vue';
11

H
haoxr 已提交
12
import CountUp from 'vue-countup-v3';
H
haoxr 已提交
13 14 15 16 17 18 19
import { useUserStore } from '@/store/modules/user';

const userStore = useUserStore();

const date: Date = new Date();

const greetings = computed(() => {
H
haoxr 已提交
20 21
  if (date.getHours() >= 6 && date.getHours() < 8) {
    return '晨起披衣出草堂,轩窗已自喜微凉🌅!';
H
haoxr 已提交
22
  } else if (date.getHours() >= 8 && date.getHours() < 12) {
H
haoxr 已提交
23
    return '上午好🌞!';
H
haoxr 已提交
24 25 26 27 28 29 30 31
  } else if (date.getHours() >= 12 && date.getHours() < 18) {
    return '下午好☕!';
  } else if (date.getHours() >= 18 && date.getHours() < 24) {
    return '晚上好🌃!';
  } else if (date.getHours() >= 0 && date.getHours() < 6) {
    return '偷偷向银河要了一把碎星,只等你闭上眼睛撒入你的梦中,晚安🌛!';
  }
});
32 33
</script>

有来技术 已提交
34
<template>
郝先瑞 已提交
35
  <div class="dashboard-container">
H
haoxr 已提交
36
    <!-- github角标 -->
郝先瑞 已提交
37
    <github-corner class="github-corner" />
38

H
haoxr 已提交
39
    <!-- 用户信息 -->
H
haoxr 已提交
40
    <el-row class="mb-8">
H
haoxr 已提交
41 42
      <el-card class="w-full">
        <div class="flex justify-between flex-wrap">
H
haoxr 已提交
43
          <div class="flex items-center">
H
haoxr 已提交
44 45 46 47
            <img
              class="user-avatar"
              :src="userStore.avatar + '?imageView2/1/w/80/h/80'"
            />
H
haoxr 已提交
48
            <span class="ml-[10px] text-[16px]">
H
haoxr 已提交
49 50 51 52 53 54 55 56
              {{ userStore.nickname }}
            </span>
          </div>

          <div class="leading-[40px]">
            {{ greetings }}
          </div>

H
haoxr 已提交
57
          <div class="space-x-2 flex items-center">
H
haoxr 已提交
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
            <el-link
              target="_blank"
              type="danger"
              href="https://www.cnblogs.com/haoxianrui/p/16090029.html"
              >官方0到1教程</el-link
            >
            <el-divider direction="vertical" />
            <el-link
              target="_blank"
              type="success"
              href="https://gitee.com/youlaiorg/vue3-element-admin"
              >Gitee源码</el-link
            >
            <el-divider direction="vertical" />
            <el-link
              target="_blank"
              type="primary"
              href="https://github.com/youlaitech/vue3-element-admin"
              >GitHub源码
            </el-link>
          </div>
        </div>
      </el-card>
    </el-row>

    <!-- 数据卡片 -->
H
haoxr 已提交
84
    <el-row :gutter="40" class="mb-8">
H
haoxr 已提交
85
      <el-col :xs="24" :sm="12" :lg="6">
H
haoxr 已提交
86 87 88 89 90
        <div class="data-box">
          <div
            class="text-[#40c9c6] hover:!text-white hover:bg-[#40c9c6] p-3 rounded"
          >
            <svg-icon icon-class="uv" size="3em" />
郝先瑞 已提交
91
          </div>
H
haoxr 已提交
92 93 94 95 96
          <div class="flex flex-col space-y-3">
            <div class="text-[var(--el-text-color-secondary)]">访问数</div>
            <div class="text-lg">
              <count-up :end-val="2000"></count-up>
            </div>
郝先瑞 已提交
97 98 99 100
          </div>
        </div>
      </el-col>

H
haoxr 已提交
101
      <!--消息数-->
H
haoxr 已提交
102
      <el-col :xs="24" :sm="12" :lg="6">
H
haoxr 已提交
103 104 105 106 107
        <div class="data-box">
          <div
            class="text-[#36a3f7] hover:!text-white hover:bg-[#36a3f7] p-3 rounded"
          >
            <svg-icon icon-class="message" size="3em" />
郝先瑞 已提交
108
          </div>
H
haoxr 已提交
109 110 111 112 113
          <div class="flex flex-col space-y-3">
            <div class="text-[var(--el-text-color-secondary)]">消息数</div>
            <div class="text-lg">
              <count-up :end-val="2000"></count-up>
            </div>
郝先瑞 已提交
114 115 116 117
          </div>
        </div>
      </el-col>

H
haoxr 已提交
118
      <el-col :xs="24" :sm="12" :lg="6">
H
haoxr 已提交
119 120 121 122 123
        <div class="data-box">
          <div
            class="text-[#f4516c] hover:!text-white hover:bg-[#f4516c] p-3 rounded"
          >
            <svg-icon icon-class="money" size="3em" />
郝先瑞 已提交
124
          </div>
H
haoxr 已提交
125 126 127 128 129
          <div class="flex flex-col space-y-3">
            <div class="text-[var(--el-text-color-secondary)]">收入金额</div>
            <div class="text-lg">
              <count-up :end-val="2000"></count-up>
            </div>
郝先瑞 已提交
130 131 132
          </div>
        </div>
      </el-col>
H
haoxr 已提交
133
      <el-col :xs="24" :sm="12" :lg="6">
H
haoxr 已提交
134 135 136 137 138
        <div class="data-box">
          <div
            class="text-[#34bfa3] hover:!text-white hover:bg-[#34bfa3] p-3 rounded"
          >
            <svg-icon icon-class="shopping" size="3em" />
郝先瑞 已提交
139
          </div>
H
haoxr 已提交
140 141 142 143 144
          <div class="flex flex-col space-y-3">
            <div class="text-[var(--el-text-color-secondary)]">订单数</div>
            <div class="text-lg">
              <count-up :end-val="2000"></count-up>
            </div>
郝先瑞 已提交
145 146 147 148 149 150
          </div>
        </div>
      </el-col>
    </el-row>

    <!-- Echarts 图表 -->
H
haoxr 已提交
151
    <el-row :gutter="40">
H
haoxr 已提交
152
      <el-col :sm="24" :lg="8" class="mb-4">
郝先瑞 已提交
153 154 155 156
        <BarChart
          id="barChart"
          height="400px"
          width="100%"
H
haoxr 已提交
157
          class="bg-[var(--el-bg-color-overlay)]"
郝先瑞 已提交
158 159 160
        />
      </el-col>

H
haoxr 已提交
161
      <el-col :xs="24" :sm="12" :lg="8" class="mb-4">
郝先瑞 已提交
162 163 164 165
        <PieChart
          id="pieChart"
          height="400px"
          width="100%"
H
haoxr 已提交
166
          class="bg-[var(--el-bg-color-overlay)]"
郝先瑞 已提交
167 168 169
        />
      </el-col>

H
haoxr 已提交
170
      <el-col :xs="24" :sm="12" :lg="8" class="mb-4">
郝先瑞 已提交
171 172 173 174
        <RadarChart
          id="radarChart"
          height="400px"
          width="100%"
H
haoxr 已提交
175
          class="bg-[var(--el-bg-color-overlay)]"
郝先瑞 已提交
176 177 178 179
        />
      </el-col>
    </el-row>
  </div>
有来技术 已提交
180 181
</template>

182 183
<style lang="scss" scoped>
.dashboard-container {
郝先瑞 已提交
184 185
  padding: 24px;
  position: relative;
H
haoxr 已提交
186 187
  .user-avatar {
    height: 40px;
H
haoxr 已提交
188
    width: 40px;
H
haoxr 已提交
189 190
    border-radius: 50%;
  }
郝先瑞 已提交
191 192 193 194 195 196 197 198 199

  .github-corner {
    position: absolute;
    top: 0px;
    border: 0;
    right: 0;
    z-index: 99;
  }

H
haoxr 已提交
200 201 202
  .data-box {
    font-weight: bold;
    padding: 20px;
郝先瑞 已提交
203
    cursor: pointer;
204 205
    color: var(--el-text-color-regular);
    background: var(--el-bg-color-overlay);
206 207
    box-shadow: var(--el-box-shadow-dark);
    border-color: var(--el-border-color);
H
haoxr 已提交
208 209
    display: flex;
    justify-content: space-between;
郝先瑞 已提交
210
  }
H
haoxr 已提交
211 212 213
  .svg-icon {
    fill: currentColor !important;
  }
214 215
}
</style>