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

<script setup lang="ts">
6 7
import { useUserStore } from "@/store/modules/user";
import { useTransition, TransitionPresets } from "@vueuse/core";
8

9 10 11 12 13
import GithubCorner from "@/components/GithubCorner/index.vue";
import SvgIcon from "@/components/SvgIcon/index.vue";
import BarChart from "./components/BarChart.vue";
import PieChart from "./components/PieChart.vue";
import RadarChart from "./components/RadarChart.vue";
14

H
haoxr 已提交
15 16 17 18 19
const userStore = useUserStore();

const date: Date = new Date();

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

const duration = 5000;

// 收入金额
const amount = ref(0);
const amountOutput = useTransition(amount, {
  duration: duration,
39
  transition: TransitionPresets.easeOutExpo,
40 41 42 43 44 45 46
});
amount.value = 2000;

// 访问数
const visitCount = ref(0);
const visitCountOutput = useTransition(visitCount, {
  duration: duration,
47
  transition: TransitionPresets.easeOutExpo,
48 49 50 51 52 53 54
});
visitCount.value = 2000;

//消息数
const messageCount = ref(0);
const messageCountOutput = useTransition(messageCount, {
  duration: duration,
55
  transition: TransitionPresets.easeOutExpo,
56 57 58 59 60 61 62
});
messageCount.value = 2000;

// 订单数
const orderCount = ref(0);
const orderCountOutput = useTransition(orderCount, {
  duration: duration,
63
  transition: TransitionPresets.easeOutExpo,
64 65
});
orderCount.value = 2000;
66 67
</script>

有来技术 已提交
68
<template>
郝先瑞 已提交
69
  <div class="dashboard-container">
H
haoxr 已提交
70
    <!-- github角标 -->
郝先瑞 已提交
71
    <github-corner class="github-corner" />
72

H
haoxr 已提交
73
    <!-- 用户信息 -->
H
haoxr 已提交
74
    <el-row class="mb-8">
H
haoxr 已提交
75 76
      <el-card class="w-full">
        <div class="flex justify-between flex-wrap">
H
haoxr 已提交
77
          <div class="flex items-center">
H
haoxr 已提交
78 79 80 81
            <img
              class="user-avatar"
              :src="userStore.avatar + '?imageView2/1/w/80/h/80'"
            />
H
haoxr 已提交
82
            <span class="ml-[10px] text-[16px]">
H
haoxr 已提交
83 84 85 86 87 88 89 90
              {{ userStore.nickname }}
            </span>
          </div>

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

H
haoxr 已提交
91
          <div class="space-x-2 flex items-center">
H
haoxr 已提交
92 93 94
            <el-link
              target="_blank"
              type="danger"
95
              href="https://blog.csdn.net/u013737132/article/details/130191394"
H
haoxr 已提交
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
              >官方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 已提交
118 119
    <el-row :gutter="40" class="mb-4">
      <el-col :xs="24" :sm="12" :lg="6" class="mb-4">
H
haoxr 已提交
120 121 122 123 124
        <div class="data-box">
          <div
            class="text-[#40c9c6] hover:!text-white hover:bg-[#40c9c6] p-3 rounded"
          >
            <svg-icon icon-class="uv" size="3em" />
郝先瑞 已提交
125
          </div>
H
haoxr 已提交
126 127 128
          <div class="flex flex-col space-y-3">
            <div class="text-[var(--el-text-color-secondary)]">访问数</div>
            <div class="text-lg">
129
              {{ Math.round(visitCountOutput) }}
H
haoxr 已提交
130
            </div>
郝先瑞 已提交
131 132 133 134
          </div>
        </div>
      </el-col>

H
haoxr 已提交
135
      <!--消息数-->
H
haoxr 已提交
136
      <el-col :xs="24" :sm="12" :lg="6" class="mb-4">
H
haoxr 已提交
137 138 139 140 141
        <div class="data-box">
          <div
            class="text-[#36a3f7] hover:!text-white hover:bg-[#36a3f7] p-3 rounded"
          >
            <svg-icon icon-class="message" size="3em" />
郝先瑞 已提交
142
          </div>
H
haoxr 已提交
143 144 145
          <div class="flex flex-col space-y-3">
            <div class="text-[var(--el-text-color-secondary)]">消息数</div>
            <div class="text-lg">
