Index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  1. <template>
  2. <div>
  3. <el-card shadow="never">
  4. <el-skeleton :loading="loading" animated>
  5. <el-row :gutter="16" justify="space-between">
  6. <el-col :xl="12" :lg="12" :md="12" :sm="24" :xs="24">
  7. <div class="flex items-center">
  8. <el-avatar :src="avatar" :size="70" class="mr-16px">
  9. <img src="@/assets/imgs/avatar.gif" alt="" />
  10. </el-avatar>
  11. <div>
  12. <div class="text-20px">
  13. {{ t('workplace.welcome') }} {{ username }} {{ t('workplace.happyDay') }}
  14. </div>
  15. <div class="mt-10px text-14px text-gray-500">
  16. {{ t('workplace.toady') }},20℃ - 32℃!
  17. </div>
  18. </div>
  19. </div>
  20. </el-col>
  21. <el-col :xl="12" :lg="12" :md="12" :sm="24" :xs="24">
  22. <div class="h-70px flex items-center justify-end lt-sm:mt-10px">
  23. <div class="px-8px text-right">
  24. <div class="mb-16px text-14px text-gray-400">{{ t('workplace.project') }}</div>
  25. <CountTo
  26. class="text-20px"
  27. :start-val="0"
  28. :end-val="totalSate.project"
  29. :duration="2600"
  30. />
  31. </div>
  32. <el-divider direction="vertical" />
  33. <div class="px-8px text-right">
  34. <div class="mb-16px text-14px text-gray-400">{{ t('workplace.toDo') }}</div>
  35. <CountTo
  36. class="text-20px"
  37. :start-val="0"
  38. :end-val="totalSate.todo"
  39. :duration="2600"
  40. />
  41. </div>
  42. <el-divider direction="vertical" border-style="dashed" />
  43. <div class="px-8px text-right">
  44. <div class="mb-16px text-14px text-gray-400">{{ t('workplace.access') }}</div>
  45. <CountTo
  46. class="text-20px"
  47. :start-val="0"
  48. :end-val="totalSate.access"
  49. :duration="2600"
  50. />
  51. </div>
  52. </div>
  53. </el-col>
  54. </el-row>
  55. </el-skeleton>
  56. </el-card>
  57. </div>
  58. <el-row class="mt-8px" :gutter="8" justify="space-between">
  59. <el-col :xl="16" :lg="16" :md="24" :sm="24" :xs="24" class="mb-8px">
  60. <el-card shadow="never">
  61. <template #header>
  62. <div class="h-3 flex justify-between">
  63. <span>{{ t('workplace.project') }}</span>
  64. <el-link
  65. type="primary"
  66. :underline="false"
  67. href="https://github.com/yudaocode"
  68. target="_blank"
  69. >
  70. {{ t('action.more') }}
  71. </el-link>
  72. </div>
  73. </template>
  74. <el-skeleton :loading="loading" animated>
  75. <el-row>
  76. <el-col
  77. v-for="(item, index) in projects"
  78. :key="`card-${index}`"
  79. :xl="8"
  80. :lg="8"
  81. :md="8"
  82. :sm="24"
  83. :xs="24"
  84. >
  85. <el-card
  86. shadow="hover"
  87. class="mr-5px mt-5px cursor-pointer"
  88. @click="handleProjectClick(item.message)"
  89. >
  90. <div class="flex items-center">
  91. <Icon
  92. :icon="item.icon"
  93. :size="25"
  94. class="mr-8px"
  95. :style="{ color: item.color }"
  96. />
  97. <span class="text-16px">{{ item.name }}</span>
  98. </div>
  99. <div class="mt-12px text-12px text-gray-400">{{ t(item.message) }}</div>
  100. <div class="mt-12px flex justify-between text-12px text-gray-400">
  101. <span>{{ item.personal }}</span>
  102. <span>{{ formatTime(item.time, 'yyyy-MM-dd') }}</span>
  103. </div>
  104. </el-card>
  105. </el-col>
  106. </el-row>
  107. </el-skeleton>
  108. </el-card>
  109. <el-card shadow="never" class="mt-8px">
  110. <el-skeleton :loading="loading" animated>
  111. <el-row :gutter="20" justify="space-between">
  112. <el-col :xl="10" :lg="10" :md="24" :sm="24" :xs="24">
  113. <el-card shadow="hover" class="mb-8px">
  114. <el-skeleton :loading="loading" animated>
  115. <Echart :options="pieOptionsData" :height="280" />
  116. </el-skeleton>
  117. </el-card>
  118. </el-col>
  119. <el-col :xl="14" :lg="14" :md="24" :sm="24" :xs="24">
  120. <el-card shadow="hover" class="mb-8px">
  121. <el-skeleton :loading="loading" animated>
  122. <Echart :options="barOptionsData" :height="280" />
  123. </el-skeleton>
  124. </el-card>
  125. </el-col>
  126. </el-row>
  127. </el-skeleton>
  128. </el-card>
  129. </el-col>
  130. <el-col :xl="8" :lg="8" :md="24" :sm="24" :xs="24" class="mb-8px">
  131. <el-card shadow="never">
  132. <template #header>
  133. <div class="h-3 flex justify-between">
  134. <span>{{ t('workplace.shortcutOperation') }}</span>
  135. </div>
  136. </template>
  137. <el-skeleton :loading="loading" animated>
  138. <el-row>
  139. <el-col v-for="item in shortcut" :key="`team-${item.name}`" :span="8" class="mb-8px">
  140. <div class="flex items-center">
  141. <Icon :icon="item.icon" class="mr-8px" :style="{ color: item.color }" />
  142. <el-link type="default" :underline="false" @click="handleShortcutClick(item.url)">
  143. {{ item.name }}
  144. </el-link>
  145. </div>
  146. </el-col>
  147. </el-row>
  148. </el-skeleton>
  149. </el-card>
  150. <el-card shadow="never" class="mt-8px">
  151. <template #header>
  152. <div class="h-3 flex justify-between">
  153. <span>{{ t('workplace.notice') }}</span>
  154. <el-link type="primary" :underline="false">{{ t('action.more') }}</el-link>
  155. </div>
  156. </template>
  157. <el-skeleton :loading="loading" animated>
  158. <div v-for="(item, index) in notice" :key="`dynamics-${index}`">
  159. <div class="flex items-center">
  160. <el-avatar :src="avatar" :size="35" class="mr-16px">
  161. <img src="@/assets/imgs/avatar.gif" alt="" />
  162. </el-avatar>
  163. <div>
  164. <div class="text-14px">
  165. <Highlight :keys="item.keys.map((v) => t(v))">
  166. {{ item.type }} : {{ item.title }}
  167. </Highlight>
  168. </div>
  169. <div class="mt-16px text-12px text-gray-400">
  170. {{ formatTime(item.date, 'yyyy-MM-dd') }}
  171. </div>
  172. </div>
  173. </div>
  174. <el-divider />
  175. </div>
  176. </el-skeleton>
  177. </el-card>
  178. </el-col>
  179. </el-row>
  180. </template>
  181. <script lang="ts" setup>
  182. import { set } from 'lodash-es'
  183. import { EChartsOption } from 'echarts'
  184. import { formatTime } from '@/utils'
  185. import { useUserStore } from '@/store/modules/user'
  186. // import { useWatermark } from '@/hooks/web/useWatermark'
  187. import type { WorkplaceTotal, Project, Notice, Shortcut } from './types'
  188. import { pieOptions, barOptions } from './echarts-data'
  189. import { useRouter } from 'vue-router'
  190. defineOptions({ name: 'Index' })
  191. const { t } = useI18n()
  192. const router = useRouter()
  193. const userStore = useUserStore()
  194. // const { setWatermark } = useWatermark()
  195. const loading = ref(true)
  196. const avatar = userStore.getUser.avatar
  197. const username = userStore.getUser.nickname
  198. const pieOptionsData = reactive<EChartsOption>(pieOptions) as EChartsOption
  199. // 获取统计数
  200. let totalSate = reactive<WorkplaceTotal>({
  201. project: 0,
  202. access: 0,
  203. todo: 0
  204. })
  205. const getCount = async () => {
  206. const data = {
  207. project: 40,
  208. access: 2340,
  209. todo: 10
  210. }
  211. totalSate = Object.assign(totalSate, data)
  212. }
  213. // 获取项目数
  214. let projects = reactive<Project[]>([])
  215. const getProject = async () => {
  216. const data = [
  217. {
  218. name: 'ruoyi-vue-pro',
  219. icon: 'simple-icons:springboot',
  220. message: 'github.com/YunaiV/ruoyi-vue-pro',
  221. personal: 'Spring Boot 单体架构',
  222. time: new Date('2025-01-02'),
  223. color: '#6DB33F'
  224. },
  225. {
  226. name: 'yudao-ui-admin-vue3',
  227. icon: 'ep:element-plus',
  228. message: 'github.com/yudaocode/yudao-ui-admin-vue3',
  229. personal: 'Vue3 + element-plus 管理后台',
  230. time: new Date('2025-02-03'),
  231. color: '#409EFF'
  232. },
  233. {
  234. name: 'yudao-ui-mall-uniapp',
  235. icon: 'icon-park-outline:mall-bag',
  236. message: 'github.com/yudaocode/yudao-ui-mall-uniapp',
  237. personal: 'Vue3 + uniapp 商城手机端',
  238. time: new Date('2025-03-04'),
  239. color: '#ff4d4f'
  240. },
  241. {
  242. name: 'yudao-cloud',
  243. icon: 'material-symbols:cloud-outline',
  244. message: 'github.com/YunaiV/yudao-cloud',
  245. personal: 'Spring Cloud 微服务架构',
  246. time: new Date('2025-04-05'),
  247. color: '#1890ff'
  248. },
  249. {
  250. name: 'yudao-ui-admin-vben',
  251. icon: 'devicon:antdesign',
  252. message: 'github.com/yudaocode/yudao-ui-admin-vben',
  253. personal: 'Vue3 + vben5(antd) 管理后台',
  254. time: new Date('2025-05-06'),
  255. color: '#e18525'
  256. },
  257. {
  258. name: 'yudao-ui-admin-uniapp',
  259. icon: 'ant-design:mobile',
  260. message: 'github.com/yudaocode/yudao-ui-admin-uniapp',
  261. personal: 'Vue3 + uniapp 管理手机端',
  262. time: new Date('2025-06-01'),
  263. color: '#2979ff'
  264. }
  265. ]
  266. projects = Object.assign(projects, data)
  267. }
  268. // 获取通知公告
  269. let notice = reactive<Notice[]>([])
  270. const getNotice = async () => {
  271. const data = [
  272. {
  273. title: '系统支持 JDK 8/17/21,Vue 2/3',
  274. type: '技术兼容性',
  275. keys: ['JDK', 'Vue'],
  276. date: new Date()
  277. },
  278. {
  279. title: '后端提供 Spring Boot 2.7/3.2 + Cloud 双架构',
  280. type: '架构灵活性',
  281. keys: ['Boot', 'Cloud'],
  282. date: new Date()
  283. },
  284. {
  285. title: '全部开源,个人与企业可 100% 直接使用,无需授权',
  286. type: '开源免授权',
  287. keys: ['无需授权'],
  288. date: new Date()
  289. },
  290. {
  291. title: '国内使用最广泛的快速开发平台,远超 10w+ 企业使用',
  292. type: '广泛企业认可',
  293. keys: ['最广泛', '10w+'],
  294. date: new Date()
  295. }
  296. ]
  297. notice = Object.assign(notice, data)
  298. }
  299. // 获取快捷入口
  300. let shortcut = reactive<Shortcut[]>([])
  301. const getShortcut = async () => {
  302. const data = [
  303. {
  304. name: '首页',
  305. icon: 'ion:home-outline',
  306. url: '/',
  307. color: '#1fdaca'
  308. },
  309. {
  310. name: '商城中心',
  311. icon: 'ep:shop',
  312. url: '/mall/home',
  313. color: '#ff6b6b'
  314. },
  315. {
  316. name: 'AI 大模型',
  317. icon: 'tabler:ai',
  318. url: '/ai/chat',
  319. color: '#7c3aed'
  320. },
  321. {
  322. name: 'ERP 系统',
  323. icon: 'simple-icons:erpnext',
  324. url: '/erp/home',
  325. color: '#3fb27f'
  326. },
  327. {
  328. name: 'CRM 系统',
  329. icon: 'simple-icons:civicrm',
  330. url: '/crm/backlog',
  331. color: '#4daf1bc9'
  332. },
  333. {
  334. name: 'IoT 物联网',
  335. icon: 'fa-solid:hdd',
  336. url: '/iot/home',
  337. color: '#1a73e8'
  338. }
  339. ]
  340. shortcut = Object.assign(shortcut, data)
  341. }
  342. // 用户来源
  343. const getUserAccessSource = async () => {
  344. const data = [
  345. { value: 335, name: 'analysis.directAccess' },
  346. { value: 310, name: 'analysis.mailMarketing' },
  347. { value: 234, name: 'analysis.allianceAdvertising' },
  348. { value: 135, name: 'analysis.videoAdvertising' },
  349. { value: 1548, name: 'analysis.searchEngines' }
  350. ]
  351. set(
  352. pieOptionsData,
  353. 'legend.data',
  354. data.map((v) => t(v.name))
  355. )
  356. pieOptionsData!.series![0].data = data.map((v) => {
  357. return {
  358. name: t(v.name),
  359. value: v.value
  360. }
  361. })
  362. }
  363. const barOptionsData = reactive<EChartsOption>(barOptions) as EChartsOption
  364. // 周活跃量
  365. const getWeeklyUserActivity = async () => {
  366. const data = [
  367. { value: 13253, name: 'analysis.monday' },
  368. { value: 34235, name: 'analysis.tuesday' },
  369. { value: 26321, name: 'analysis.wednesday' },
  370. { value: 12340, name: 'analysis.thursday' },
  371. { value: 24643, name: 'analysis.friday' },
  372. { value: 1322, name: 'analysis.saturday' },
  373. { value: 1324, name: 'analysis.sunday' }
  374. ]
  375. set(
  376. barOptionsData,
  377. 'xAxis.data',
  378. data.map((v) => t(v.name))
  379. )
  380. set(barOptionsData, 'series', [
  381. {
  382. name: t('analysis.activeQuantity'),
  383. data: data.map((v) => v.value),
  384. type: 'bar'
  385. }
  386. ])
  387. }
  388. const getAllApi = async () => {
  389. await Promise.all([
  390. getCount(),
  391. getProject(),
  392. getNotice(),
  393. getShortcut(),
  394. getUserAccessSource(),
  395. getWeeklyUserActivity()
  396. ])
  397. loading.value = false
  398. }
  399. const handleProjectClick = (message: string) => {
  400. window.open(`https://${message}`, '_blank')
  401. }
  402. const handleShortcutClick = (url: string) => {
  403. router.push(url)
  404. }
  405. getAllApi()
  406. </script>