perf: 前端按需引入 Element Plus + Vite 拆包 + template 优化
This commit is contained in:
@@ -428,7 +428,7 @@
|
||||
|
||||
<div v-if="expandedId === snap.id" class="snap-body">
|
||||
<el-table
|
||||
:data="groupRows(snap.snapshot)"
|
||||
:data="groupRows(snap)"
|
||||
size="small"
|
||||
:header-cell-style="{ background: 'rgba(255, 244, 232, 0.02)', color: 'var(--text-soft)' }"
|
||||
:cell-style="{ background: 'transparent', color: 'var(--text-primary)' }"
|
||||
@@ -725,9 +725,15 @@ const toUTC = (t: string) => /[Z+\-]\d*$/.test(t.trim()) ? t : `${t}Z`
|
||||
const fmtTime = (t: string) => dayjs(toUTC(t)).format('MM-DD HH:mm:ss')
|
||||
const fmtTimeFull = (t: string) => dayjs(toUTC(t)).format('YYYY-MM-DD HH:mm:ss')
|
||||
|
||||
function groupRows(snapshot: any) {
|
||||
if (!snapshot?.groups) return []
|
||||
return Object.values(snapshot.groups) as any[]
|
||||
const _groupRowsCache = new Map<number, any[]>()
|
||||
|
||||
function groupRows(snap: { id: number; snapshot: any }) {
|
||||
if (!snap?.snapshot?.groups) return []
|
||||
const cached = _groupRowsCache.get(snap.id)
|
||||
if (cached) return cached
|
||||
const rows = Object.values(snap.snapshot.groups) as any[]
|
||||
_groupRowsCache.set(snap.id, rows)
|
||||
return rows
|
||||
}
|
||||
|
||||
function shrinkError(value: string) {
|
||||
@@ -833,6 +839,7 @@ function openDetail(row: UpstreamData) {
|
||||
generatedKeys.value = []
|
||||
snapshotOffset.value = 0
|
||||
expandedId.value = null
|
||||
_groupRowsCache.clear()
|
||||
detailVisible.value = true
|
||||
}
|
||||
|
||||
@@ -854,6 +861,7 @@ async function loadSnapshots() {
|
||||
try {
|
||||
const res = await upstreamsApi.listSnapshots(detailUpstream.value.id, snapshotLimit, snapshotOffset.value)
|
||||
snapshots.value = res.data
|
||||
_groupRowsCache.clear()
|
||||
if (res.data.length > 0 && expandedId.value === null) {
|
||||
expandedId.value = res.data[0].id
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user