fix: rowid column shift in get_message_with_rowid; add file logging and frontend error reporting
This commit is contained in:
@@ -21,12 +21,14 @@ tauri = { version = "2", features = [] }
|
||||
tauri-plugin-opener = "2"
|
||||
tracing-subscriber.workspace = true
|
||||
tracing.workspace = true
|
||||
tracing-appender.workspace = true
|
||||
serde.workspace = true
|
||||
serde_json.workspace = true
|
||||
tokio.workspace = true
|
||||
reqwest.workspace = true
|
||||
futures.workspace = true
|
||||
uuid.workspace = true
|
||||
dirs.workspace = true
|
||||
xianren-core = { path = "../../crates/core" }
|
||||
xianren-engine = { path = "../../crates/engine" }
|
||||
xianren-download = { path = "../../crates/download" }
|
||||
|
||||
@@ -19,6 +19,7 @@ pub struct AppInfo {
|
||||
pub version: String,
|
||||
pub platform: String,
|
||||
pub models_dir: String,
|
||||
pub logs_dir: String,
|
||||
pub engine_bin: Option<String>,
|
||||
pub engine_exists: bool,
|
||||
pub db_path: String,
|
||||
@@ -133,6 +134,7 @@ pub fn app_info(state: State<'_, App>) -> AppInfo {
|
||||
version: env!("CARGO_PKG_VERSION").to_string(),
|
||||
platform: std::env::consts::OS.to_string(),
|
||||
models_dir: state.core.models_dir.to_string_lossy().to_string(),
|
||||
logs_dir: state.core.logs_dir.to_string_lossy().to_string(),
|
||||
engine_exists: engine_bin
|
||||
.as_ref()
|
||||
.is_some_and(|p| PathBuf::from(p).exists()),
|
||||
@@ -1416,3 +1418,10 @@ pub async fn server_status(state: State<'_, App>) -> Result<serde_json::Value, S
|
||||
pub fn open_path(path: String) -> Result<(), String> {
|
||||
tauri_plugin_opener::open_path(path, None::<&str>).map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
/// 前端上报运行时错误:写入本地日志便于排查。
|
||||
#[tauri::command]
|
||||
pub fn report_error(source: String, message: String) -> Result<(), String> {
|
||||
tracing::error!(source = %source, error = %message, "frontend reported error");
|
||||
Ok(())
|
||||
}
|
||||
@@ -17,11 +17,20 @@ pub struct App {
|
||||
}
|
||||
|
||||
pub fn run() {
|
||||
let data_dir = dirs::data_dir()
|
||||
.unwrap_or_else(|| PathBuf::from("."))
|
||||
.join("XianrenStudio");
|
||||
let logs_dir = data_dir.join("logs");
|
||||
let _ = std::fs::create_dir_all(&logs_dir);
|
||||
let file_appender = tracing_appender::rolling::daily(&logs_dir, "app.log");
|
||||
let (non_blocking, _guard) = tracing_appender::non_blocking(file_appender);
|
||||
tracing_subscriber::fmt()
|
||||
.with_env_filter(
|
||||
tracing_subscriber::EnvFilter::try_from_default_env()
|
||||
.unwrap_or_else(|_| "info".into()),
|
||||
)
|
||||
.with_writer(non_blocking)
|
||||
.with_ansi(false)
|
||||
.init();
|
||||
|
||||
tauri::Builder::default()
|
||||
@@ -115,6 +124,7 @@ pub fn run() {
|
||||
commands::edit_message,
|
||||
commands::list_message_versions,
|
||||
commands::apply_message_version,
|
||||
commands::report_error,
|
||||
commands::download_enqueue,
|
||||
commands::server_start,
|
||||
commands::server_stop,
|
||||
|
||||
Reference in New Issue
Block a user