import { defineComponent, ref, computed, useSSRContext } from 'vue'; import { ssrRenderAttrs, ssrRenderList, ssrRenderAttr, ssrIncludeBooleanAttr, ssrLooseContain, ssrLooseEqual, ssrInterpolate, ssrRenderStyle, ssrRenderClass } from 'vue/server-renderer'; import { u as useApi } from './useApi-B-E5eLsI.mjs'; import { u as useToast } from './useToast-CS21XT61.mjs'; import { _ as _export_sfc } from './server.mjs'; import './useLoading-D4zrSa2m.mjs'; import '../nitro/nitro.mjs'; import 'node:http'; import 'node:https'; import 'node:events'; import 'node:buffer'; import 'node:fs'; import 'node:path'; import 'node:crypto'; import 'node:url'; import '../routes/renderer.mjs'; import 'vue-bundle-renderer/runtime'; import 'unhead/server'; import 'devalue'; import 'unhead/utils'; import 'pinia'; import 'perfect-debounce'; const _sfc_main = /* @__PURE__ */ defineComponent({ __name: "statlog", __ssrInlineRender: true, setup(__props) { useApi(); useToast(); const REGION_NAMES = { cn: "中国", us: "美国", ea: "东亚", sea: "东南亚", sa: "南亚", me: "中东", eu: "欧洲", ru: "俄罗斯", af: "非洲", sam: "南美", nam: "北美", oc: "大洋洲", br: "巴西", in: "印度" }; function regionName(c) { return c ? REGION_NAMES[c] || c : "-"; } const all = ref([]); const loading = ref(false); const loadError = ref(""); const statTotal = ref("-"); const statLast = ref("-"); const statTip = ref(""); const fDay = ref(0); const fLevel = ref(""); const fKw = ref(""); const fAuto = ref(false); function shYmd(offsetDays = 0) { const d = new Date(Date.now() + offsetDays * 864e5); const s = new Intl.DateTimeFormat("en-CA", { timeZone: "Asia/Shanghai", year: "numeric", month: "2-digit", day: "2-digit" }).format(d); return parseInt(s.replace(/-/g, ""), 10); } function fmtDay(yyyymmdd) { const s = "" + yyyymmdd; return s.length === 8 ? s.slice(0, 4) + "-" + s.slice(4, 6) + "-" + s.slice(6, 8) : s; } function fmtTime(ts) { if (!ts) return "--"; const d = new Date(ts * 1e3); const p = (n) => n < 10 ? "0" + n : "" + n; return p(d.getHours()) + ":" + p(d.getMinutes()) + ":" + p(d.getSeconds()); } function fmtProduct(pid) { return pid ? "0x" + (pid >>> 0).toString(16).toUpperCase() : "全部"; } const dayOptions = computed(() => [ { value: shYmd(0), label: "今天 " + fmtDay(shYmd(0)) }, { value: shYmd(-1), label: "昨天 " + fmtDay(shYmd(-1)) } ]); function levelInfo(level) { if (level === "error") return { cls: "lv-error", txt: "解析失败" }; if (level === "warn") return { cls: "lv-warn", txt: "未落库" }; return { cls: "lv-info", txt: "已落库" }; } function isLate(e) { return !!(e.snap_ts && e.ts && e.ts - e.snap_ts > 120); } const filteredRows = computed(() => { const level = fLevel.value; const kw = fKw.value.trim().toLowerCase(); return all.value.filter((e) => { if (level && e.level !== level) return false; if (kw) { const hay = ((e.app || "") + " " + (e.region || "") + " " + regionName(e.region) + " " + (e.product_id || "") + " " + fmtProduct(e.product_id) + " " + (e.stat_day || "")).toLowerCase(); if (hay.indexOf(kw) < 0) return false; } return true; }); }); return (_ctx, _push, _parent, _attrs) => { _push(`

统计日志

console 从 NATS 收到的「当日统计快照」接收流水(最新在前,按接收时间分天存 Redis)。各业务部署每个同步周期/启动时/0点 推送一次当日绝对快照,console 收到后覆盖落库。用于核对每个部署是否在正常汇报;带 未注册 的应用快照已收到但不会落库(应用名需与 console 注册表完全一致)。

该日保留 ${ssrInterpolate(statTotal.value)} 条当前显示 ${ssrInterpolate(filteredRows.value.length)} 条最近接收 ${ssrInterpolate(statLast.value)}${ssrInterpolate(statTip.value)}
接收时间
级别
应用 · 区域 · 产品
统计日
指标摘要 / 说明
快照时间
`); if (loading.value) { _push(`
加载中...
`); } else if (loadError.value) { _push(`
加载失败:${ssrInterpolate(loadError.value)}
`); } else if (!filteredRows.value.length) { _push(`
${ssrInterpolate(all.value.length ? "无匹配记录" : "该日暂无接收记录")}
`); } else { _push(``); ssrRenderList(filteredRows.value, (e, i) => { _push(`
${ssrInterpolate(fmtTime(e.ts))}
${ssrInterpolate(levelInfo(e.level).txt)}
`); if (e.app) { _push(`${ssrInterpolate(e.app)}`); if (!e.registered) { _push(`未注册`); } else { _push(``); } _push(``); } else { _push(`(无应用名)`); } _push(` · ${ssrInterpolate(regionName(e.region))} · ${ssrInterpolate(fmtProduct(e.product_id))}
${ssrInterpolate(e.stat_day ? fmtDay(e.stat_day) : "-")}
`); if (e.msg) { _push(`${ssrInterpolate(e.msg)}`); if (e.summary) { _push(` · ${ssrInterpolate(e.summary)}`); } else { _push(``); } _push(``); } else { _push(`${ssrInterpolate(e.summary || "无增量")}`); } _push(`
${ssrInterpolate(fmtTime(e.snap_ts))}`); if (isLate(e)) { _push(`迟到${ssrInterpolate(e.ts - e.snap_ts)}s`); } else { _push(``); } _push(`
`); }); _push(``); } _push(`
`); }; } }); const _sfc_setup = _sfc_main.setup; _sfc_main.setup = (props, ctx) => { const ssrContext = useSSRContext(); (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("pages/statlog.vue"); return _sfc_setup ? _sfc_setup(props, ctx) : void 0; }; const statlog = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-742ee359"]]); export { statlog as default }; //# sourceMappingURL=statlog-5z1Dy_jV.mjs.map