From f1c32c5f99bd24526ec1329a275d6a3422c0383f Mon Sep 17 00:00:00 2001 From: Lei OT Date: Tue, 30 Dec 2025 15:24:40 +0800 Subject: [PATCH] perf: pagespy: offline? --- package.json | 2 +- src/utils/pagespy.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index fa11310..6ba57fd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@haina/npm", - "version": "0.1.0", + "version": "0.1.1", "main": "./build/cjs/index.js", "module": "./build/esm/index.js", "exports": { diff --git a/src/utils/pagespy.js b/src/utils/pagespy.js index 2b45546..1b58e09 100644 --- a/src/utils/pagespy.js +++ b/src/utils/pagespy.js @@ -2,10 +2,10 @@ import { loadScript } from './commons'; const TODAY_TIME = new Date().getTime(); -export const loadPageSpy = (title, projectName = 'hn-page-spy') => { +export const loadPageSpy = (title, projectName = 'hn-page-spy', offline = true) => { if (import.meta.env.DEV || window.$pageSpy) return; - const PageSpyConfig = { api: 'page-spy.mycht.cn', project: projectName, title: title, autoRender: false }; + const PageSpyConfig = { api: 'page-spy.mycht.cn', project: projectName, title, autoRender: false, offline }; const PageSpySrc = [ 'https://page-spy.mycht.cn/page-spy/index.min.js' + `?v=${TODAY_TIME}`, 'https://page-spy.mycht.cn/plugin/data-harbor/index.min.js' + `?v=${TODAY_TIME}`, @@ -40,7 +40,7 @@ export const loadPageSpy = (title, projectName = 'hn-page-spy') => { }); }; -export const uploadPageSpyLog = async (remark = '') => { +export const uploadPageSpyLog = async (minutes=60, remark = '') => { if (import.meta.env.DEV) return true; @@ -49,7 +49,7 @@ export const uploadPageSpyLog = async (remark = '') => { // 上传最近一小时的日志, 直接upload 所有日志: 413 Payload Too Large const now = Date.now(); await window.$harbor.uploadPeriods({ - startTime: now - 1 * 60 * 60000, + startTime: now - minutes * 60000, endTime: now, remark, });