mirror of
https://gitlab.com/vyla-entertainment/home.git
synced 2026-11-12 21:27:22 -05:00
added debug text
This commit is contained in:
@@ -7,26 +7,19 @@ use tauri::{Emitter, Manager, State, WebviewUrl, WebviewWindowBuilder};
|
||||
|
||||
fn debug_log(msg: &str) {
|
||||
let log_dir = if let Ok(app_data) = std::env::var("APPDATA") {
|
||||
std::path::PathBuf::from(app_data)
|
||||
.join("vyla-home")
|
||||
.join("vyla-home-files")
|
||||
.join("logs")
|
||||
std::path::PathBuf::from(app_data).join("vyla-home").join("vyla-home-files").join("logs")
|
||||
} else if let Ok(home) = std::env::var("HOME") {
|
||||
std::path::PathBuf::from(home).join("Library").join("Logs").join("VylaHome")
|
||||
} else if let Ok(user_profile) = std::env::var("USERPROFILE") {
|
||||
std::path::PathBuf::from(user_profile)
|
||||
.join(".vyla-home")
|
||||
.join("logs")
|
||||
std::path::PathBuf::from(user_profile).join(".vyla-home").join("logs")
|
||||
} else {
|
||||
std::path::PathBuf::from("logs")
|
||||
std::env::temp_dir().join("vyla-home-logs")
|
||||
};
|
||||
|
||||
let _ = std::fs::create_dir_all(&log_dir);
|
||||
let log_path = log_dir.join("rust-debug.log");
|
||||
|
||||
if let Ok(mut file) = std::fs::OpenOptions::new()
|
||||
.create(true)
|
||||
.append(true)
|
||||
.open(&log_path)
|
||||
{
|
||||
if let Ok(mut file) = std::fs::OpenOptions::new().create(true).append(true).open(&log_path) {
|
||||
use std::io::Write;
|
||||
let _ = writeln!(file, "[RUST] {}", msg);
|
||||
}
|
||||
@@ -652,11 +645,15 @@ fn main() {
|
||||
child.id()
|
||||
));
|
||||
if let Some(stderr) = child.stderr.take() {
|
||||
let w = window.clone();
|
||||
std::thread::spawn(move || {
|
||||
use std::io::{BufRead, BufReader};
|
||||
let reader = BufReader::new(stderr);
|
||||
for line in reader.lines().flatten() {
|
||||
debug_log(&format!("[NODE STDERR] {}", line));
|
||||
if line.contains("Error") || line.contains("Exception") || line.contains("MODULE_NOT_FOUND") {
|
||||
let _ = w.emit("error", serde_json::json!({ "message": format!("Backend failed: {}", line) }));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -195,6 +195,9 @@
|
||||
<div class="loader-container">
|
||||
<div class="loader-card">
|
||||
<div class="status-text" id="status-message">Starting runtime engine...</div>
|
||||
<div id="debug-log-box"
|
||||
style="display: none; width: 100%; max-height: 180px; overflow-y: auto; background: rgba(255, 50, 50, 0.12); border: 1px solid rgba(255, 100, 100, 0.3); border-radius: 8px; padding: 12px; font-family: monospace; font-size: 12px; color: #fca5a5; text-align: left; white-space: pre-wrap; word-break: break-all; margin-bottom: 20px; user-select: text;">
|
||||
</div>
|
||||
<div class="progress-track" id="progress-track" style="display: none;">
|
||||
<div class="progress-fill" id="progress-fill"></div>
|
||||
</div>
|
||||
@@ -257,7 +260,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="module">
|
||||
@@ -500,6 +503,7 @@ void main() {
|
||||
|
||||
<script>
|
||||
const statusEl = document.getElementById("status-message");
|
||||
const debugBox = document.getElementById("debug-log-box");
|
||||
const progressTrack = document.getElementById("progress-track");
|
||||
const progressFill = document.getElementById("progress-fill");
|
||||
const actionsEl = document.getElementById("update-actions");
|
||||
@@ -524,6 +528,12 @@ void main() {
|
||||
});
|
||||
}
|
||||
|
||||
function showDebug(msg) {
|
||||
if (!debugBox) return;
|
||||
debugBox.style.display = "block";
|
||||
debugBox.textContent = msg;
|
||||
}
|
||||
|
||||
async function initTauriEvents() {
|
||||
const eventApi = window.__TAURI__?.event || window.__TAURI_INTERNALS__;
|
||||
if (!eventApi || typeof eventApi.listen !== 'function') {
|
||||
@@ -567,23 +577,15 @@ void main() {
|
||||
});
|
||||
|
||||
eventApi.listen("error", (e) => {
|
||||
setStatus("Cleaning up background processes...", "#fca5a5");
|
||||
try {
|
||||
const core = window.__TAURI__?.core;
|
||||
if (core) {
|
||||
core.invoke("kill_orphans").finally(() => {
|
||||
setTimeout(() => {
|
||||
core.invoke("win_close").catch(() => {});
|
||||
}, 500);
|
||||
});
|
||||
}
|
||||
} catch (err) { }
|
||||
const data = e.payload || e;
|
||||
const msg = data && data.message ? data.message : JSON.stringify(data);
|
||||
setStatus("Runtime Error", "#fca5a5");
|
||||
showDebug(msg);
|
||||
});
|
||||
}
|
||||
|
||||
btnYes.addEventListener("click", () => {
|
||||
|
||||
if (actionsEl) actionsEl.style.display = "none";
|
||||
if (actionsEl) actionsEl.style.display = "none";
|
||||
setStatus("Starting update installation...");
|
||||
fetch("http://127.0.0.1:4891/update/yes", { method: "POST" }).catch(() => { });
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user