146
              {{ Math.round(messageCountOutput) }}
H
haoxr 已提交
147
            </div>
郝先瑞 已提交
148 149 150 151
          </div>
        </div>
      </el-col>

H
haoxr 已提交
152
      <el-col :xs="24" :sm="12" :lg="6" class="mb-4">
H
haoxr 已提交
153 154 155 156 157
        <div class="data-box">
          <div
            class="text-[#f4516c] hover:!text-white hover:bg-[#f4516c] p-3 rounded"
          >
            <svg-icon icon-class="money" size="3em" />
郝先瑞 已提交
158
          </div>
H
haoxr 已提交
159 160 161
          <div class="flex flex-col space-y-3">
            <div class="text-[var(--el-text-color-secondary)]">收入金额</div>
            <div class="text-lg">
162
              {{ Math.round(amountOutput) }}
H
haoxr 已提交
163
            </div>
郝先瑞 已提交
164 165 166
          </div>
        </div>
      </el-col>
H
haoxr 已提交
167
      <el-col :xs="24" :sm="12" :lg="6" class="mb-2">
H
haoxr 已提交
168 169 170 171 172
        <div class="data-box">
          <div
            class="text-[#34bfa3] hover:!text-white hover:bg-[#34bfa3] p-3 rounded"
          >
            <svg-icon icon-class="shopping" size="3em" />
郝先瑞 已提交
173
          </div>
H
haoxr 已提交
174 175 176
          <div class="flex flex-col space-y-3">
            <div class="text-[var(--el-text-color-secondary)]">订单数</div>
            <div class="text-lg">
177
              {{ Math.round(orderCountOutput) }}
H
haoxr 已提交
178
            </div>
郝先瑞 已提交
179 180 181 182 183 184
          </div>
        </div>
      </el-col>
    </el-row>

    <!-- Echarts 图表 -->
H
haoxr 已提交
185
    <el-row :gutter="40">
H
haoxr 已提交
186
      <el-col :sm="24" :lg="8" class="mb-4">
郝先瑞 已提交
187 188 189 190
        <BarChart
          id="barChart"
          height="400px"
          width="100%"
H
haoxr 已提交
191
          class="bg-[var(--el-bg-color-overlay)]"
郝先瑞 已提交
192 193 194
        />
      </el-col>

H
haoxr 已提交
195
      <el-col :xs="24" :sm="12" :lg="8" class="mb-4">
郝先瑞 已提交
196 197 198 199
        <PieChart
          id="pieChart"
          height="400px"
          width="100%"
H
haoxr 已提交
200
          class="bg-[var(--el-bg-color-overlay)]"
郝先瑞 已提交
201 202 203
        />
      </el-col>

H
haoxr 已提交
204
      <el-col :xs="24" :sm="12" :lg="8" class="mb-4">
郝先瑞 已提交
205 206 207 208
        <RadarChart
          id="radarChart"
          height="400px"
          width="100%"
H
haoxr 已提交
209
          class="bg-[var(--el-bg-color-overlay)]"
郝先瑞 已提交
210 211 212 213
        />
      </el-col>
    </el-row>
  </div>
有来技术 已提交
214 215
</template>

216 217
<style lang="scss" scoped>
.dashboard-container {
郝先瑞 已提交
218
  position: relative;
219 220
  padding: 24px;

H
haoxr 已提交
221
  .user-avatar {
H
haoxr 已提交
222
    width: 40px;
223
    height: 40px;
H
haoxr 已提交
224 225
    border-radius: 50%;
  }
郝先瑞 已提交
226 227 228

  .github-corner {
    position: absolute;
229
    top: 0;
郝先瑞 已提交
230 231
    right: 0;
    z-index: 99;
232
    border: 0;
郝先瑞 已提交
233 234
  }

H
haoxr 已提交
235
  .data-box {
236 237
    display: flex;
    justify-content: space-between;
H
haoxr 已提交
238
    padding: 20px;
239
    font-weight: bold;
240 241
    color: var(--el-text-color-regular);
    background: var(--el-bg-color-overlay);
242
    border-color: var(--el-border-color);
243
    box-shadow: var(--el-box-shadow-dark);
郝先瑞 已提交
244
  }
245

H
haoxr 已提交
246
  .svg-icon {
247
    fill: currentcolor !important;
H
haoxr 已提交
248
  }
249 250
}
</style>