Index.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <template>
  2. <div>1111</div>
  3. </template>
  4. <script lang="ts" setup>
  5. import { set } from 'lodash-es'
  6. import { EChartsOption } from 'echarts'
  7. import { formatTime } from '@/utils'
  8. import { useUserStore } from '@/store/modules/user'
  9. // import { useWatermark } from '@/hooks/web/useWatermark'
  10. import type { WorkplaceTotal, Project, Notice, Shortcut } from './types'
  11. import { pieOptions, barOptions } from './echarts-data'
  12. import { useRouter } from 'vue-router'
  13. defineOptions({ name: 'Index' })
  14. const { t } = useI18n()
  15. const router = useRouter()
  16. const userStore = useUserStore()
  17. // const { setWatermark } = useWatermark()
  18. const loading = ref(true)
  19. const avatar = userStore.getUser.avatar
  20. const username = userStore.getUser.nickname
  21. const pieOptionsData = reactive<EChartsOption>(pieOptions) as EChartsOption
  22. // 获取统计数
  23. let totalSate = reactive<WorkplaceTotal>({
  24. project: 0,
  25. access: 0,
  26. todo: 0
  27. })
  28. const getCount = async () => {
  29. const data = {
  30. project: 40,
  31. access: 2340,
  32. todo: 10
  33. }
  34. totalSate = Object.assign(totalSate, data)
  35. }
  36. // 获取项目数
  37. let projects = reactive<Project[]>([])
  38. const getProject = async () => {
  39. const data = [
  40. {
  41. name: 'ruoyi-vue-pro',
  42. icon: 'simple-icons:springboot',
  43. message: 'github.com/YunaiV/ruoyi-vue-pro',
  44. personal: 'Spring Boot 单体架构',
  45. time: new Date('2025-01-02'),
  46. color: '#6DB33F'
  47. },
  48. {
  49. name: 'yudao-ui-admin-vue3',
  50. icon: 'ep:element-plus',
  51. message: 'github.com/yudaocode/yudao-ui-admin-vue3',
  52. personal: 'Vue3 + element-plus 管理后台',
  53. time: new Date('2025-02-03'),
  54. color: '#409EFF'
  55. },
  56. {
  57. name: 'yudao-ui-mall-uniapp',
  58. icon: 'icon-park-outline:mall-bag',
  59. message: 'github.com/yudaocode/yudao-ui-mall-uniapp',
  60. personal: 'Vue3 + uniapp 商城手机端',
  61. time: new Date('2025-03-04'),
  62. color: '#ff4d4f'
  63. },
  64. {
  65. name: 'yudao-cloud',
  66. icon: 'material-symbols:cloud-outline',
  67. message: 'github.com/YunaiV/yudao-cloud',
  68. personal: 'Spring Cloud 微服务架构',
  69. time: new Date('2025-04-05'),
  70. color: '#1890ff'
  71. },
  72. {
  73. name: 'yudao-ui-admin-vben',
  74. icon: 'devicon:antdesign',
  75. message: 'github.com/yudaocode/yudao-ui-admin-vben',
  76. personal: 'Vue3 + vben5(antd) 管理后台',
  77. time: new Date('2025-05-06'),
  78. color: '#e18525'
  79. },
  80. {
  81. name: 'yudao-ui-admin-uniapp',
  82. icon: 'ant-design:mobile',
  83. message: 'github.com/yudaocode/yudao-ui-admin-uniapp',
  84. personal: 'Vue3 + uniapp 管理手机端',
  85. time: new Date('2025-06-01'),
  86. color: '#2979ff'
  87. }
  88. ]
  89. projects = Object.assign(projects, data)
  90. }
  91. // 获取通知公告
  92. let notice = reactive<Notice[]>([])
  93. const getNotice = async () => {
  94. const data = [
  95. {
  96. title: '系统支持 JDK 8/17/21,Vue 2/3',
  97. type: '技术兼容性',
  98. keys: ['JDK', 'Vue'],
  99. date: new Date()
  100. },
  101. {
  102. title: '后端提供 Spring Boot 2.7/3.2 + Cloud 双架构',
  103. type: '架构灵活性',
  104. keys: ['Boot', 'Cloud'],
  105. date: new Date()
  106. },
  107. {
  108. title: '个人与企业可 100% 直接使用,无需授权',
  109. type: '免授权',
  110. keys: ['无需授权'],
  111. date: new Date()
  112. },
  113. {
  114. title: '国内使用最广泛的快速开发平台,远超 10w+ 企业使用',
  115. type: '广泛企业认可',
  116. keys: ['最广泛', '10w+'],
  117. date: new Date()
  118. }
  119. ]
  120. notice = Object.assign(notice, data)
  121. }
  122. // 获取快捷入口
  123. // 用户来源
  124. const getUserAccessSource = async () => {
  125. const data = [
  126. { value: 335, name: 'analysis.directAccess' },
  127. { value: 310, name: 'analysis.mailMarketing' },
  128. { value: 234, name: 'analysis.allianceAdvertising' },
  129. { value: 135, name: 'analysis.videoAdvertising' },
  130. { value: 1548, name: 'analysis.searchEngines' }
  131. ]
  132. set(
  133. pieOptionsData,
  134. 'legend.data',
  135. data.map((v) => t(v.name))
  136. )
  137. pieOptionsData!.series![0].data = data.map((v) => {
  138. return {
  139. name: t(v.name),
  140. value: v.value
  141. }
  142. })
  143. }
  144. const barOptionsData = reactive<EChartsOption>(barOptions) as EChartsOption
  145. // 周活跃量
  146. const getWeeklyUserActivity = async () => {
  147. const data = [
  148. { value: 13253, name: 'analysis.monday' },
  149. { value: 34235, name: 'analysis.tuesday' },
  150. { value: 26321, name: 'analysis.wednesday' },
  151. { value: 12340, name: 'analysis.thursday' },
  152. { value: 24643, name: 'analysis.friday' },
  153. { value: 1322, name: 'analysis.saturday' },
  154. { value: 1324, name: 'analysis.sunday' }
  155. ]
  156. set(
  157. barOptionsData,
  158. 'xAxis.data',
  159. data.map((v) => t(v.name))
  160. )
  161. set(barOptionsData, 'series', [
  162. {
  163. name: t('analysis.activeQuantity'),
  164. data: data.map((v) => v.value),
  165. type: 'bar'
  166. }
  167. ])
  168. }
  169. const getAllApi = async () => {
  170. await Promise.all([
  171. getCount(),
  172. getProject(),
  173. getNotice(),
  174. getShortcut(),
  175. getUserAccessSource(),
  176. getWeeklyUserActivity()
  177. ])
  178. loading.value = false
  179. }
  180. const handleProjectClick = (message: string) => {
  181. window.open(`https://${message}`, '_blank')
  182. }
  183. const handleShortcutClick = (url: string) => {
  184. router.push(url)
  185. }
  186. getAllApi()
  187. </script>