63 lines
1.9 KiB
Bash
Executable File
63 lines
1.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
cat <<'EOF'
|
|
在 Chrome DevTools Console 粘贴执行:
|
|
|
|
(() => {
|
|
const stamp = () => new Date().toISOString();
|
|
const counts = {};
|
|
const wrap = (name) => {
|
|
const original = window[name];
|
|
if (typeof original !== "function") {
|
|
console.log(`[probe] ${name}:`, typeof original);
|
|
return;
|
|
}
|
|
counts[name] = 0;
|
|
const wrapped = function (...args) {
|
|
counts[name] += 1;
|
|
console.log(`[probe ${stamp()}] ${name} called`, args);
|
|
try {
|
|
const ret = original.apply(this, args);
|
|
console.log(`[probe ${stamp()}] ${name} returned`, ret);
|
|
return ret;
|
|
} catch (err) {
|
|
console.error(`[probe ${stamp()}] ${name} threw`, err);
|
|
throw err;
|
|
}
|
|
};
|
|
wrapped.__deployTestProbe = true;
|
|
wrapped.__deployTestOriginal = original;
|
|
window[name] = wrapped;
|
|
console.log(`[probe] ${name}: wrapped`);
|
|
};
|
|
|
|
["initSDK", "login", "commonEventFunc"].forEach(wrap);
|
|
window.addEventListener("error", (event) => {
|
|
console.error("[probe window error]", event.message, event.filename, event.lineno, event.error);
|
|
});
|
|
window.addEventListener("unhandledrejection", (event) => {
|
|
console.error("[probe unhandledrejection]", event.reason);
|
|
});
|
|
console.log("[probe ready]", {
|
|
electronAPI: Boolean(window.electronAPI),
|
|
Go: typeof Go,
|
|
initSDK: typeof window.initSDK,
|
|
login: typeof window.login,
|
|
commonEventFunc: typeof window.commonEventFunc,
|
|
openIMRenderApi: typeof window.openIMRenderApi,
|
|
});
|
|
window.__deployTestProbeCounts = counts;
|
|
clearInterval(window.__deployTestProbeTimer);
|
|
window.__deployTestProbeTimer = setInterval(() => {
|
|
console.log(`[probe ${stamp()}] counts`, { ...counts });
|
|
}, 5000);
|
|
})();
|
|
|
|
然后退出登录/刷新页面重新登录一次,观察是否打印:
|
|
- initSDK called / returned
|
|
- login called / returned
|
|
- window error / unhandledrejection
|
|
- counts 里的 initSDK/login 是否从 0 变成 1
|
|
EOF
|