Commit 1e65b2219d0e7ae2986d8a5d926810a513706762
1 parent
91113eac
perf
Showing
1 changed file
with
17 additions
and
115 deletions
yudao-ui-admin-vue3/src/views/Home/Index.vue
| @@ -6,12 +6,11 @@ import { CountTo } from '@/components/CountTo' | @@ -6,12 +6,11 @@ import { CountTo } from '@/components/CountTo' | ||
| 6 | import { formatTime } from '@/utils' | 6 | import { formatTime } from '@/utils' |
| 7 | import { Echart } from '@/components/Echart' | 7 | import { Echart } from '@/components/Echart' |
| 8 | import { EChartsOption } from 'echarts' | 8 | import { EChartsOption } from 'echarts' |
| 9 | -import { radarOption } from './echarts-data' | ||
| 10 | import { Highlight } from '@/components/Highlight' | 9 | import { Highlight } from '@/components/Highlight' |
| 11 | import type { WorkplaceTotal, Project, Notice, Shortcut } from './types' | 10 | import type { WorkplaceTotal, Project, Notice, Shortcut } from './types' |
| 12 | import { set } from 'lodash-es' | 11 | import { set } from 'lodash-es' |
| 13 | import { useCache } from '@/hooks/web/useCache' | 12 | import { useCache } from '@/hooks/web/useCache' |
| 14 | -import { pieOptions, barOptions, lineOptions } from './echarts-data' | 13 | +import { pieOptions, barOptions } from './echarts-data' |
| 15 | 14 | ||
| 16 | const { t } = useI18n() | 15 | const { t } = useI18n() |
| 17 | const { wsCache } = useCache() | 16 | const { wsCache } = useCache() |
| @@ -156,44 +155,6 @@ const getShortcut = async () => { | @@ -156,44 +155,6 @@ const getShortcut = async () => { | ||
| 156 | shortcut = Object.assign(shortcut, data) | 155 | shortcut = Object.assign(shortcut, data) |
| 157 | } | 156 | } |
| 158 | 157 | ||
| 159 | -// 获取指数 | ||
| 160 | -let radarOptionData = reactive<EChartsOption>(radarOption) as EChartsOption | ||
| 161 | - | ||
| 162 | -const getRadar = async () => { | ||
| 163 | - const data = [ | ||
| 164 | - { name: 'workplace.quote', max: 65, personal: 42, team: 50 }, | ||
| 165 | - { name: 'workplace.contribution', max: 160, personal: 30, team: 140 }, | ||
| 166 | - { name: 'workplace.hot', max: 300, personal: 20, team: 28 }, | ||
| 167 | - { name: 'workplace.yield', max: 130, personal: 35, team: 35 }, | ||
| 168 | - { name: 'workplace.follow', max: 100, personal: 80, team: 90 } | ||
| 169 | - ] | ||
| 170 | - set( | ||
| 171 | - radarOptionData, | ||
| 172 | - 'radar.indicator', | ||
| 173 | - data.map((v) => { | ||
| 174 | - return { | ||
| 175 | - name: t(v.name), | ||
| 176 | - max: v.max | ||
| 177 | - } | ||
| 178 | - }) | ||
| 179 | - ) | ||
| 180 | - set(radarOptionData, 'series', [ | ||
| 181 | - { | ||
| 182 | - name: '指数', | ||
| 183 | - type: 'radar', | ||
| 184 | - data: [ | ||
| 185 | - { | ||
| 186 | - value: data.map((v) => v.personal), | ||
| 187 | - name: t('workplace.personal') | ||
| 188 | - }, | ||
| 189 | - { | ||
| 190 | - value: data.map((v) => v.team), | ||
| 191 | - name: t('workplace.team') | ||
| 192 | - } | ||
| 193 | - ] | ||
| 194 | - } | ||
| 195 | - ]) | ||
| 196 | -} | ||
| 197 | // 用户来源 | 158 | // 用户来源 |
| 198 | const getUserAccessSource = async () => { | 159 | const getUserAccessSource = async () => { |
| 199 | const data = [ | 160 | const data = [ |
| @@ -242,60 +203,14 @@ const getWeeklyUserActivity = async () => { | @@ -242,60 +203,14 @@ const getWeeklyUserActivity = async () => { | ||
| 242 | ]) | 203 | ]) |
| 243 | } | 204 | } |
| 244 | 205 | ||
| 245 | -const lineOptionsData = reactive<EChartsOption>(lineOptions) as EChartsOption | ||
| 246 | - | ||
| 247 | -// 每月销售总额 | ||
| 248 | -const getMonthlySales = async () => { | ||
| 249 | - const data = [ | ||
| 250 | - { estimate: 100, actual: 120, name: 'analysis.january' }, | ||
| 251 | - { estimate: 120, actual: 82, name: 'analysis.february' }, | ||
| 252 | - { estimate: 161, actual: 91, name: 'analysis.march' }, | ||
| 253 | - { estimate: 134, actual: 154, name: 'analysis.april' }, | ||
| 254 | - { estimate: 105, actual: 162, name: 'analysis.may' }, | ||
| 255 | - { estimate: 160, actual: 140, name: 'analysis.june' }, | ||
| 256 | - { estimate: 165, actual: 145, name: 'analysis.july' }, | ||
| 257 | - { estimate: 114, actual: 250, name: 'analysis.august' }, | ||
| 258 | - { estimate: 163, actual: 134, name: 'analysis.september' }, | ||
| 259 | - { estimate: 185, actual: 56, name: 'analysis.october' }, | ||
| 260 | - { estimate: 118, actual: 99, name: 'analysis.november' }, | ||
| 261 | - { estimate: 123, actual: 123, name: 'analysis.december' } | ||
| 262 | - ] | ||
| 263 | - set( | ||
| 264 | - lineOptionsData, | ||
| 265 | - 'xAxis.data', | ||
| 266 | - data.map((v) => t(v.name)) | ||
| 267 | - ) | ||
| 268 | - set(lineOptionsData, 'series', [ | ||
| 269 | - { | ||
| 270 | - name: t('analysis.estimate'), | ||
| 271 | - smooth: true, | ||
| 272 | - type: 'line', | ||
| 273 | - data: data.map((v) => v.estimate), | ||
| 274 | - animationDuration: 2800, | ||
| 275 | - animationEasing: 'cubicInOut' | ||
| 276 | - }, | ||
| 277 | - { | ||
| 278 | - name: t('analysis.actual'), | ||
| 279 | - smooth: true, | ||
| 280 | - type: 'line', | ||
| 281 | - itemStyle: {}, | ||
| 282 | - data: data.map((v) => v.actual), | ||
| 283 | - animationDuration: 2800, | ||
| 284 | - animationEasing: 'quadraticOut' | ||
| 285 | - } | ||
| 286 | - ]) | ||
| 287 | -} | ||
| 288 | - | ||
| 289 | const getAllApi = async () => { | 206 | const getAllApi = async () => { |
| 290 | await Promise.all([ | 207 | await Promise.all([ |
| 291 | getCount(), | 208 | getCount(), |
| 292 | getProject(), | 209 | getProject(), |
| 293 | getNotice(), | 210 | getNotice(), |
| 294 | getShortcut(), | 211 | getShortcut(), |
| 295 | - getRadar(), | ||
| 296 | getUserAccessSource(), | 212 | getUserAccessSource(), |
| 297 | - getWeeklyUserActivity(), | ||
| 298 | - getMonthlySales() | 213 | + getWeeklyUserActivity() |
| 299 | ]) | 214 | ]) |
| 300 | loading.value = false | 215 | loading.value = false |
| 301 | } | 216 | } |
| @@ -359,11 +274,11 @@ getAllApi() | @@ -359,11 +274,11 @@ getAllApi() | ||
| 359 | </el-card> | 274 | </el-card> |
| 360 | </div> | 275 | </div> |
| 361 | 276 | ||
| 362 | - <el-row class="mt-10px" :gutter="20" justify="space-between"> | ||
| 363 | - <el-col :xl="16" :lg="16" :md="24" :sm="24" :xs="24" class="mb-20px"> | 277 | + <el-row class="mt-5px" :gutter="20" justify="space-between"> |
| 278 | + <el-col :xl="16" :lg="16" :md="24" :sm="24" :xs="24" class="mb-10px"> | ||
| 364 | <el-card shadow="never"> | 279 | <el-card shadow="never"> |
| 365 | <template #header> | 280 | <template #header> |
| 366 | - <div class="flex justify-between"> | 281 | + <div class="flex justify-between h-3"> |
| 367 | <span>{{ t('workplace.project') }}</span> | 282 | <span>{{ t('workplace.project') }}</span> |
| 368 | <el-link type="primary" :underline="false">{{ t('workplace.more') }}</el-link> | 283 | <el-link type="primary" :underline="false">{{ t('workplace.more') }}</el-link> |
| 369 | </div> | 284 | </div> |
| @@ -375,7 +290,7 @@ getAllApi() | @@ -375,7 +290,7 @@ getAllApi() | ||
| 375 | :key="`card-${index}`" | 290 | :key="`card-${index}`" |
| 376 | :xl="8" | 291 | :xl="8" |
| 377 | :lg="8" | 292 | :lg="8" |
| 378 | - :md="12" | 293 | + :md="8" |
| 379 | :sm="24" | 294 | :sm="24" |
| 380 | :xs="24" | 295 | :xs="24" |
| 381 | > | 296 | > |
| @@ -395,27 +310,20 @@ getAllApi() | @@ -395,27 +310,20 @@ getAllApi() | ||
| 395 | </el-skeleton> | 310 | </el-skeleton> |
| 396 | </el-card> | 311 | </el-card> |
| 397 | 312 | ||
| 398 | - <el-card shadow="never" class="mt-10px"> | 313 | + <el-card shadow="never" class="mt-5px"> |
| 399 | <el-skeleton :loading="loading" animated> | 314 | <el-skeleton :loading="loading" animated> |
| 400 | <el-row :gutter="20" justify="space-between"> | 315 | <el-row :gutter="20" justify="space-between"> |
| 401 | <el-col :xl="10" :lg="10" :md="24" :sm="24" :xs="24"> | 316 | <el-col :xl="10" :lg="10" :md="24" :sm="24" :xs="24"> |
| 402 | - <el-card shadow="hover" class="mb-20px"> | 317 | + <el-card shadow="hover" class="mb-10px"> |
| 403 | <el-skeleton :loading="loading" animated> | 318 | <el-skeleton :loading="loading" animated> |
| 404 | - <Echart :options="pieOptionsData" :height="300" /> | 319 | + <Echart :options="pieOptionsData" :height="280" /> |
| 405 | </el-skeleton> | 320 | </el-skeleton> |
| 406 | </el-card> | 321 | </el-card> |
| 407 | </el-col> | 322 | </el-col> |
| 408 | <el-col :xl="14" :lg="14" :md="24" :sm="24" :xs="24"> | 323 | <el-col :xl="14" :lg="14" :md="24" :sm="24" :xs="24"> |
| 409 | - <el-card shadow="hover" class="mb-20px"> | 324 | + <el-card shadow="hover" class="mb-10px"> |
| 410 | <el-skeleton :loading="loading" animated> | 325 | <el-skeleton :loading="loading" animated> |
| 411 | - <Echart :options="barOptionsData" :height="300" /> | ||
| 412 | - </el-skeleton> | ||
| 413 | - </el-card> | ||
| 414 | - </el-col> | ||
| 415 | - <el-col :span="24"> | ||
| 416 | - <el-card shadow="hover" class="mb-20px"> | ||
| 417 | - <el-skeleton :loading="loading" animated :rows="4"> | ||
| 418 | - <Echart :options="lineOptionsData" :height="350" /> | 326 | + <Echart :options="barOptionsData" :height="280" /> |
| 419 | </el-skeleton> | 327 | </el-skeleton> |
| 420 | </el-card> | 328 | </el-card> |
| 421 | </el-col> | 329 | </el-col> |
| @@ -423,14 +331,16 @@ getAllApi() | @@ -423,14 +331,16 @@ getAllApi() | ||
| 423 | </el-skeleton> | 331 | </el-skeleton> |
| 424 | </el-card> | 332 | </el-card> |
| 425 | </el-col> | 333 | </el-col> |
| 426 | - <el-col :xl="8" :lg="8" :md="24" :sm="24" :xs="24" class="mb-20px"> | 334 | + <el-col :xl="8" :lg="8" :md="24" :sm="24" :xs="24" class="mb-10px"> |
| 427 | <el-card shadow="never"> | 335 | <el-card shadow="never"> |
| 428 | <template #header> | 336 | <template #header> |
| 429 | - <span>{{ t('workplace.shortcutOperation') }}</span> | 337 | + <div class="flex justify-between h-3"> |
| 338 | + <span>{{ t('workplace.shortcutOperation') }}</span> | ||
| 339 | + </div> | ||
| 430 | </template> | 340 | </template> |
| 431 | <el-skeleton :loading="loading" animated> | 341 | <el-skeleton :loading="loading" animated> |
| 432 | <el-row> | 342 | <el-row> |
| 433 | - <el-col v-for="item in shortcut" :key="`team-${item.name}`" :span="8" class="mb-20px"> | 343 | + <el-col v-for="item in shortcut" :key="`team-${item.name}`" :span="8" class="mb-10px"> |
| 434 | <div class="flex items-center"> | 344 | <div class="flex items-center"> |
| 435 | <Icon :icon="item.icon" class="mr-10px" /> | 345 | <Icon :icon="item.icon" class="mr-10px" /> |
| 436 | <el-link type="default" :underline="false" :href="item.url"> | 346 | <el-link type="default" :underline="false" :href="item.url"> |
| @@ -443,7 +353,7 @@ getAllApi() | @@ -443,7 +353,7 @@ getAllApi() | ||
| 443 | </el-card> | 353 | </el-card> |
| 444 | <el-card shadow="never" class="mt-10px"> | 354 | <el-card shadow="never" class="mt-10px"> |
| 445 | <template #header> | 355 | <template #header> |
| 446 | - <div class="flex justify-between"> | 356 | + <div class="flex justify-between h-3"> |
| 447 | <span>{{ t('workplace.notice') }}</span> | 357 | <span>{{ t('workplace.notice') }}</span> |
| 448 | <el-link type="primary" :underline="false">{{ t('workplace.more') }}</el-link> | 358 | <el-link type="primary" :underline="false">{{ t('workplace.more') }}</el-link> |
| 449 | </div> | 359 | </div> |
| @@ -467,14 +377,6 @@ getAllApi() | @@ -467,14 +377,6 @@ getAllApi() | ||
| 467 | </div> | 377 | </div> |
| 468 | </el-skeleton> | 378 | </el-skeleton> |
| 469 | </el-card> | 379 | </el-card> |
| 470 | - <el-card shadow="never" class="mt-10px"> | ||
| 471 | - <template #header> | ||
| 472 | - <span>{{ t('workplace.index') }}</span> | ||
| 473 | - </template> | ||
| 474 | - <el-skeleton :loading="loading" animated> | ||
| 475 | - <Echart :options="radarOptionData" :height="400" /> | ||
| 476 | - </el-skeleton> | ||
| 477 | - </el-card> | ||
| 478 | </el-col> | 380 | </el-col> |
| 479 | </el-row> | 381 | </el-row> |
| 480 | </template> | 382 | </template> |