Browse Source

首页

master
zhang_li 12 months ago
parent
commit
762390d2b2
  1. 381
      src/views/Home/Index copy.vue
  2. 569
      src/views/Home/Index.vue

381
src/views/Home/Index copy.vue

@ -0,0 +1,381 @@
<template>
<div>
<el-card shadow="never">
<el-skeleton :loading="loading" animated>
<el-row :gutter="20" justify="space-between">
<el-col :xl="12" :lg="12" :md="12" :sm="24" :xs="24">
<div class="flex items-center">
<img :src="avatar" alt="" class="mr-20px h-70px w-70px rounded-[50%]" />
<div>
<div class="text-20px">
{{ t('workplace.welcome') }} {{ username }} {{ t('workplace.happyDay') }}
</div>
<div class="mt-10px text-14px text-gray-500">
{{ t('workplace.toady') }}20 - 32
</div>
</div>
</div>
</el-col>
<el-col :xl="12" :lg="12" :md="12" :sm="24" :xs="24">
<div class="h-70px flex items-center justify-end lt-sm:mt-10px">
<div class="px-8px text-right">
<div class="mb-20px text-14px text-gray-400">{{ t('workplace.project') }}</div>
<CountTo
class="text-20px"
:start-val="0"
:end-val="totalSate.project"
:duration="2600"
/>
</div>
<el-divider direction="vertical" />
<div class="px-8px text-right">
<div class="mb-20px text-14px text-gray-400">{{ t('workplace.toDo') }}</div>
<CountTo
class="text-20px"
:start-val="0"
:end-val="totalSate.todo"
:duration="2600"
/>
</div>
<el-divider direction="vertical" border-style="dashed" />
<div class="px-8px text-right">
<div class="mb-20px text-14px text-gray-400">{{ t('workplace.access') }}</div>
<CountTo
class="text-20px"
:start-val="0"
:end-val="totalSate.access"
:duration="2600"
/>
</div>
</div>
</el-col>
</el-row>
</el-skeleton>
</el-card>
</div>
<el-row class="mt-5px" :gutter="20" justify="space-between">
<el-col :xl="16" :lg="16" :md="24" :sm="24" :xs="24" class="mb-10px">
<el-card shadow="never">
<template #header>
<div class="h-3 flex justify-between">
<span>{{ t('workplace.project') }}</span>
<el-link type="primary" :underline="false">{{ t('action.more') }}</el-link>
</div>
</template>
<el-skeleton :loading="loading" animated>
<el-row>
<el-col
v-for="(item, index) in projects"
:key="`card-${index}`"
:xl="8"
:lg="8"
:md="8"
:sm="24"
:xs="24"
>
<el-card shadow="hover">
<div class="flex items-center">
<Icon :icon="item.icon" :size="25" class="mr-10px" />
<span class="text-16px">{{ item.name }}</span>
</div>
<div class="mt-15px text-14px text-gray-400">{{ t(item.message) }}</div>
<div class="mt-20px flex justify-between text-12px text-gray-400">
<span>{{ item.personal }}</span>
<span>{{ formatTime(item.time, 'yyyy-MM-dd') }}</span>
</div>
</el-card>
</el-col>
</el-row>
</el-skeleton>
</el-card>
<el-card shadow="never" class="mt-5px">
<el-skeleton :loading="loading" animated>
<el-row :gutter="20" justify="space-between">
<el-col :xl="10" :lg="10" :md="24" :sm="24" :xs="24">
<el-card shadow="hover" class="mb-10px">
<el-skeleton :loading="loading" animated>
<Echart :options="pieOptionsData" :height="280" />
</el-skeleton>
</el-card>
</el-col>
<el-col :xl="14" :lg="14" :md="24" :sm="24" :xs="24">
<el-card shadow="hover" class="mb-10px">
<el-skeleton :loading="loading" animated>
<Echart :options="barOptionsData" :height="280" />
</el-skeleton>
</el-card>
</el-col>
</el-row>
</el-skeleton>
</el-card>
</el-col>
<el-col :xl="8" :lg="8" :md="24" :sm="24" :xs="24" class="mb-10px">
<el-card shadow="never">
<template #header>
<div class="h-3 flex justify-between">
<span>{{ t('workplace.shortcutOperation') }}</span>
</div>
</template>
<el-skeleton :loading="loading" animated>
<el-row>
<el-col v-for="item in shortcut" :key="`team-${item.name}`" :span="8" class="mb-10px">
<div class="flex items-center">
<Icon :icon="item.icon" class="mr-10px" />
<el-link type="default" :underline="false" @click="setWatermark(item.name)">
{{ item.name }}
</el-link>
</div>
</el-col>
</el-row>
</el-skeleton>
</el-card>
<el-card shadow="never" class="mt-10px">
<template #header>
<div class="h-3 flex justify-between">
<span>{{ t('workplace.notice') }}</span>
<el-link type="primary" :underline="false">{{ t('action.more') }}</el-link>
</div>
</template>
<el-skeleton :loading="loading" animated>
<div v-for="(item, index) in notice" :key="`dynamics-${index}`">
<div class="flex items-center">
<img :src="avatar" alt="" class="mr-20px h-35px w-35px rounded-[50%]" />
<div>
<div class="text-14px">
<Highlight :keys="item.keys.map((v) => t(v))">
{{ item.type }} : {{ item.title }}
</Highlight>
</div>
<div class="mt-15px text-12px text-gray-400">
{{ formatTime(item.date, 'yyyy-MM-dd') }}
</div>
</div>
</div>
<el-divider />
</div>
</el-skeleton>
</el-card>
</el-col>
</el-row>
</template>
<script lang="ts" setup>
import { set } from 'lodash-es'
import { EChartsOption } from 'echarts'
import { formatTime } from '@/utils'
import { useUserStore } from '@/store/modules/user'
import { useWatermark } from '@/hooks/web/useWatermark'
import avatarImg from '@/assets/imgs/avatar.gif'
import type { WorkplaceTotal, Project, Notice, Shortcut } from './types'
import { pieOptions, barOptions } from './echarts-data'
defineOptions({ name: 'Home' })
const { t } = useI18n()
const userStore = useUserStore()
const { setWatermark } = useWatermark()
const loading = ref(true)
const avatar = userStore.getUser.avatar ? userStore.getUser.avatar : avatarImg
const username = userStore.getUser.nickname
const pieOptionsData = reactive<EChartsOption>(pieOptions) as EChartsOption
//
let totalSate = reactive<WorkplaceTotal>({
project: 0,
access: 0,
todo: 0
})
const getCount = async () => {
const data = {
project: 40,
access: 2340,
todo: 10
}
totalSate = Object.assign(totalSate, data)
}
//
let projects = reactive<Project[]>([])
const getProject = async () => {
const data = [
{
name: 'Github',
icon: 'akar-icons:github-fill',
message: 'workplace.introduction',
personal: 'Archer',
time: new Date()
},
{
name: 'Vue',
icon: 'logos:vue',
message: 'workplace.introduction',
personal: 'Archer',
time: new Date()
},
{
name: 'Angular',
icon: 'logos:angular-icon',
message: 'workplace.introduction',
personal: 'Archer',
time: new Date()
},
{
name: 'React',
icon: 'logos:react',
message: 'workplace.introduction',
personal: 'Archer',
time: new Date()
},
{
name: 'Webpack',
icon: 'logos:webpack',
message: 'workplace.introduction',
personal: 'Archer',
time: new Date()
},
{
name: 'Vite',
icon: 'vscode-icons:file-type-vite',
message: 'workplace.introduction',
personal: 'Archer',
time: new Date()
}
]
projects = Object.assign(projects, data)
}
//
let notice = reactive<Notice[]>([])
const getNotice = async () => {
const data = [
{
title: '系统升级版本',
type: '通知',
keys: ['通知', '升级'],
date: new Date()
},
{
title: '系统凌晨维护',
type: '公告',
keys: ['公告', '维护'],
date: new Date()
},
{
title: '系统升级版本',
type: '通知',
keys: ['通知', '升级'],
date: new Date()
},
{
title: '系统凌晨维护',
type: '公告',
keys: ['公告', '维护'],
date: new Date()
}
]
notice = Object.assign(notice, data)
}
//
let shortcut = reactive<Shortcut[]>([])
const getShortcut = async () => {
const data = [
{
name: 'Github',
icon: 'akar-icons:github-fill',
url: 'github.io'
},
{
name: 'Vue',
icon: 'logos:vue',
url: 'vuejs.org'
},
{
name: 'Vite',
icon: 'vscode-icons:file-type-vite',
url: 'https://vitejs.dev/'
},
{
name: 'Angular',
icon: 'logos:angular-icon',
url: 'github.io'
},
{
name: 'React',
icon: 'logos:react',
url: 'github.io'
},
{
name: 'Webpack',
icon: 'logos:webpack',
url: 'github.io'
}
]
shortcut = Object.assign(shortcut, data)
}
//
const getUserAccessSource = async () => {
const data = [
{ value: 335, name: 'analysis.directAccess' },
{ value: 310, name: 'analysis.mailMarketing' },
{ value: 234, name: 'analysis.allianceAdvertising' },
{ value: 135, name: 'analysis.videoAdvertising' },
{ value: 1548, name: 'analysis.searchEngines' }
]
set(
pieOptionsData,
'legend.data',
data.map((v) => t(v.name))
)
pieOptionsData!.series![0].data = data.map((v) => {
return {
name: t(v.name),
value: v.value
}
})
}
const barOptionsData = reactive<EChartsOption>(barOptions) as EChartsOption
//
const getWeeklyUserActivity = async () => {
const data = [
{ value: 13253, name: 'analysis.monday' },
{ value: 34235, name: 'analysis.tuesday' },
{ value: 26321, name: 'analysis.wednesday' },
{ value: 12340, name: 'analysis.thursday' },
{ value: 24643, name: 'analysis.friday' },
{ value: 1322, name: 'analysis.saturday' },
{ value: 1324, name: 'analysis.sunday' }
]
set(
barOptionsData,
'xAxis.data',
data.map((v) => t(v.name))
)
set(barOptionsData, 'series', [
{
name: t('analysis.activeQuantity'),
data: data.map((v) => v.value),
type: 'bar'
}
])
}
const getAllApi = async () => {
await Promise.all([
getCount(),
getProject(),
getNotice(),
getShortcut(),
getUserAccessSource(),
getWeeklyUserActivity()
])
loading.value = false
}
getAllApi()
</script>

