@vitalens/panel 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +64 -2
- package/dist/PerfPanel.vue.d.ts +8 -0
- package/dist/PerfPanel.vue.d.ts.map +1 -0
- package/dist/composables/usePerfMetrics.d.ts +24 -0
- package/dist/composables/usePerfMetrics.d.ts.map +1 -0
- package/dist/composables/usePerfRecords.d.ts +28 -0
- package/dist/composables/usePerfRecords.d.ts.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1079 -0
- package/dist/index.js.map +1 -0
- package/dist/style.css +1 -0
- package/dist/types.d.ts +83 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +44 -3
package/dist/index.js
ADDED
|
@@ -0,0 +1,1079 @@
|
|
|
1
|
+
import { computed as R, shallowRef as We, ref as x, watch as B, onBeforeUnmount as Le, defineComponent as Xe, onMounted as Ke, nextTick as Qe, onErrorCaptured as Ze, openBlock as p, createElementBlock as f, createElementVNode as l, toDisplayString as w, Fragment as O, unref as D, createCommentVNode as H, renderList as z, withDirectives as et, vModelText as tt, normalizeClass as we, createTextVNode as nt } from "vue";
|
|
2
|
+
import { LineChart as at } from "echarts/charts";
|
|
3
|
+
import { GridComponent as st, TooltipComponent as rt, LegendComponent as lt } from "echarts/components";
|
|
4
|
+
import { use as ot, init as it } from "echarts/core";
|
|
5
|
+
import { CanvasRenderer as ut } from "echarts/renderers";
|
|
6
|
+
const Ie = 60 * 1e3, $e = 60 * Ie, ct = 2 * $e, pt = 1e3, ft = 5, dt = /* @__PURE__ */ new Set([
|
|
7
|
+
"error",
|
|
8
|
+
"request",
|
|
9
|
+
"longTask",
|
|
10
|
+
"event",
|
|
11
|
+
"exposure"
|
|
12
|
+
]);
|
|
13
|
+
function W(n, u) {
|
|
14
|
+
var v;
|
|
15
|
+
const o = n.filter((C) => Number.isFinite(C)).sort((C, M) => C - M);
|
|
16
|
+
if (o.length === 0) return null;
|
|
17
|
+
const s = Math.min(o.length - 1, Math.max(0, Math.ceil(o.length * u) - 1));
|
|
18
|
+
return (v = o[s]) != null ? v : null;
|
|
19
|
+
}
|
|
20
|
+
function mt() {
|
|
21
|
+
return {
|
|
22
|
+
vital: 0,
|
|
23
|
+
error: 0,
|
|
24
|
+
request: 0,
|
|
25
|
+
route: 0,
|
|
26
|
+
resource: 0,
|
|
27
|
+
longTask: 0,
|
|
28
|
+
event: 0,
|
|
29
|
+
exposure: 0
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function re(n) {
|
|
33
|
+
return n < 10 ? `0${n}` : String(n);
|
|
34
|
+
}
|
|
35
|
+
function _t(n, u) {
|
|
36
|
+
const o = new Date(n), s = re(o.getMonth() + 1), v = re(o.getDate()), C = re(o.getHours());
|
|
37
|
+
return u === "hour" ? `${s}-${v} ${C}:00` : `${C}:${re(o.getMinutes())}`;
|
|
38
|
+
}
|
|
39
|
+
function yt(n) {
|
|
40
|
+
let u = Number.POSITIVE_INFINITY, o = Number.NEGATIVE_INFINITY;
|
|
41
|
+
for (const s of n)
|
|
42
|
+
Number.isFinite(s.timestamp) && (s.timestamp < u && (u = s.timestamp), s.timestamp > o && (o = s.timestamp));
|
|
43
|
+
return !Number.isFinite(u) || !Number.isFinite(o) ? "minute" : o - u >= ct ? "hour" : "minute";
|
|
44
|
+
}
|
|
45
|
+
function fe(n, u) {
|
|
46
|
+
return Array.from(n, ([o, s]) => {
|
|
47
|
+
const v = {
|
|
48
|
+
key: o,
|
|
49
|
+
label: s.label,
|
|
50
|
+
count: s.count
|
|
51
|
+
};
|
|
52
|
+
return s.totalDuration > 0 && s.count > 0 && (v.avgDurationMs = s.totalDuration / s.count), v;
|
|
53
|
+
}).sort((o, s) => s.count - o.count || o.label.localeCompare(s.label)).slice(0, u);
|
|
54
|
+
}
|
|
55
|
+
function de(n) {
|
|
56
|
+
return n.type !== "error" ? 1 : n.count && n.count > 0 ? n.count : 1;
|
|
57
|
+
}
|
|
58
|
+
function vt(n) {
|
|
59
|
+
var U;
|
|
60
|
+
const u = Math.max(1, Math.trunc((U = n.topLimit) != null ? U : ft)), o = R(() => {
|
|
61
|
+
const m = mt(), d = {
|
|
62
|
+
LCP: [],
|
|
63
|
+
INP: [],
|
|
64
|
+
CLS: [],
|
|
65
|
+
FCP: [],
|
|
66
|
+
TTFB: []
|
|
67
|
+
};
|
|
68
|
+
let c = 0, _ = 0, b = 0, k = 0;
|
|
69
|
+
for (const g of n.records())
|
|
70
|
+
switch (m[g.type] += 1, k += 1, g.type) {
|
|
71
|
+
case "vital":
|
|
72
|
+
d[g.name].push(g.value);
|
|
73
|
+
break;
|
|
74
|
+
case "error":
|
|
75
|
+
c += de(g);
|
|
76
|
+
break;
|
|
77
|
+
case "request":
|
|
78
|
+
g.durationMs > pt && (_ += 1);
|
|
79
|
+
break;
|
|
80
|
+
case "longTask":
|
|
81
|
+
b += 1;
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
const S = {
|
|
85
|
+
LCP: W(d.LCP, 0.75),
|
|
86
|
+
INP: W(d.INP, 0.75),
|
|
87
|
+
CLS: W(d.CLS, 0.75),
|
|
88
|
+
FCP: W(d.FCP, 0.75),
|
|
89
|
+
TTFB: W(d.TTFB, 0.75)
|
|
90
|
+
};
|
|
91
|
+
return {
|
|
92
|
+
total: k,
|
|
93
|
+
vitals: S,
|
|
94
|
+
errors: c,
|
|
95
|
+
slowRequests: _,
|
|
96
|
+
longTasks: b,
|
|
97
|
+
byType: m
|
|
98
|
+
};
|
|
99
|
+
}), s = R(() => {
|
|
100
|
+
const m = n.records().filter((k) => dt.has(k.type)), d = yt(m), c = d === "hour" ? $e : Ie, _ = /* @__PURE__ */ new Map();
|
|
101
|
+
for (const k of m) {
|
|
102
|
+
if (!Number.isFinite(k.timestamp)) continue;
|
|
103
|
+
const S = Math.floor(k.timestamp / c) * c;
|
|
104
|
+
let g = _.get(S);
|
|
105
|
+
switch (g || (g = {
|
|
106
|
+
bucket: S,
|
|
107
|
+
label: _t(S, d),
|
|
108
|
+
errors: 0,
|
|
109
|
+
requests: 0,
|
|
110
|
+
longTasks: 0,
|
|
111
|
+
events: 0
|
|
112
|
+
}, _.set(S, g)), k.type) {
|
|
113
|
+
case "error":
|
|
114
|
+
g.errors += de(k);
|
|
115
|
+
break;
|
|
116
|
+
case "request":
|
|
117
|
+
g.requests += 1;
|
|
118
|
+
break;
|
|
119
|
+
case "longTask":
|
|
120
|
+
g.longTasks += 1;
|
|
121
|
+
break;
|
|
122
|
+
case "event":
|
|
123
|
+
case "exposure":
|
|
124
|
+
g.events += 1;
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
const b = Array.from(_.values()).sort((k, S) => k.bucket - S.bucket);
|
|
129
|
+
return { granularity: d, points: b };
|
|
130
|
+
}), v = R(() => s.value.points), C = R(() => s.value.granularity), M = R(() => {
|
|
131
|
+
var d;
|
|
132
|
+
const m = /* @__PURE__ */ new Map();
|
|
133
|
+
for (const c of n.records()) {
|
|
134
|
+
if (c.type !== "route") continue;
|
|
135
|
+
const _ = c.to.path || c.to.fullPath || "(未知路由)", b = (d = m.get(_)) != null ? d : { label: _, count: 0, totalDuration: 0 };
|
|
136
|
+
b.count += 1, b.totalDuration += Number.isFinite(c.durationMs) ? c.durationMs : 0, m.set(_, b);
|
|
137
|
+
}
|
|
138
|
+
return fe(m, u);
|
|
139
|
+
}), T = R(() => {
|
|
140
|
+
var d;
|
|
141
|
+
const m = /* @__PURE__ */ new Map();
|
|
142
|
+
for (const c of n.records()) {
|
|
143
|
+
if (c.type !== "error") continue;
|
|
144
|
+
const _ = c.fingerprint || c.message, b = c.message || c.name || "(未知错误)", k = (d = m.get(_)) != null ? d : { label: b, count: 0, totalDuration: 0 };
|
|
145
|
+
k.count += de(c), m.set(_, k);
|
|
146
|
+
}
|
|
147
|
+
return fe(m, u);
|
|
148
|
+
}), I = R(() => {
|
|
149
|
+
var d;
|
|
150
|
+
const m = /* @__PURE__ */ new Map();
|
|
151
|
+
for (const c of n.records()) {
|
|
152
|
+
if (c.type !== "event" && c.type !== "exposure") continue;
|
|
153
|
+
const _ = c.name || "(未命名事件)", b = (d = m.get(_)) != null ? d : { label: _, count: 0, totalDuration: 0 };
|
|
154
|
+
b.count += 1, m.set(_, b);
|
|
155
|
+
}
|
|
156
|
+
return fe(m, u);
|
|
157
|
+
});
|
|
158
|
+
return {
|
|
159
|
+
overview: o,
|
|
160
|
+
trend: v,
|
|
161
|
+
trendGranularity: C,
|
|
162
|
+
topRoutes: M,
|
|
163
|
+
topErrors: T,
|
|
164
|
+
topEvents: I
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
const me = 5e3, Re = 1e3, Se = 1e3, bt = 1e3;
|
|
168
|
+
function X(n) {
|
|
169
|
+
return n instanceof Error ? n.message : String(n);
|
|
170
|
+
}
|
|
171
|
+
function ht(n, u) {
|
|
172
|
+
return n.timestamp !== u.timestamp ? u.timestamp - n.timestamp : n.id === u.id ? 0 : n.id < u.id ? -1 : 1;
|
|
173
|
+
}
|
|
174
|
+
function kt(n) {
|
|
175
|
+
const u = n.replace(/[^\w-]+/g, "-") || "export", o = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
176
|
+
return `vitalens-${u}-${o}.json`;
|
|
177
|
+
}
|
|
178
|
+
function gt(n, u) {
|
|
179
|
+
try {
|
|
180
|
+
if (typeof document == "undefined" || typeof URL == "undefined" || typeof URL.createObjectURL != "function") return;
|
|
181
|
+
const o = URL.createObjectURL(n), s = document.createElement("a");
|
|
182
|
+
s.href = o, s.download = kt(u), s.rel = "noopener", document.body.appendChild(s), s.click(), s.remove(), setTimeout(() => {
|
|
183
|
+
try {
|
|
184
|
+
typeof URL.revokeObjectURL == "function" && URL.revokeObjectURL(o);
|
|
185
|
+
} catch {
|
|
186
|
+
}
|
|
187
|
+
}, 0);
|
|
188
|
+
} catch {
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
function Ct(n) {
|
|
192
|
+
const u = We([]), o = x(!1), s = x(""), v = x(!0);
|
|
193
|
+
let C = [], M = [], T = /* @__PURE__ */ new Map(), I = [], U = !1, m = 0, d, c, _ = !1;
|
|
194
|
+
function b() {
|
|
195
|
+
const r = n.appId(), i = /* @__PURE__ */ new Map(), h = (F) => {
|
|
196
|
+
for (const E of F)
|
|
197
|
+
r && E.appId !== r || Number.isFinite(E.timestamp) && i.set(E.id, E);
|
|
198
|
+
};
|
|
199
|
+
h(C), h(M), h(Array.from(T.values()));
|
|
200
|
+
const $ = Array.from(i.values()).sort(ht);
|
|
201
|
+
u.value = $.length > me ? $.slice(0, me) : $;
|
|
202
|
+
}
|
|
203
|
+
function k() {
|
|
204
|
+
if (T.size <= Re) return;
|
|
205
|
+
const r = T.size - Re;
|
|
206
|
+
let i = 0;
|
|
207
|
+
for (const h of T.keys())
|
|
208
|
+
if (T.delete(h), i += 1, i >= r) break;
|
|
209
|
+
}
|
|
210
|
+
function S() {
|
|
211
|
+
if (I.length !== 0) {
|
|
212
|
+
for (const r of I)
|
|
213
|
+
T.delete(r.id), T.set(r.id, r);
|
|
214
|
+
I = [], k(), b();
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
function g() {
|
|
218
|
+
!v.value || U || typeof document != "undefined" && document.visibilityState === "hidden" || S();
|
|
219
|
+
}
|
|
220
|
+
function le(r) {
|
|
221
|
+
if (r.length === 0) return;
|
|
222
|
+
const i = I.concat(r);
|
|
223
|
+
I = i.length > Se ? i.slice(i.length - Se) : i;
|
|
224
|
+
}
|
|
225
|
+
function K() {
|
|
226
|
+
typeof document != "undefined" && document.visibilityState === "visible" && g();
|
|
227
|
+
}
|
|
228
|
+
function Q() {
|
|
229
|
+
const r = n.perf();
|
|
230
|
+
if (!(!r || d || !v.value)) {
|
|
231
|
+
try {
|
|
232
|
+
d = r.subscribe((i) => {
|
|
233
|
+
le(i);
|
|
234
|
+
});
|
|
235
|
+
} catch (i) {
|
|
236
|
+
s.value = `订阅实时数据失败:${X(i)}`;
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
c = setInterval(g, bt), typeof document != "undefined" && !_ && (document.addEventListener("visibilitychange", K), _ = !0);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
function P() {
|
|
243
|
+
if (d) {
|
|
244
|
+
try {
|
|
245
|
+
d();
|
|
246
|
+
} catch {
|
|
247
|
+
}
|
|
248
|
+
d = void 0;
|
|
249
|
+
}
|
|
250
|
+
c !== void 0 && (clearInterval(c), c = void 0), typeof document != "undefined" && _ && (document.removeEventListener("visibilitychange", K), _ = !1);
|
|
251
|
+
}
|
|
252
|
+
async function N() {
|
|
253
|
+
const r = ++m;
|
|
254
|
+
o.value = !0;
|
|
255
|
+
try {
|
|
256
|
+
const i = n.perf();
|
|
257
|
+
if (!i) {
|
|
258
|
+
if (r !== m) return;
|
|
259
|
+
C = [], s.value = "";
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
const h = { order: "desc", limit: me }, $ = await i.query(h);
|
|
263
|
+
if (r !== m) return;
|
|
264
|
+
C = $, s.value = "";
|
|
265
|
+
} catch (i) {
|
|
266
|
+
if (r !== m) return;
|
|
267
|
+
s.value = `读取本地数据失败:${X(i)}`;
|
|
268
|
+
} finally {
|
|
269
|
+
r === m && (o.value = !1, b());
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
function L(r) {
|
|
273
|
+
if (r !== v.value) {
|
|
274
|
+
if (!r) {
|
|
275
|
+
S(), v.value = !1, P();
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
v.value = !0, n.perf() && (Q(), N());
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
async function V(r) {
|
|
282
|
+
const i = n.perf();
|
|
283
|
+
if (!i)
|
|
284
|
+
return s.value = "缺少 perf 实例,无法导入", 0;
|
|
285
|
+
U = !0, o.value = !0;
|
|
286
|
+
try {
|
|
287
|
+
const h = await i.importAll(r);
|
|
288
|
+
return await N(), h;
|
|
289
|
+
} catch (h) {
|
|
290
|
+
return s.value = `导入失败:${X(h)}`, 0;
|
|
291
|
+
} finally {
|
|
292
|
+
U = !1, o.value = !1;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
async function q() {
|
|
296
|
+
var r, i, h, $;
|
|
297
|
+
try {
|
|
298
|
+
const F = n.perf();
|
|
299
|
+
let E;
|
|
300
|
+
if (F)
|
|
301
|
+
E = await F.exportAll();
|
|
302
|
+
else {
|
|
303
|
+
const ie = {
|
|
304
|
+
formatVersion: 1,
|
|
305
|
+
appId: (r = n.appId()) != null ? r : "",
|
|
306
|
+
exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
307
|
+
records: u.value
|
|
308
|
+
};
|
|
309
|
+
E = new Blob([JSON.stringify(ie, null, 2)], { type: "application/json" });
|
|
310
|
+
}
|
|
311
|
+
const oe = ($ = (h = n.appId()) != null ? h : (i = n.perf()) == null ? void 0 : i.config.appId) != null ? $ : "export";
|
|
312
|
+
return gt(E, oe), E;
|
|
313
|
+
} catch (F) {
|
|
314
|
+
return s.value = `导出失败:${X(F)}`, null;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
async function Z() {
|
|
318
|
+
const r = n.perf();
|
|
319
|
+
if (!r)
|
|
320
|
+
return s.value = "缺少 perf 实例,无法清空", !1;
|
|
321
|
+
o.value = !0;
|
|
322
|
+
try {
|
|
323
|
+
return await r.clear(), C = [], T = /* @__PURE__ */ new Map(), I = [], s.value = "", b(), !0;
|
|
324
|
+
} catch (i) {
|
|
325
|
+
return s.value = `清空失败:${X(i)}`, !1;
|
|
326
|
+
} finally {
|
|
327
|
+
o.value = !1;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
return B(
|
|
331
|
+
() => n.perf(),
|
|
332
|
+
(r, i) => {
|
|
333
|
+
r !== i && (P(), I = [], T = /* @__PURE__ */ new Map(), r ? (v.value && Q(), N()) : (C = [], b()));
|
|
334
|
+
},
|
|
335
|
+
{ immediate: !0 }
|
|
336
|
+
), B(
|
|
337
|
+
() => n.records(),
|
|
338
|
+
(r) => {
|
|
339
|
+
M = r != null ? r : [], b();
|
|
340
|
+
},
|
|
341
|
+
{ immediate: !0 }
|
|
342
|
+
), B(
|
|
343
|
+
() => n.appId(),
|
|
344
|
+
() => {
|
|
345
|
+
b();
|
|
346
|
+
}
|
|
347
|
+
), Le(() => {
|
|
348
|
+
P(), I = [], T = /* @__PURE__ */ new Map(), C = [], M = [];
|
|
349
|
+
}), {
|
|
350
|
+
records: u,
|
|
351
|
+
loading: o,
|
|
352
|
+
error: s,
|
|
353
|
+
realtime: v,
|
|
354
|
+
refresh: N,
|
|
355
|
+
importFile: V,
|
|
356
|
+
exportFile: q,
|
|
357
|
+
clearLocal: Z,
|
|
358
|
+
setRealtime: L
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
const Tt = {
|
|
362
|
+
class: "perf-panel",
|
|
363
|
+
"aria-label": "性能面板"
|
|
364
|
+
}, wt = {
|
|
365
|
+
key: 0,
|
|
366
|
+
class: "perf-panel__fallback",
|
|
367
|
+
role: "alert"
|
|
368
|
+
}, Rt = { class: "perf-panel__fallback-text" }, St = { class: "perf-panel__header" }, Lt = { class: "perf-panel__actions" }, It = ["disabled"], $t = ["disabled"], Mt = ["disabled"], Et = { class: "perf-panel__switch" }, Pt = ["checked", "disabled"], xt = {
|
|
369
|
+
key: 0,
|
|
370
|
+
class: "perf-panel__status",
|
|
371
|
+
role: "status"
|
|
372
|
+
}, Nt = {
|
|
373
|
+
key: 1,
|
|
374
|
+
class: "perf-panel__notice",
|
|
375
|
+
role: "alert"
|
|
376
|
+
}, Ft = {
|
|
377
|
+
key: 2,
|
|
378
|
+
class: "perf-panel__empty"
|
|
379
|
+
}, At = {
|
|
380
|
+
key: 3,
|
|
381
|
+
class: "perf-panel__empty"
|
|
382
|
+
}, Ot = {
|
|
383
|
+
class: "perf-panel__section",
|
|
384
|
+
"aria-label": "概览"
|
|
385
|
+
}, Dt = { class: "perf-panel__overview" }, Ut = ["data-metric"], qt = { class: "perf-panel__card-label" }, zt = { class: "perf-panel__card-value" }, Bt = {
|
|
386
|
+
key: 0,
|
|
387
|
+
class: "perf-panel__card-unit"
|
|
388
|
+
}, Vt = {
|
|
389
|
+
class: "perf-panel__section",
|
|
390
|
+
"aria-label": "趋势"
|
|
391
|
+
}, Ht = { class: "perf-panel__section-head" }, Gt = { class: "perf-panel__section-meta" }, jt = { class: "perf-panel__chart-wrap" }, Yt = {
|
|
392
|
+
key: 0,
|
|
393
|
+
class: "perf-panel__chart-empty"
|
|
394
|
+
}, Jt = {
|
|
395
|
+
key: 0,
|
|
396
|
+
class: "perf-panel__notice"
|
|
397
|
+
}, Wt = {
|
|
398
|
+
class: "perf-panel__section",
|
|
399
|
+
"aria-label": "Top 排行"
|
|
400
|
+
}, Xt = { class: "perf-panel__top-grid" }, Kt = { class: "perf-panel__top-title" }, Qt = {
|
|
401
|
+
key: 0,
|
|
402
|
+
class: "perf-panel__top-list"
|
|
403
|
+
}, Zt = ["title"], en = { class: "perf-panel__top-count" }, tn = {
|
|
404
|
+
key: 1,
|
|
405
|
+
class: "perf-panel__top-empty"
|
|
406
|
+
}, nn = {
|
|
407
|
+
class: "perf-panel__section perf-panel__details",
|
|
408
|
+
"aria-label": "明细"
|
|
409
|
+
}, an = { class: "perf-panel__details-head" }, sn = {
|
|
410
|
+
class: "perf-panel__tabs",
|
|
411
|
+
role: "tablist",
|
|
412
|
+
"aria-label": "明细分类"
|
|
413
|
+
}, rn = ["aria-selected", "data-tab", "onClick"], ln = { class: "perf-panel__tab-count" }, on = { class: "perf-panel__table-wrap" }, un = {
|
|
414
|
+
key: 0,
|
|
415
|
+
class: "perf-panel__table"
|
|
416
|
+
}, cn = {
|
|
417
|
+
key: 1,
|
|
418
|
+
class: "perf-panel__empty"
|
|
419
|
+
}, pn = {
|
|
420
|
+
key: 0,
|
|
421
|
+
class: "perf-panel__pagination"
|
|
422
|
+
}, fn = ["disabled"], dn = ["disabled"], _e = 20, mn = /* @__PURE__ */ Xe({
|
|
423
|
+
name: "PerfPanel",
|
|
424
|
+
__name: "PerfPanel",
|
|
425
|
+
props: {
|
|
426
|
+
perf: {},
|
|
427
|
+
records: { default: () => [] },
|
|
428
|
+
appId: {}
|
|
429
|
+
},
|
|
430
|
+
setup(n) {
|
|
431
|
+
const u = n;
|
|
432
|
+
ot([at, st, rt, lt, ut]);
|
|
433
|
+
const o = ["#d54941", "#3f6ad8", "#c87f2c", "#2f8f6b"], s = [
|
|
434
|
+
"--perf-panel-chart-error",
|
|
435
|
+
"--perf-panel-chart-request",
|
|
436
|
+
"--perf-panel-chart-long-task",
|
|
437
|
+
"--perf-panel-chart-event"
|
|
438
|
+
], v = {
|
|
439
|
+
error: ["error"],
|
|
440
|
+
request: ["request"],
|
|
441
|
+
route: ["route"],
|
|
442
|
+
resource: ["resource"],
|
|
443
|
+
event: ["event", "exposure"]
|
|
444
|
+
}, C = [
|
|
445
|
+
{
|
|
446
|
+
tab: "error",
|
|
447
|
+
label: "错误",
|
|
448
|
+
columns: [
|
|
449
|
+
{ key: "time", label: "时间" },
|
|
450
|
+
{ key: "source", label: "来源" },
|
|
451
|
+
{ key: "name", label: "名称" },
|
|
452
|
+
{ key: "message", label: "消息" }
|
|
453
|
+
]
|
|
454
|
+
},
|
|
455
|
+
{
|
|
456
|
+
tab: "request",
|
|
457
|
+
label: "请求",
|
|
458
|
+
columns: [
|
|
459
|
+
{ key: "time", label: "时间" },
|
|
460
|
+
{ key: "method", label: "方法" },
|
|
461
|
+
{ key: "url", label: "URL" },
|
|
462
|
+
{ key: "status", label: "状态" },
|
|
463
|
+
{ key: "duration", label: "耗时" }
|
|
464
|
+
]
|
|
465
|
+
},
|
|
466
|
+
{
|
|
467
|
+
tab: "route",
|
|
468
|
+
label: "路由",
|
|
469
|
+
columns: [
|
|
470
|
+
{ key: "time", label: "时间" },
|
|
471
|
+
{ key: "from", label: "来源" },
|
|
472
|
+
{ key: "to", label: "目标" },
|
|
473
|
+
{ key: "navigation", label: "类型" },
|
|
474
|
+
{ key: "duration", label: "耗时" }
|
|
475
|
+
]
|
|
476
|
+
},
|
|
477
|
+
{
|
|
478
|
+
tab: "resource",
|
|
479
|
+
label: "资源",
|
|
480
|
+
columns: [
|
|
481
|
+
{ key: "time", label: "时间" },
|
|
482
|
+
{ key: "url", label: "URL" },
|
|
483
|
+
{ key: "initiator", label: "发起方" },
|
|
484
|
+
{ key: "status", label: "状态" },
|
|
485
|
+
{ key: "duration", label: "耗时" },
|
|
486
|
+
{ key: "result", label: "结果" }
|
|
487
|
+
]
|
|
488
|
+
},
|
|
489
|
+
{
|
|
490
|
+
tab: "event",
|
|
491
|
+
label: "埋点",
|
|
492
|
+
columns: [
|
|
493
|
+
{ key: "time", label: "时间" },
|
|
494
|
+
{ key: "kind", label: "类型" },
|
|
495
|
+
{ key: "name", label: "名称" },
|
|
496
|
+
{ key: "source", label: "来源" },
|
|
497
|
+
{ key: "props", label: "属性" }
|
|
498
|
+
]
|
|
499
|
+
}
|
|
500
|
+
], {
|
|
501
|
+
records: M,
|
|
502
|
+
loading: T,
|
|
503
|
+
error: I,
|
|
504
|
+
realtime: U,
|
|
505
|
+
refresh: m,
|
|
506
|
+
importFile: d,
|
|
507
|
+
exportFile: c,
|
|
508
|
+
clearLocal: _,
|
|
509
|
+
setRealtime: b
|
|
510
|
+
} = Ct({
|
|
511
|
+
perf: () => u.perf,
|
|
512
|
+
records: () => u.records,
|
|
513
|
+
appId: () => u.appId
|
|
514
|
+
}), { overview: k, trend: S, trendGranularity: g, topRoutes: le, topErrors: K, topEvents: Q } = vt({
|
|
515
|
+
records: () => M.value
|
|
516
|
+
}), P = x("error"), N = x(""), L = x(1), V = x(""), q = x(""), Z = x(null), r = x(null);
|
|
517
|
+
let i = null, h = null, $ = !1;
|
|
518
|
+
const F = R(() => M.value.length), E = R(() => {
|
|
519
|
+
const e = k.value.vitals;
|
|
520
|
+
return [
|
|
521
|
+
{ key: "LCP", label: "LCP p75", value: j("LCP", e.LCP), unit: "ms" },
|
|
522
|
+
{ key: "INP", label: "INP p75", value: j("INP", e.INP), unit: "ms" },
|
|
523
|
+
{ key: "CLS", label: "CLS p75", value: j("CLS", e.CLS), unit: "" },
|
|
524
|
+
{ key: "FCP", label: "FCP p75", value: j("FCP", e.FCP), unit: "ms" },
|
|
525
|
+
{ key: "TTFB", label: "TTFB p75", value: j("TTFB", e.TTFB), unit: "ms" },
|
|
526
|
+
{ key: "errors", label: "错误数", value: String(k.value.errors), unit: "条" },
|
|
527
|
+
{ key: "slowRequests", label: "慢请求", value: String(k.value.slowRequests), unit: "条" },
|
|
528
|
+
{ key: "longTasks", label: "长任务", value: String(k.value.longTasks), unit: "个" }
|
|
529
|
+
];
|
|
530
|
+
}), oe = R(() => [
|
|
531
|
+
{ key: "routes", title: "Top 路由", items: le.value },
|
|
532
|
+
{ key: "errors", title: "Top 错误", items: K.value },
|
|
533
|
+
{ key: "events", title: "Top 埋点", items: Q.value }
|
|
534
|
+
]), ie = R(() => v[P.value]), Me = R(() => {
|
|
535
|
+
const e = ie.value, t = N.value.trim().toLowerCase();
|
|
536
|
+
return M.value.filter((a) => e.includes(a.type) ? t.length === 0 ? !0 : Pe(a).toLowerCase().includes(t) : !1);
|
|
537
|
+
}), ye = R(() => Me.value.map(xe)), ue = R(() => ye.value.length), ee = R(() => Math.max(1, Math.ceil(ue.value / _e))), ve = R(() => {
|
|
538
|
+
const e = (L.value - 1) * _e;
|
|
539
|
+
return ye.value.slice(e, e + _e);
|
|
540
|
+
}), be = R(
|
|
541
|
+
() => {
|
|
542
|
+
var e, t;
|
|
543
|
+
return (t = (e = C.find((a) => a.tab === P.value)) == null ? void 0 : e.columns) != null ? t : [];
|
|
544
|
+
}
|
|
545
|
+
);
|
|
546
|
+
function te(e) {
|
|
547
|
+
return e instanceof Error ? e.message : String(e);
|
|
548
|
+
}
|
|
549
|
+
function G(e) {
|
|
550
|
+
return e < 10 ? `0${e}` : String(e);
|
|
551
|
+
}
|
|
552
|
+
function Ee(e) {
|
|
553
|
+
if (!Number.isFinite(e)) return "—";
|
|
554
|
+
const t = new Date(e), a = G(t.getMonth() + 1), y = G(t.getDate());
|
|
555
|
+
return `${a}-${y} ${G(t.getHours())}:${G(t.getMinutes())}:${G(t.getSeconds())}`;
|
|
556
|
+
}
|
|
557
|
+
function ne(e) {
|
|
558
|
+
return Number.isFinite(e) ? e >= 1e3 ? `${(e / 1e3).toFixed(2)} s` : `${Math.round(e)} ms` : "—";
|
|
559
|
+
}
|
|
560
|
+
function j(e, t) {
|
|
561
|
+
return t === null || !Number.isFinite(t) ? "—" : e === "CLS" ? t.toFixed(3) : String(Math.round(t));
|
|
562
|
+
}
|
|
563
|
+
function ae(e) {
|
|
564
|
+
return e && (e.path || e.fullPath || e.name) || "—";
|
|
565
|
+
}
|
|
566
|
+
function se(e) {
|
|
567
|
+
if (!e) return "—";
|
|
568
|
+
try {
|
|
569
|
+
const t = JSON.stringify(e);
|
|
570
|
+
return typeof t != "string" ? "—" : t.length > 200 ? `${t.slice(0, 197)}...` : t;
|
|
571
|
+
} catch {
|
|
572
|
+
return "[无法序列化]";
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
function Pe(e) {
|
|
576
|
+
var t, a, y, A, Y, J, Te;
|
|
577
|
+
switch (e.type) {
|
|
578
|
+
case "vital":
|
|
579
|
+
return `${e.name} ${e.value}`;
|
|
580
|
+
case "error":
|
|
581
|
+
return `${e.message} ${(t = e.name) != null ? t : ""} ${e.source} ${e.fingerprint} ${(a = e.stack) != null ? a : ""}`;
|
|
582
|
+
case "request":
|
|
583
|
+
return `${e.method} ${e.url} ${(y = e.status) != null ? y : ""}`;
|
|
584
|
+
case "route":
|
|
585
|
+
return `${ae(e.to)} ${ae(e.from)}`;
|
|
586
|
+
case "resource":
|
|
587
|
+
return `${e.url} ${(A = e.initiatorType) != null ? A : ""}`;
|
|
588
|
+
case "longTask":
|
|
589
|
+
return `${(Y = e.name) != null ? Y : ""} ${e.durationMs}`;
|
|
590
|
+
case "event":
|
|
591
|
+
return `${e.name} ${(J = e.source) != null ? J : ""} ${se(e.props)}`;
|
|
592
|
+
case "exposure":
|
|
593
|
+
return `${e.name} ${(Te = e.target) != null ? Te : ""} ${se(e.props)}`;
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
function xe(e) {
|
|
597
|
+
var a, y, A, Y, J;
|
|
598
|
+
const t = Ee(e.timestamp);
|
|
599
|
+
switch (e.type) {
|
|
600
|
+
case "error":
|
|
601
|
+
return {
|
|
602
|
+
id: e.id,
|
|
603
|
+
timestamp: e.timestamp,
|
|
604
|
+
cells: {
|
|
605
|
+
time: t,
|
|
606
|
+
source: e.source,
|
|
607
|
+
name: (a = e.name) != null ? a : "—",
|
|
608
|
+
message: e.message
|
|
609
|
+
}
|
|
610
|
+
};
|
|
611
|
+
case "request":
|
|
612
|
+
return {
|
|
613
|
+
id: e.id,
|
|
614
|
+
timestamp: e.timestamp,
|
|
615
|
+
cells: {
|
|
616
|
+
time: t,
|
|
617
|
+
method: e.method,
|
|
618
|
+
url: e.url,
|
|
619
|
+
status: e.status === void 0 ? "—" : String(e.status),
|
|
620
|
+
duration: ne(e.durationMs)
|
|
621
|
+
}
|
|
622
|
+
};
|
|
623
|
+
case "route":
|
|
624
|
+
return {
|
|
625
|
+
id: e.id,
|
|
626
|
+
timestamp: e.timestamp,
|
|
627
|
+
cells: {
|
|
628
|
+
time: t,
|
|
629
|
+
from: ae(e.from),
|
|
630
|
+
to: ae(e.to),
|
|
631
|
+
navigation: e.navigation === "initial" ? "首次" : "SPA",
|
|
632
|
+
duration: ne(e.durationMs)
|
|
633
|
+
}
|
|
634
|
+
};
|
|
635
|
+
case "resource":
|
|
636
|
+
return {
|
|
637
|
+
id: e.id,
|
|
638
|
+
timestamp: e.timestamp,
|
|
639
|
+
cells: {
|
|
640
|
+
time: t,
|
|
641
|
+
url: e.url,
|
|
642
|
+
initiator: (y = e.initiatorType) != null ? y : "—",
|
|
643
|
+
status: e.status === void 0 ? "—" : String(e.status),
|
|
644
|
+
duration: e.durationMs === void 0 ? "—" : ne(e.durationMs),
|
|
645
|
+
result: e.failed ? "失败" : "成功"
|
|
646
|
+
}
|
|
647
|
+
};
|
|
648
|
+
case "event":
|
|
649
|
+
return {
|
|
650
|
+
id: e.id,
|
|
651
|
+
timestamp: e.timestamp,
|
|
652
|
+
cells: {
|
|
653
|
+
time: t,
|
|
654
|
+
kind: "事件",
|
|
655
|
+
name: e.name,
|
|
656
|
+
source: (A = e.source) != null ? A : "manual",
|
|
657
|
+
props: se(e.props)
|
|
658
|
+
}
|
|
659
|
+
};
|
|
660
|
+
case "exposure":
|
|
661
|
+
return {
|
|
662
|
+
id: e.id,
|
|
663
|
+
timestamp: e.timestamp,
|
|
664
|
+
cells: {
|
|
665
|
+
time: t,
|
|
666
|
+
kind: "曝光",
|
|
667
|
+
name: e.name,
|
|
668
|
+
source: "exposure",
|
|
669
|
+
props: se(e.props)
|
|
670
|
+
}
|
|
671
|
+
};
|
|
672
|
+
case "vital":
|
|
673
|
+
return {
|
|
674
|
+
id: e.id,
|
|
675
|
+
timestamp: e.timestamp,
|
|
676
|
+
cells: {
|
|
677
|
+
time: t,
|
|
678
|
+
kind: "Vital",
|
|
679
|
+
name: e.name,
|
|
680
|
+
source: (Y = e.rating) != null ? Y : "—",
|
|
681
|
+
props: String(e.value)
|
|
682
|
+
}
|
|
683
|
+
};
|
|
684
|
+
case "longTask":
|
|
685
|
+
return {
|
|
686
|
+
id: e.id,
|
|
687
|
+
timestamp: e.timestamp,
|
|
688
|
+
cells: {
|
|
689
|
+
time: t,
|
|
690
|
+
kind: "长任务",
|
|
691
|
+
name: (J = e.name) != null ? J : "—",
|
|
692
|
+
source: "longTask",
|
|
693
|
+
props: ne(e.durationMs)
|
|
694
|
+
}
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
function Ne(e) {
|
|
699
|
+
const t = v[e];
|
|
700
|
+
let a = 0;
|
|
701
|
+
for (const y of M.value)
|
|
702
|
+
t.includes(y.type) && (a += 1);
|
|
703
|
+
return a;
|
|
704
|
+
}
|
|
705
|
+
function Fe(e) {
|
|
706
|
+
return `perf-panel__cell--${e.key}`;
|
|
707
|
+
}
|
|
708
|
+
function Ae(e) {
|
|
709
|
+
P.value = e;
|
|
710
|
+
}
|
|
711
|
+
function Oe() {
|
|
712
|
+
L.value > 1 && (L.value -= 1);
|
|
713
|
+
}
|
|
714
|
+
function De() {
|
|
715
|
+
L.value < ee.value && (L.value += 1);
|
|
716
|
+
}
|
|
717
|
+
function Ue() {
|
|
718
|
+
V.value = "";
|
|
719
|
+
}
|
|
720
|
+
async function qe() {
|
|
721
|
+
await m();
|
|
722
|
+
}
|
|
723
|
+
async function ze() {
|
|
724
|
+
await c();
|
|
725
|
+
}
|
|
726
|
+
function Be() {
|
|
727
|
+
var e;
|
|
728
|
+
if (u.perf)
|
|
729
|
+
try {
|
|
730
|
+
(e = Z.value) == null || e.click();
|
|
731
|
+
} catch {
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
async function Ve(e) {
|
|
735
|
+
var y;
|
|
736
|
+
const t = e.target;
|
|
737
|
+
if (!(t instanceof HTMLInputElement)) return;
|
|
738
|
+
const a = (y = t.files) == null ? void 0 : y[0];
|
|
739
|
+
try {
|
|
740
|
+
t.value = "";
|
|
741
|
+
} catch {
|
|
742
|
+
}
|
|
743
|
+
a && await d(a);
|
|
744
|
+
}
|
|
745
|
+
async function He() {
|
|
746
|
+
if (u.perf) {
|
|
747
|
+
if (typeof window != "undefined") {
|
|
748
|
+
let e = !1;
|
|
749
|
+
try {
|
|
750
|
+
e = window.confirm("确定清空本地性能数据吗?");
|
|
751
|
+
} catch {
|
|
752
|
+
e = !1;
|
|
753
|
+
}
|
|
754
|
+
if (!e) return;
|
|
755
|
+
}
|
|
756
|
+
await _();
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
function Ge(e) {
|
|
760
|
+
const t = e.target;
|
|
761
|
+
t instanceof HTMLInputElement && b(t.checked);
|
|
762
|
+
}
|
|
763
|
+
function je(e) {
|
|
764
|
+
if (!e) return [...o];
|
|
765
|
+
try {
|
|
766
|
+
const t = getComputedStyle(e);
|
|
767
|
+
return s.map((a, y) => t.getPropertyValue(a).trim() || o[y] || "#8f959e");
|
|
768
|
+
} catch {
|
|
769
|
+
return [...o];
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
function Ye(e, t) {
|
|
773
|
+
return {
|
|
774
|
+
animation: !1,
|
|
775
|
+
color: je(t),
|
|
776
|
+
grid: { top: 36, right: 16, bottom: 8, left: 8, containLabel: !0 },
|
|
777
|
+
legend: { top: 0, icon: "circle", itemWidth: 8, itemHeight: 8, textStyle: { fontSize: 12 } },
|
|
778
|
+
tooltip: { trigger: "axis" },
|
|
779
|
+
xAxis: {
|
|
780
|
+
type: "category",
|
|
781
|
+
boundaryGap: !1,
|
|
782
|
+
data: e.map((a) => a.label),
|
|
783
|
+
axisLabel: { hideOverlap: !0 }
|
|
784
|
+
},
|
|
785
|
+
yAxis: {
|
|
786
|
+
type: "value",
|
|
787
|
+
minInterval: 1,
|
|
788
|
+
splitLine: { lineStyle: { type: "dashed" } }
|
|
789
|
+
},
|
|
790
|
+
series: [
|
|
791
|
+
{ name: "错误", type: "line", symbol: "circle", symbolSize: 5, data: e.map((a) => a.errors) },
|
|
792
|
+
{ name: "请求", type: "line", symbol: "circle", symbolSize: 5, data: e.map((a) => a.requests) },
|
|
793
|
+
{ name: "长任务", type: "line", symbol: "circle", symbolSize: 5, data: e.map((a) => a.longTasks) },
|
|
794
|
+
{ name: "埋点", type: "line", symbol: "circle", symbolSize: 5, data: e.map((a) => a.events) }
|
|
795
|
+
]
|
|
796
|
+
};
|
|
797
|
+
}
|
|
798
|
+
function he() {
|
|
799
|
+
if (i)
|
|
800
|
+
try {
|
|
801
|
+
i.setOption(Ye(S.value, r.value), !0), q.value = "";
|
|
802
|
+
} catch (e) {
|
|
803
|
+
q.value = `图表渲染失败:${te(e)}`;
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
function Je() {
|
|
807
|
+
if (i) return;
|
|
808
|
+
const e = r.value;
|
|
809
|
+
if (!(!e || typeof window == "undefined") && !(e.clientWidth <= 0 || e.clientHeight <= 0))
|
|
810
|
+
try {
|
|
811
|
+
i = it(e), he();
|
|
812
|
+
} catch (t) {
|
|
813
|
+
i = null, q.value = `图表初始化失败:${te(t)}`;
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
function ce() {
|
|
817
|
+
Je(), he();
|
|
818
|
+
}
|
|
819
|
+
function pe() {
|
|
820
|
+
if (r.value) {
|
|
821
|
+
if (!i) {
|
|
822
|
+
ce();
|
|
823
|
+
return;
|
|
824
|
+
}
|
|
825
|
+
try {
|
|
826
|
+
i.resize();
|
|
827
|
+
} catch (e) {
|
|
828
|
+
q.value = `图表尺寸更新失败:${te(e)}`;
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
function ke() {
|
|
833
|
+
if (h || $) return;
|
|
834
|
+
const e = r.value;
|
|
835
|
+
if (e) {
|
|
836
|
+
if (typeof ResizeObserver != "undefined")
|
|
837
|
+
try {
|
|
838
|
+
h = new ResizeObserver(() => {
|
|
839
|
+
pe();
|
|
840
|
+
}), h.observe(e);
|
|
841
|
+
return;
|
|
842
|
+
} catch {
|
|
843
|
+
h = null;
|
|
844
|
+
}
|
|
845
|
+
typeof window != "undefined" && (window.addEventListener("resize", pe), $ = !0);
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
function ge() {
|
|
849
|
+
h && (h.disconnect(), h = null), $ && typeof window != "undefined" && (window.removeEventListener("resize", pe), $ = !1);
|
|
850
|
+
}
|
|
851
|
+
function Ce() {
|
|
852
|
+
if (i) {
|
|
853
|
+
try {
|
|
854
|
+
i.dispose();
|
|
855
|
+
} catch {
|
|
856
|
+
}
|
|
857
|
+
i = null;
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
return B(P, () => {
|
|
861
|
+
L.value = 1;
|
|
862
|
+
}), B(N, () => {
|
|
863
|
+
L.value = 1;
|
|
864
|
+
}), B(ee, (e) => {
|
|
865
|
+
L.value > e && (L.value = e);
|
|
866
|
+
}), B(
|
|
867
|
+
S,
|
|
868
|
+
() => {
|
|
869
|
+
if (!r.value) {
|
|
870
|
+
Ce(), ge();
|
|
871
|
+
return;
|
|
872
|
+
}
|
|
873
|
+
ke(), ce();
|
|
874
|
+
},
|
|
875
|
+
{ flush: "post" }
|
|
876
|
+
), Ke(() => {
|
|
877
|
+
ke(), Qe().then(() => {
|
|
878
|
+
ce();
|
|
879
|
+
});
|
|
880
|
+
}), Le(() => {
|
|
881
|
+
ge(), Ce();
|
|
882
|
+
}), Ze((e) => (V.value = `面板内部错误:${te(e)}`, !1)), (e, t) => (p(), f("section", Tt, [
|
|
883
|
+
V.value ? (p(), f("div", wt, [
|
|
884
|
+
t[1] || (t[1] = l("p", { class: "perf-panel__fallback-title" }, "性能面板渲染失败", -1)),
|
|
885
|
+
l("p", Rt, w(V.value), 1),
|
|
886
|
+
l("button", {
|
|
887
|
+
class: "perf-panel__button",
|
|
888
|
+
type: "button",
|
|
889
|
+
onClick: Ue
|
|
890
|
+
}, "重试")
|
|
891
|
+
])) : (p(), f(O, { key: 1 }, [
|
|
892
|
+
l("header", St, [
|
|
893
|
+
t[3] || (t[3] = l("h2", { class: "perf-panel__title" }, "性能面板", -1)),
|
|
894
|
+
l("div", Lt, [
|
|
895
|
+
l("button", {
|
|
896
|
+
class: "perf-panel__button",
|
|
897
|
+
type: "button",
|
|
898
|
+
"data-action": "refresh",
|
|
899
|
+
disabled: D(T),
|
|
900
|
+
onClick: qe
|
|
901
|
+
}, " 刷新 ", 8, It),
|
|
902
|
+
l("button", {
|
|
903
|
+
class: "perf-panel__button",
|
|
904
|
+
type: "button",
|
|
905
|
+
"data-action": "export",
|
|
906
|
+
onClick: ze
|
|
907
|
+
}, "导出 JSON"),
|
|
908
|
+
l("button", {
|
|
909
|
+
class: "perf-panel__button",
|
|
910
|
+
type: "button",
|
|
911
|
+
"data-action": "import",
|
|
912
|
+
disabled: !n.perf,
|
|
913
|
+
onClick: Be
|
|
914
|
+
}, " 导入 JSON ", 8, $t),
|
|
915
|
+
l("button", {
|
|
916
|
+
class: "perf-panel__button perf-panel__button--danger",
|
|
917
|
+
type: "button",
|
|
918
|
+
"data-action": "clear",
|
|
919
|
+
disabled: !n.perf || D(T),
|
|
920
|
+
onClick: He
|
|
921
|
+
}, " 清空 ", 8, Mt),
|
|
922
|
+
l("label", Et, [
|
|
923
|
+
l("input", {
|
|
924
|
+
type: "checkbox",
|
|
925
|
+
"data-action": "realtime",
|
|
926
|
+
checked: D(U),
|
|
927
|
+
disabled: !n.perf,
|
|
928
|
+
onChange: Ge
|
|
929
|
+
}, null, 40, Pt),
|
|
930
|
+
t[2] || (t[2] = l("span", null, "实时", -1))
|
|
931
|
+
]),
|
|
932
|
+
l("input", {
|
|
933
|
+
ref_key: "fileInput",
|
|
934
|
+
ref: Z,
|
|
935
|
+
class: "perf-panel__file-input",
|
|
936
|
+
type: "file",
|
|
937
|
+
accept: "application/json,.json",
|
|
938
|
+
onChange: Ve
|
|
939
|
+
}, null, 544)
|
|
940
|
+
])
|
|
941
|
+
]),
|
|
942
|
+
D(T) ? (p(), f("p", xt, "正在加载数据…")) : H("", !0),
|
|
943
|
+
D(I) ? (p(), f("p", Nt, w(D(I)), 1)) : H("", !0),
|
|
944
|
+
D(T) && F.value === 0 ? (p(), f("p", Ft, "加载中…")) : F.value === 0 ? (p(), f("p", At, "暂无性能数据")) : (p(), f(O, { key: 4 }, [
|
|
945
|
+
l("section", Ot, [
|
|
946
|
+
l("div", Dt, [
|
|
947
|
+
(p(!0), f(O, null, z(E.value, (a) => (p(), f("article", {
|
|
948
|
+
key: a.key,
|
|
949
|
+
class: "perf-panel__card",
|
|
950
|
+
"data-metric": a.key
|
|
951
|
+
}, [
|
|
952
|
+
l("span", qt, w(a.label), 1),
|
|
953
|
+
l("span", zt, w(a.value), 1),
|
|
954
|
+
a.unit ? (p(), f("span", Bt, w(a.unit), 1)) : H("", !0)
|
|
955
|
+
], 8, Ut))), 128))
|
|
956
|
+
])
|
|
957
|
+
]),
|
|
958
|
+
l("section", Vt, [
|
|
959
|
+
l("div", Ht, [
|
|
960
|
+
t[4] || (t[4] = l("h3", { class: "perf-panel__section-title" }, "趋势", -1)),
|
|
961
|
+
l("span", Gt, w(D(g) === "hour" ? "按小时" : "按分钟"), 1)
|
|
962
|
+
]),
|
|
963
|
+
l("div", jt, [
|
|
964
|
+
l("div", {
|
|
965
|
+
ref_key: "chartEl",
|
|
966
|
+
ref: r,
|
|
967
|
+
class: "perf-panel__chart"
|
|
968
|
+
}, null, 512),
|
|
969
|
+
D(S).length === 0 ? (p(), f("p", Yt, "暂无趋势数据")) : H("", !0)
|
|
970
|
+
]),
|
|
971
|
+
q.value ? (p(), f("p", Jt, w(q.value), 1)) : H("", !0)
|
|
972
|
+
]),
|
|
973
|
+
l("section", Wt, [
|
|
974
|
+
t[5] || (t[5] = l("h3", { class: "perf-panel__section-title" }, "Top 排行", -1)),
|
|
975
|
+
l("div", Xt, [
|
|
976
|
+
(p(!0), f(O, null, z(oe.value, (a) => (p(), f("div", {
|
|
977
|
+
key: a.key,
|
|
978
|
+
class: "perf-panel__top"
|
|
979
|
+
}, [
|
|
980
|
+
l("h4", Kt, w(a.title), 1),
|
|
981
|
+
a.items.length > 0 ? (p(), f("ol", Qt, [
|
|
982
|
+
(p(!0), f(O, null, z(a.items, (y) => (p(), f("li", {
|
|
983
|
+
key: y.key,
|
|
984
|
+
class: "perf-panel__top-item"
|
|
985
|
+
}, [
|
|
986
|
+
l("span", {
|
|
987
|
+
class: "perf-panel__top-label",
|
|
988
|
+
title: y.label
|
|
989
|
+
}, w(y.label), 9, Zt),
|
|
990
|
+
l("span", en, w(y.count), 1)
|
|
991
|
+
]))), 128))
|
|
992
|
+
])) : (p(), f("p", tn, "暂无"))
|
|
993
|
+
]))), 128))
|
|
994
|
+
])
|
|
995
|
+
]),
|
|
996
|
+
l("section", nn, [
|
|
997
|
+
l("div", an, [
|
|
998
|
+
t[6] || (t[6] = l("h3", { class: "perf-panel__section-title" }, "明细", -1)),
|
|
999
|
+
et(l("input", {
|
|
1000
|
+
"onUpdate:modelValue": t[0] || (t[0] = (a) => N.value = a),
|
|
1001
|
+
class: "perf-panel__search",
|
|
1002
|
+
type: "search",
|
|
1003
|
+
placeholder: "搜索 URL / 消息 / 事件名",
|
|
1004
|
+
"aria-label": "搜索明细"
|
|
1005
|
+
}, null, 512), [
|
|
1006
|
+
[tt, N.value]
|
|
1007
|
+
])
|
|
1008
|
+
]),
|
|
1009
|
+
l("div", sn, [
|
|
1010
|
+
(p(), f(O, null, z(C, (a) => l("button", {
|
|
1011
|
+
key: a.tab,
|
|
1012
|
+
class: we(["perf-panel__tab", { "perf-panel__tab--active": a.tab === P.value }]),
|
|
1013
|
+
type: "button",
|
|
1014
|
+
role: "tab",
|
|
1015
|
+
"aria-selected": a.tab === P.value,
|
|
1016
|
+
"data-tab": a.tab,
|
|
1017
|
+
onClick: (y) => Ae(a.tab)
|
|
1018
|
+
}, [
|
|
1019
|
+
nt(w(a.label) + " ", 1),
|
|
1020
|
+
l("span", ln, w(Ne(a.tab)), 1)
|
|
1021
|
+
], 10, rn)), 64))
|
|
1022
|
+
]),
|
|
1023
|
+
l("div", on, [
|
|
1024
|
+
ve.value.length > 0 ? (p(), f("table", un, [
|
|
1025
|
+
l("thead", null, [
|
|
1026
|
+
l("tr", null, [
|
|
1027
|
+
(p(!0), f(O, null, z(be.value, (a) => (p(), f("th", {
|
|
1028
|
+
key: a.key,
|
|
1029
|
+
scope: "col"
|
|
1030
|
+
}, w(a.label), 1))), 128))
|
|
1031
|
+
])
|
|
1032
|
+
]),
|
|
1033
|
+
l("tbody", null, [
|
|
1034
|
+
(p(!0), f(O, null, z(ve.value, (a) => (p(), f("tr", {
|
|
1035
|
+
key: a.id
|
|
1036
|
+
}, [
|
|
1037
|
+
(p(!0), f(O, null, z(be.value, (y) => {
|
|
1038
|
+
var A;
|
|
1039
|
+
return p(), f("td", {
|
|
1040
|
+
key: y.key,
|
|
1041
|
+
class: we(Fe(y))
|
|
1042
|
+
}, w((A = a.cells[y.key]) != null ? A : ""), 3);
|
|
1043
|
+
}), 128))
|
|
1044
|
+
]))), 128))
|
|
1045
|
+
])
|
|
1046
|
+
])) : (p(), f("p", cn, "当前分类暂无数据"))
|
|
1047
|
+
]),
|
|
1048
|
+
ue.value > 0 ? (p(), f("div", pn, [
|
|
1049
|
+
l("button", {
|
|
1050
|
+
class: "perf-panel__button",
|
|
1051
|
+
type: "button",
|
|
1052
|
+
"data-action": "prev-page",
|
|
1053
|
+
disabled: L.value <= 1,
|
|
1054
|
+
onClick: Oe
|
|
1055
|
+
}, " 上一页 ", 8, fn),
|
|
1056
|
+
l("span", null, "第 " + w(L.value) + " / " + w(ee.value) + " 页,共 " + w(ue.value) + " 条", 1),
|
|
1057
|
+
l("button", {
|
|
1058
|
+
class: "perf-panel__button",
|
|
1059
|
+
type: "button",
|
|
1060
|
+
"data-action": "next-page",
|
|
1061
|
+
disabled: L.value >= ee.value,
|
|
1062
|
+
onClick: De
|
|
1063
|
+
}, " 下一页 ", 8, dn)
|
|
1064
|
+
])) : H("", !0)
|
|
1065
|
+
])
|
|
1066
|
+
], 64))
|
|
1067
|
+
], 64))
|
|
1068
|
+
]));
|
|
1069
|
+
}
|
|
1070
|
+
}), _n = (n, u) => {
|
|
1071
|
+
const o = n.__vccOpts || n;
|
|
1072
|
+
for (const [s, v] of u)
|
|
1073
|
+
o[s] = v;
|
|
1074
|
+
return o;
|
|
1075
|
+
}, gn = /* @__PURE__ */ _n(mn, [["__scopeId", "data-v-33172fbd"]]);
|
|
1076
|
+
export {
|
|
1077
|
+
gn as PerfPanel
|
|
1078
|
+
};
|
|
1079
|
+
//# sourceMappingURL=index.js.map
|