All checks were successful
Docker Build and Push / build-image (push) Successful in 2m45s
21 lines
1023 B
JavaScript
21 lines
1023 B
JavaScript
// 仅在 Tauri WebView 内启用 PageSpy, 用于生产环境远程调试.
|
|
// web 模式 (Vite dev / 浏览器) 通过检测 window.__TAURI_INTERNALS__ 直接跳过,
|
|
// 配合 dynamic import 让 page-spy 这个 chunk 在 web 模式下完全不下载.
|
|
// VITE_PAGESPY_API 留空可关闭连接 (例如本地调试不想连远端 PageSpy 服务时).
|
|
// 加载失败不阻塞应用启动, 仅 console.warn 提示.
|
|
|
|
const PAGESPY_API = import.meta.env.VITE_PAGESPY_API || 'http://bh.vps.honor3.com:6752'
|
|
const inTauri = typeof window !== 'undefined' && '__TAURI_INTERNALS__' in window
|
|
|
|
if (inTauri && PAGESPY_API) {
|
|
// 动态 import: 仅在 Tauri 内才下载 page-spy chunk
|
|
import('@huolala-tech/page-spy')
|
|
.then(({ default: PageSpy }) => {
|
|
// PageSpy 默认会 hook fetch / XMLHttpRequest, 自动抓取网络请求和错误
|
|
const instance = new PageSpy({ api: PAGESPY_API })
|
|
window.__IBOARD_PAGESPY__ = instance
|
|
})
|
|
.catch((err) => {
|
|
console.warn('[PageSpy] init failed:', err)
|
|
})
|
|
} |