index.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. <script setup lang="ts">
  2. import dayjs from "dayjs";
  3. import axios from "axios";
  4. import MdEditor from "md-editor-v3";
  5. import VueDanmaku from "vue3-danmaku";
  6. import Bar from "./components/Bar.vue";
  7. import Pie from "./components/Pie.vue";
  8. import Line from "./components/Line.vue";
  9. import TypeIt from "@/components/ReTypeit";
  10. import Github from "./components/Github.vue";
  11. import { openLink, randomColor } from "@pureadmin/utils";
  12. import { useRenderFlicker } from "@/components/ReFlicker";
  13. import { ref, computed, markRaw, onMounted, onUnmounted } from "vue";
  14. defineOptions({
  15. name: "Welcome"
  16. });
  17. const danmus = [
  18. "太好用了吧",
  19. "so easy",
  20. "效率大大提高呀",
  21. "还有精简版,还分国际化和非国际化,Perfect 😘",
  22. "好多组件呀,爱啦爱啦 ❤️",
  23. "精简版开发体验也太赞了吧 🙀",
  24. "pure-admin-table 真方便呀",
  25. "哇塞,pure-admin-utils 好多常用、易用的工具呀",
  26. "我要 star 这个项目,爱啦爱啦",
  27. "免费、开源做到这个程度,真不错 👍",
  28. "文档简单易懂,上手真快",
  29. "呀!还有免费的教学视频呢,我要去学习一下咯",
  30. "稳定、可靠,未来可期呀,加油!",
  31. "太卷了,太卷了,慢点让我跟上 😄"
  32. ];
  33. let timer = 0;
  34. const list = ref();
  35. const danmaku = ref();
  36. const date: Date = new Date();
  37. const loading = ref<boolean>(true);
  38. const titleClass = computed(() => {
  39. return ["text-base", "font-medium"];
  40. });
  41. setTimeout(() => {
  42. loading.value = !loading.value;
  43. }, 800);
  44. const greetings = computed(() => {
  45. if (date.getHours() >= 0 && date.getHours() < 12) {
  46. return "上午阳光明媚,祝你薪水翻倍🌞!";
  47. } else if (date.getHours() >= 12 && date.getHours() < 18) {
  48. return "下午小风娇好,愿你青春不老😃!";
  49. } else {
  50. return "折一根天使羽毛,愿拂去您的疲惫烦恼忧伤🌛!";
  51. }
  52. });
  53. function resizeHandler() {
  54. if (timer) clearTimeout(timer);
  55. timer = window.setTimeout(() => {
  56. danmaku.value.resize();
  57. }, 500);
  58. }
  59. axios
  60. .get("https://api.github.com/repos/xiaoxian521/vue-pure-admin/releases")
  61. .then(res => {
  62. list.value = res.data.map(v => {
  63. return {
  64. content: v.body,
  65. timestamp: dayjs(v.published_at).format("YYYY/MM/DD hh:mm:ss A"),
  66. icon: markRaw(
  67. useRenderFlicker({
  68. background: randomColor({ type: "hex" }) as string
  69. })
  70. )
  71. };
  72. });
  73. });
  74. onMounted(() => {
  75. window.onresize = () => resizeHandler();
  76. });
  77. onUnmounted(() => {
  78. window.onresize = null;
  79. });
  80. </script>
  81. <template>
  82. <div class="welcome">
  83. <el-card class="top-content dark:border-none">
  84. <div class="left-mark select-none">
  85. <img
  86. src="https://avatars.githubusercontent.com/u/44761321?v=4"
  87. title="直达仓库地址"
  88. @click="openLink('https://github.com/xiaoxian521/vue-pure-admin')"
  89. />
  90. <TypeIt
  91. :className="'type-it0'"
  92. :values="[greetings]"
  93. :cursor="false"
  94. :speed="60"
  95. />
  96. </div>
  97. </el-card>
  98. <el-row :gutter="24" style="margin: 20px">
  99. <el-col
  100. :xs="24"
  101. :sm="24"
  102. :md="12"
  103. :lg="12"
  104. :xl="12"
  105. style="margin-bottom: 20px"
  106. v-motion
  107. :initial="{
  108. opacity: 0,
  109. y: 100
  110. }"
  111. :enter="{
  112. opacity: 1,
  113. y: 0,
  114. transition: {
  115. delay: 200
  116. }
  117. }"
  118. >
  119. <el-card style="height: 410px">
  120. <template #header>
  121. <a
  122. :class="titleClass"
  123. href="https://github.com/xiaoxian521"
  124. target="_black"
  125. >
  126. <TypeIt
  127. :className="'type-it1'"
  128. :values="['GitHub信息']"
  129. :cursor="false"
  130. :speed="120"
  131. />
  132. </a>
  133. </template>
  134. <el-skeleton animated :rows="7" :loading="loading">
  135. <template #default>
  136. <Github />
  137. <vue-danmaku
  138. ref="danmaku"
  139. loop
  140. useSlot
  141. isSuspend
  142. randomChannel
  143. :debounce="1200"
  144. :danmus="danmus"
  145. style="width: 100%; height: 80px"
  146. >
  147. <template v-slot:dm="{ danmu }">
  148. <p :style="{ color: randomColor({ type: 'hex' }) as string }">
  149. {{ danmu }}
  150. </p>
  151. </template>
  152. </vue-danmaku>
  153. </template>
  154. </el-skeleton>
  155. </el-card>
  156. </el-col>
  157. <el-col
  158. :xs="24"
  159. :sm="24"
  160. :md="12"
  161. :lg="12"
  162. :xl="12"
  163. style="margin-bottom: 20px"
  164. v-motion
  165. :initial="{
  166. opacity: 0,
  167. y: 100
  168. }"
  169. :enter="{
  170. opacity: 1,
  171. y: 0,
  172. transition: {
  173. delay: 200
  174. }
  175. }"
  176. >
  177. <el-card style="height: 410px">
  178. <template #header>
  179. <a
  180. :class="titleClass"
  181. href="https://github.com/xiaoxian521/vue-pure-admin/releases"
  182. target="_black"
  183. >
  184. <TypeIt
  185. :className="'type-it2'"
  186. :values="['Pure-Admin 版本日志']"
  187. :cursor="false"
  188. :speed="80"
  189. />
  190. </a>
  191. </template>
  192. <el-skeleton animated :rows="7" :loading="loading">
  193. <template #default>
  194. <el-scrollbar height="324px">
  195. <el-timeline v-show="list?.length > 0">
  196. <el-timeline-item
  197. v-for="(item, index) in list"
  198. :key="index"
  199. :icon="item.icon"
  200. :timestamp="item.timestamp"
  201. >
  202. <md-editor v-model="item.content" preview-only />
  203. </el-timeline-item>
  204. </el-timeline>
  205. <el-empty v-show="list?.length === 0" />
  206. </el-scrollbar>
  207. </template>
  208. </el-skeleton>
  209. </el-card>
  210. </el-col>
  211. <el-col
  212. :xs="24"
  213. :sm="24"
  214. :md="12"
  215. :lg="8"
  216. :xl="8"
  217. style="margin-bottom: 20px"
  218. v-motion
  219. :initial="{
  220. opacity: 0,
  221. y: 100
  222. }"
  223. :enter="{
  224. opacity: 1,
  225. y: 0,
  226. transition: {
  227. delay: 400
  228. }
  229. }"
  230. >
  231. <el-card>
  232. <template #header>
  233. <a
  234. :class="titleClass"
  235. href="https://github.com/xiaoxian521/vue-pure-admin"
  236. target="_black"
  237. >
  238. <TypeIt
  239. :className="'type-it3'"
  240. :values="['GitHub饼图信息']"
  241. :cursor="false"
  242. :speed="120"
  243. />
  244. </a>
  245. </template>
  246. <el-skeleton animated :rows="7" :loading="loading">
  247. <template #default>
  248. <Pie />
  249. </template>
  250. </el-skeleton>
  251. </el-card>
  252. </el-col>
  253. <el-col
  254. :xs="24"
  255. :sm="24"
  256. :md="12"
  257. :lg="8"
  258. :xl="8"
  259. style="margin-bottom: 20px"
  260. v-motion
  261. :initial="{
  262. opacity: 0,
  263. y: 100
  264. }"
  265. :enter="{
  266. opacity: 1,
  267. y: 0,
  268. transition: {
  269. delay: 400
  270. }
  271. }"
  272. >
  273. <el-card>
  274. <template #header>
  275. <a
  276. :class="titleClass"
  277. href="https://github.com/xiaoxian521/vue-pure-admin"
  278. target="_black"
  279. >
  280. <TypeIt
  281. :className="'type-it4'"
  282. :values="['GitHub折线图信息']"
  283. :cursor="false"
  284. :speed="120"
  285. />
  286. </a>
  287. </template>
  288. <el-skeleton animated :rows="7" :loading="loading">
  289. <template #default>
  290. <Line />
  291. </template>
  292. </el-skeleton>
  293. </el-card>
  294. </el-col>
  295. <el-col
  296. :xs="24"
  297. :sm="24"
  298. :md="24"
  299. :lg="8"
  300. :xl="8"
  301. style="margin-bottom: 20px"
  302. v-motion
  303. :initial="{
  304. opacity: 0,
  305. y: 100
  306. }"
  307. :enter="{
  308. opacity: 1,
  309. y: 0,
  310. transition: {
  311. delay: 400
  312. }
  313. }"
  314. >
  315. <el-card>
  316. <template #header>
  317. <a
  318. :class="titleClass"
  319. href="https://github.com/xiaoxian521/vue-pure-admin"
  320. target="_black"
  321. >
  322. <TypeIt
  323. :className="'type-it5'"
  324. :values="['GitHub柱状图信息']"
  325. :cursor="false"
  326. :speed="120"
  327. />
  328. </a>
  329. </template>
  330. <el-skeleton animated :rows="7" :loading="loading">
  331. <template #default>
  332. <Bar />
  333. </template>
  334. </el-skeleton>
  335. </el-card>
  336. </el-col>
  337. </el-row>
  338. </div>
  339. </template>
  340. <style lang="scss" scoped>
  341. :deep(.el-timeline-item) {
  342. margin: 6px 0 0 6px;
  343. }
  344. .main-content {
  345. margin: 0 !important;
  346. }
  347. .welcome {
  348. height: 100%;
  349. .top-content {
  350. display: flex;
  351. justify-content: space-between;
  352. align-items: center;
  353. height: 60px;
  354. background: var(--el-bg-color);
  355. .left-mark {
  356. display: flex;
  357. align-items: center;
  358. img {
  359. display: block;
  360. width: 50px;
  361. height: 50px;
  362. border-radius: 50%;
  363. margin-right: 10px;
  364. cursor: pointer;
  365. }
  366. span {
  367. font-size: 14px;
  368. }
  369. }
  370. }
  371. }
  372. </style>