perf(build): 图标改为离线子集并精简图表依赖
web-ci / build (push) Canceled after 0s

This commit is contained in:
Vicky authored and trae-solo-agent committed 2026-10-30 17:14:51 +08:00
1 parent dd4be08d49
commit 2f52011491
7 files changed
+34 -67

No files matched your search

+18 -8
View File
@@ -3,7 +3,7 @@
<script setup lang="ts">
import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'
import echarts from '@/plugins/echarts'
import type { ECharts } from 'echarts/core'
import type { DashboardOverview, DashboardTrend } from '@/api/admin/dashboard'
import { formatCount } from '@/utils/format'
@@ -16,8 +16,10 @@ const props = defineProps<{
const trendRef = ref<HTMLElement>()
const deviceRef = ref<HTMLElement>()
const clock = ref('')
let trendChart: echarts.ECharts | null = null
let deviceChart: echarts.ECharts | null = null
let trendChart: ECharts | null = null
let deviceChart: ECharts | null = null
let echartsPromise: Promise<typeof import('@/plugins/echarts').default> | null = null
let active = true
let timer = 0
const AXIS = '#909399'
@@ -78,12 +80,19 @@ function tick() {
clock.value = new Date().toLocaleString('zh-CN', { hour12: false })
}
function renderCharts() {
renderTrend()
renderDevices()
async function loadEcharts() {
echartsPromise ??= import('@/plugins/echarts').then((module) => module.default)
return echartsPromise
}
function renderTrend() {
async function renderCharts() {
const echarts = await loadEcharts()
if (!active) return
renderTrend(echarts)
renderDevices(echarts)
}
function renderTrend(echarts: typeof import('@/plugins/echarts').default) {
if (!trendRef.value) return
trendChart = trendChart ?? echarts.init(trendRef.value)
const trend = props.trend
@@ -130,7 +139,7 @@ function renderTrend() {
})
}
function renderDevices() {
function renderDevices(echarts: typeof import('@/plugins/echarts').default) {
if (!deviceRef.value) return
deviceChart = deviceChart ?? echarts.init(deviceRef.value)
const android = metric('user', 'androidActive7d') ?? 0
@@ -186,6 +195,7 @@ onMounted(() => {
})
onBeforeUnmount(() => {
active = false
window.clearInterval(timer)
window.removeEventListener('resize', onResize)
trendChart?.dispose()