Files
douyin_guaji-main/webui/debug.html
T
Your Name 8368f1f3b7 Fix issues from code review
- Fix project root path in test_webgui.py
- Remove debug console.log from loadConfig in app.js
- Remove duplicate screenshot button event listener in app.js
- Fix redundant directory changes in startup batch script
- Add trailing newlines to files
2026-05-20 09:00:54 +08:00

69 lines
2.4 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<title>Debug WebGUI</title>
</head>
<body>
<h1>Debug WebGUI Config Loading</h1>
<div id="output"></div>
<script>
const output = document.getElementById('output');
async function apiGet(path) {
const res = await fetch(path, { cache: "no-store" });
if (!res.ok) throw new Error(await res.text());
return await res.json();
}
function getConfigBoundElements() {
return Array.from(document.querySelectorAll("[data-key]"));
}
async function testConfig() {
try {
output.innerHTML += '<p>Testing API...</p>';
const cfg = await apiGet("/api/config");
output.innerHTML += `<p>Config loaded: ${Object.keys(cfg).length} keys</p>`;
// Test getConfigBoundElements
const elements = getConfigBoundElements();
output.innerHTML += `<p>Found ${elements.length} config-bound elements</p>`;
if (elements.length > 0) {
output.innerHTML += '<p>Sample elements:</p><ul>';
for (let i = 0; i < Math.min(5, elements.length); i++) {
const el = elements[i];
output.innerHTML += `<li>${el.id || el.name || 'unnamed'}: data-key="${el.dataset.key}"</li>`;
}
output.innerHTML += '</ul>';
}
// Test DEFAULTS
const DEFAULTS = {
min_prize_value_yuan: 0,
min_participants: 0,
skip_if_countdown_lt_seconds: 15,
};
output.innerHTML += '<p>Testing applyConfigToUI logic...</p>';
for (const key of Object.keys(DEFAULTS)) {
const val = cfg ? cfg[key] : undefined;
const hasVal = !(typeof val === "undefined" || val === null);
const useVal = hasVal ? val : (Object.prototype.hasOwnProperty.call(DEFAULTS, key) ? DEFAULTS[key] : undefined);
output.innerHTML += `<p>${key}: config=${val}, hasVal=${hasVal}, useVal=${useVal}</p>`;
}
} catch (e) {
output.innerHTML += `<p>Error: ${e.message}</p>`;
console.error(e);
}
}
testConfig();
</script>
</body>
</html>