569
src/views/Home/Index.vue

@ -1,161 +1,39 @@
<template> <template>
<div> <el-row :gutter="14" justify="space-between">
<el-card shadow="never"> <el-col :xl="12" :lg="12" :md="12" :sm="24" :xs="24" class="mb-14px">
<el-skeleton :loading="loading" animated>
<el-row :gutter="20" justify="space-between">
<el-col :xl="12" :lg="12" :md="12" :sm="24" :xs="24">
<div class="flex items-center">
<img :src="avatar" alt="" class="mr-20px h-70px w-70px rounded-[50%]" />
<div>
<div class="text-20px">
{{ t('workplace.welcome') }} {{ username }} {{ t('workplace.happyDay') }}
</div>
<div class="mt-10px text-14px text-gray-500">
{{ t('workplace.toady') }}20 - 32
</div>
</div>
</div>
</el-col>
<el-col :xl="12" :lg="12" :md="12" :sm="24" :xs="24">
<div class="h-70px flex items-center justify-end lt-sm:mt-10px">
<div class="px-8px text-right">
<div class="mb-20px text-14px text-gray-400">{{ t('workplace.project') }}</div>
<CountTo
class="text-20px"
:start-val="0"
:end-val="totalSate.project"
:duration="2600"
/>
</div>
<el-divider direction="vertical" />
<div class="px-8px text-right">
<div class="mb-20px text-14px text-gray-400">{{ t('workplace.toDo') }}</div>
<CountTo
class="text-20px"
:start-val="0"
:end-val="totalSate.todo"
:duration="2600"
/>
</div>
<el-divider direction="vertical" border-style="dashed" />
<div class="px-8px text-right">
<div class="mb-20px text-14px text-gray-400">{{ t('workplace.access') }}</div>
<CountTo
class="text-20px"
:start-val="0"
:end-val="totalSate.access"
:duration="2600"
/>
</div>
</div>
</el-col>
</el-row>
</el-skeleton>
</el-card>
</div>
<el-row class="mt-5px" :gutter="20" justify="space-between">
<el-col :xl="16" :lg="16" :md="24" :sm="24" :xs="24" class="mb-10px">
<el-card shadow="never"> <el-card shadow="never">
<template #header> <Echart :options="barOptionsData" :height="280" />
<div class="h-3 flex justify-between">
<span>{{ t('workplace.project') }}</span>
<el-link type="primary" :underline="false">{{ t('action.more') }}</el-link>
</div>
</template>
<el-skeleton :loading="loading" animated>
<el-row>
<el-col
v-for="(item, index) in projects"
:key="`card-${index}`"
:xl="8"
:lg="8"
:md="8"
:sm="24"
:xs="24"
>
<el-card shadow="hover">
<div class="flex items-center">
<Icon :icon="item.icon" :size="25" class="mr-10px" />
<span class="text-16px">{{ item.name }}</span>
</div>
<div class="mt-15px text-14px text-gray-400">{{ t(item.message) }}</div>
<div class="mt-20px flex justify-between text-12px text-gray-400">
<span>{{ item.personal }}</span>
<span>{{ formatTime(item.time, 'yyyy-MM-dd') }}</span>
</div>
</el-card>
</el-col>
</el-row>
</el-skeleton>
</el-card> </el-card>
</el-col>
<el-card shadow="never" class="mt-5px"> <el-col :xl="12" :lg="12" :md="12" :sm="24" :xs="24" class="mb-14px">
<el-skeleton :loading="loading" animated> <el-card shadow="never">
<el-row :gutter="20" justify="space-between"> <Echart :options="lineOptionsData" :height="280" />
<el-col :xl="10" :lg="10" :md="24" :sm="24" :xs="24">
<el-card shadow="hover" class="mb-10px">
<el-skeleton :loading="loading" animated>
<Echart :options="pieOptionsData" :height="280" />
</el-skeleton>
</el-card>
</el-col>
<el-col :xl="14" :lg="14" :md="24" :sm="24" :xs="24">
<el-card shadow="hover" class="mb-10px">
<el-skeleton :loading="loading" animated>
<Echart :options="barOptionsData" :height="280" />
</el-skeleton>
</el-card>
</el-col>
</el-row>
</el-skeleton>
</el-card> </el-card>
</el-col> </el-col>
<el-col :xl="8" :lg="8" :md="24" :sm="24" :xs="24" class="mb-10px"> <el-col :xl="24" :lg="24" :md="24" :sm="24" :xs="24">
<el-card shadow="never"> <el-card shadow="never">
<template #header> <div class="title font-size-18px font-bold mb-10px">项目物料检测类型次数清单</div>
<div class="h-3 flex justify-between"> <el-table :data="tableData" style="width: 100%">
<span>{{ t('workplace.shortcutOperation') }}</span> <el-table-column label="序号" width="80" type="index" align="center" />
</div> <el-table-column prop="project" label="项目" align="center" />
</template> <el-table-column prop="code" label="物料代码" align="center" />
<el-skeleton :loading="loading" animated> <el-table-column prop="name" label="名称" align="center" />
<el-row> <el-table-column prop="type" label="检查类型" align="center" />
<el-col v-for="item in shortcut" :key="`team-${item.name}`" :span="8" class="mb-10px"> <el-table-column prop="num" label="次数" align="center" />
<div class="flex items-center"> </el-table>
<Icon :icon="item.icon" class="mr-10px" />
<el-link type="default" :underline="false" @click="setWatermark(item.name)">
{{ item.name }}
</el-link>
</div>
</el-col>
</el-row>
</el-skeleton>
</el-card> </el-card>
<el-card shadow="never" class="mt-10px"> </el-col>
<template #header> <el-col :xl="24" :lg="24" :md="24" :sm="24" :xs="24" class="mt-14px">
<div class="h-3 flex justify-between"> <el-card shadow="never">
<span>{{ t('workplace.notice') }}</span> <div class="title font-size-18px font-bold mb-10px">项目物料检测类型时间清单</div>
<el-link type="primary" :underline="false">{{ t('action.more') }}</el-link> <el-table :data="tableData1" style="width: 100%">
</div> <el-table-column label="序号" width="80" type="index" align="center" />
</template> <el-table-column prop="code" label="物料代码" align="center" />
<el-skeleton :loading="loading" animated> <el-table-column prop="name" label="物料名称" align="center" />
<div v-for="(item, index) in notice" :key="`dynamics-${index}`"> <el-table-column prop="type" label="检测类型" align="center" />
<div class="flex items-center"> <el-table-column prop="time" label="导入时间" align="center" />
<img :src="avatar" alt="" class="mr-20px h-35px w-35px rounded-[50%]" /> <el-table-column prop="people" label="操作人" align="center" />
<div> </el-table>
<div class="text-14px">
<Highlight :keys="item.keys.map((v) => t(v))">
{{ item.type }} : {{ item.title }}
</Highlight>
</div>
<div class="mt-15px text-12px text-gray-400">
{{ formatTime(item.date, 'yyyy-MM-dd') }}
</div>
</div>
</div>
<el-divider />
</div>
</el-skeleton>
</el-card> </el-card>
</el-col> </el-col>
</el-row> </el-row>
@ -163,185 +41,156 @@
<script lang="ts" setup> <script lang="ts" setup>
import { set } from 'lodash-es' import { set } from 'lodash-es'
import { EChartsOption } from 'echarts' import { EChartsOption } from 'echarts'
import { formatTime } from '@/utils' import { lineOptions, barOptions } from './echarts-data'
import { useUserStore } from '@/store/modules/user'
import { useWatermark } from '@/hooks/web/useWatermark'
import avatarImg from '@/assets/imgs/avatar.gif'
import type { WorkplaceTotal, Project, Notice, Shortcut } from './types'
import { pieOptions, barOptions } from './echarts-data'
defineOptions({ name: 'Home' }) defineOptions({ name: 'Home' })
const { t } = useI18n() const { t } = useI18n()
const userStore = useUserStore() const tableData = [
const { setWatermark } = useWatermark() {
const loading = ref(true) project: '项目1',
const avatar = userStore.getUser.avatar ? userStore.getUser.avatar : avatarImg code: 'jkhdkjgh',
const username = userStore.getUser.nickname name: '名字1',
const pieOptionsData = reactive<EChartsOption>(pieOptions) as EChartsOption type: '类型1',
// num: 30
let totalSate = reactive<WorkplaceTotal>({ },
project: 0, {
access: 0, project: '项目1',
todo: 0 code: 'jkhdkjgh',
}) name: '名字1',
type: '类型1',
const getCount = async () => { num: 30
const data = { },
project: 40, {
access: 2340, project: '项目1',
todo: 10 code: 'jkhdkjgh',
name: '名字1',
type: '类型1',
num: 30
},
{
project: '项目1',
code: 'jkhdkjgh',
name: '名字1',
type: '类型1',
num: 30
} }
totalSate = Object.assign(totalSate, data) ]
} const tableData1 = [
{
// code: 'jkhdkjgh',
let projects = reactive<Project[]>([]) name: '名字1',
const getProject = async () => { type: '类型1',
time: '2023-12-12 06:00:00',
people:'小张'
},
{
code: 'jkhdkjgh',
name: '名字1',
type: '类型1',
time: '2023-12-12 06:00:00',
people:'小张'
},
{
code: 'jkhdkjgh',
name: '名字1',
type: '类型1',
time: '2023-12-12 06:00:00',
people:'小张'
},
{
code: 'jkhdkjgh',
name: '名字1',
type: '类型1',
time: '2023-12-12 06:00:00',
people:'小张'
}
]
const barOptionsData = reactive<EChartsOption>(barOptions) as EChartsOption
const getWeeklyUserActivity = async () => {
const data = [ const data = [
{ { value: 13253, name: 'analysis.monday' },
name: 'Github', { value: 34235, name: 'analysis.tuesday' },
icon: 'akar-icons:github-fill', { value: 26321, name: 'analysis.wednesday' },
message: 'workplace.introduction', { value: 12340, name: 'analysis.thursday' },
personal: 'Archer', { value: 24643, name: 'analysis.friday' },
time: new Date() { value: 1322, name: 'analysis.saturday' },
}, { value: 1324, name: 'analysis.sunday' }
{
name: 'Vue',
icon: 'logos:vue',
message: 'workplace.introduction',
personal: 'Archer',
time: new Date()
},
{
name: 'Angular',
icon: 'logos:angular-icon',
message: 'workplace.introduction',
personal: 'Archer',
time: new Date()
},
{
name: 'React',
icon: 'logos:react',
message: 'workplace.introduction',
personal: 'Archer',
time: new Date()
},
{
name: 'Webpack',
icon: 'logos:webpack',
message: 'workplace.introduction',
personal: 'Archer',
time: new Date()
},
{
name: 'Vite',
icon: 'vscode-icons:file-type-vite',
message: 'workplace.introduction',
personal: 'Archer',
time: new Date()
}
] ]
projects = Object.assign(projects, data) const data1 = [
} { value: 23444, name: 'analysis.monday' },
{ value: 12344, name: 'analysis.tuesday' },
// { value: 34455, name: 'analysis.wednesday' },
let notice = reactive<Notice[]>([]) { value: 3434, name: 'analysis.thursday' },
const getNotice = async () => { { value: 43333, name: 'analysis.friday' },
const data = [ { value: 45555, name: 'analysis.saturday' },
{ { value: 1324, name: 'analysis.sunday' }
title: '系统升级版本',
type: '通知',
keys: ['通知', '升级'],
date: new Date()
},
{
title: '系统凌晨维护',
type: '公告',
keys: ['公告', '维护'],
date: new Date()
},
{
title: '系统升级版本',
type: '通知',
keys: ['通知', '升级'],
date: new Date()
},
{
title: '系统凌晨维护',
type: '公告',
keys: ['公告', '维护'],
date: new Date()
}
] ]
notice = Object.assign(notice, data) const data2 = [
} { value: 4344, name: 'analysis.monday' },
{ value: 34454, name: 'analysis.tuesday' },
// { value: 4322, name: 'analysis.wednesday' },
let shortcut = reactive<Shortcut[]>([]) { value: 9897, name: 'analysis.thursday' },
{ value: 89076, name: 'analysis.friday' },
const getShortcut = async () => { { value: 5434, name: 'analysis.saturday' },
const data = [ { value: 67674, name: 'analysis.sunday' }
{ ]
name: 'Github', const data3 = [
icon: 'akar-icons:github-fill', { value: 4344, name: 'analysis.monday' },
url: 'github.io' { value: 34454, name: 'analysis.tuesday' },
}, { value: 4322, name: 'analysis.wednesday' },
{ { value: 9897, name: 'analysis.thursday' },
name: 'Vue', { value: 89076, name: 'analysis.friday' },
icon: 'logos:vue', { value: 5434, name: 'analysis.saturday' },
url: 'vuejs.org' { value: 67674, name: 'analysis.sunday' }
}, ]
set(barOptionsData, 'title', {
text: '检测类型导入次数(近7天)',
left: 0
})
set(
barOptionsData,
'xAxis.data',
data.map((v) => t(v.name))
)
set(barOptionsData, 'legend', {
data: [t('analysis.activeQuantity'), '11', '22', '23'],
top: 0,
right: 20
})
set(barOptionsData, 'series', [
{ {
name: 'Vite', name: t('analysis.activeQuantity'),
icon: 'vscode-icons:file-type-vite', data: data.map((v) => v.value),
url: 'https://vitejs.dev/' type: 'bar',
animationDuration: 2000,
animationEasing: 'cubicInOut'
}, },
{ {
name: 'Angular', name: '11',
icon: 'logos:angular-icon', data: data1.map((v) => v.value),
url: 'github.io' type: 'bar',
animationDuration: 2000,
animationEasing: 'cubicInOut'
}, },
{ {
name: 'React', name: '22',
icon: 'logos:react', data: data2.map((v) => v.value),
url: 'github.io' type: 'bar',
animationDuration: 2000,
animationEasing: 'cubicInOut'
}, },
{ {
name: 'Webpack', name: '23',
icon: 'logos:webpack', data: data3.map((v) => v.value),
url: 'github.io' type: 'bar',
} animationDuration: 2000,
] animationEasing: 'cubicInOut'
shortcut = Object.assign(shortcut, data)
}
//
const getUserAccessSource = async () => {
const data = [
{ value: 335, name: 'analysis.directAccess' },
{ value: 310, name: 'analysis.mailMarketing' },
{ value: 234, name: 'analysis.allianceAdvertising' },
{ value: 135, name: 'analysis.videoAdvertising' },
{ value: 1548, name: 'analysis.searchEngines' }
]
set(
pieOptionsData,
'legend.data',
data.map((v) => t(v.name))
)
pieOptionsData!.series![0].data = data.map((v) => {
return {
name: t(v.name),
value: v.value
} }
}) ])
} }
const barOptionsData = reactive<EChartsOption>(barOptions) as EChartsOption
// const lineOptionsData = reactive<EChartsOption>(lineOptions) as EChartsOption
const getWeeklyUserActivity = async () => { const getWeeklyUserActivity1 = async () => {
const data = [ const data = [
{ value: 13253, name: 'analysis.monday' }, { value: 13253, name: 'analysis.monday' },
{ value: 34235, name: 'analysis.tuesday' }, { value: 34235, name: 'analysis.tuesday' },
@ -351,31 +200,91 @@ const getWeeklyUserActivity = async () => {
{ value: 1322, name: 'analysis.saturday' }, { value: 1322, name: 'analysis.saturday' },
{ value: 1324, name: 'analysis.sunday' } { value: 1324, name: 'analysis.sunday' }
] ]
const data1 = [
{ value: 23444, name: 'analysis.monday' },
{ value: 12344, name: 'analysis.tuesday' },
{ value: 34455, name: 'analysis.wednesday' },
{ value: 3434, name: 'analysis.thursday' },
{ value: 43333, name: 'analysis.friday' },
{ value: 45555, name: 'analysis.saturday' },
{ value: 1324, name: 'analysis.sunday' }
]
const data2 = [
{ value: 4344, name: 'analysis.monday' },
{ value: 34454, name: 'analysis.tuesday' },
{ value: 4322, name: 'analysis.wednesday' },
{ value: 9897, name: 'analysis.thursday' },
{ value: 89076, name: 'analysis.friday' },
{ value: 5434, name: 'analysis.saturday' },
{ value: 67674, name: 'analysis.sunday' }
]
set(lineOptionsData, 'title', {
text: '检测类型导入次数(近7天)',
left: 0
})
set( set(
barOptionsData, lineOptionsData,
'xAxis.data', 'xAxis.data',
data.map((v) => t(v.name)) data.map((v) => t(v.name))
) )
set(barOptionsData, 'series', [ set(lineOptionsData, 'legend', {
data: [t('analysis.activeQuantity'), '11', '22', '23'],
top: 0,
right: 20
})
set(lineOptionsData, 'series', [
{ {
name: t('analysis.activeQuantity'), name: t('analysis.activeQuantity'),
data: data.map((v) => v.value), data: data.map((v) => v.value),
type: 'bar' smooth: true,
type: 'line',
animationDuration: 2000,
animationEasing: 'cubicInOut'
},
{
name: '11',
data: data1.map((v) => v.value),
smooth: true,
type: 'line',
animationDuration: 2000,
animationEasing: 'cubicInOut'
},
{
name: '22',
data: data2.map((v) => v.value),
smooth: true,
type: 'line',
animationDuration: 2000,
animationEasing: 'cubicInOut'
},
{
name: '23',
data: data1.map((v) => v.value),
smooth: true,
type: 'line',
animationDuration: 2000,
animationEasing: 'cubicInOut'
} }
]) ])
} }
onMounted(() => {
const getAllApi = async () => { getWeeklyUserActivity()
await Promise.all([ getWeeklyUserActivity1()
getCount(), })
getProject(),
getNotice(),
getShortcut(),
getUserAccessSource(),
getWeeklyUserActivity()
])
loading.value = false
}
getAllApi()
</script> </script>
<style lang="scss" scoped>
.title{
position: relative;
padding-left: 16px;
&::after{
content: '';
position: absolute;
left: 0px;
width: 5px;
height: 20px;
background: #409eff;
top: 50%;
margin-top: -9px;
}
}
</style>

Loading…
Cancel
Save