mirror of
https://github.com/FranP-code/ChatGPT.git
synced 2025-10-13 00:13:25 +00:00
chore: log
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use crate::utils;
|
||||
use log::info;
|
||||
use log::error;
|
||||
use std::{fs, path::PathBuf};
|
||||
use tauri::{api, command, AppHandle, Manager};
|
||||
|
||||
@@ -58,7 +58,7 @@ pub async fn get_data(app: AppHandle, url: String, is_msg: Option<bool>) -> Opti
|
||||
utils::get_data(&url, None).await
|
||||
};
|
||||
res.unwrap_or_else(|err| {
|
||||
info!("chatgpt_client_http_error: {}", err);
|
||||
error!("chatgpt_client_http: {}", err);
|
||||
None
|
||||
})
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ use crate::{
|
||||
conf::GITHUB_PROMPTS_CSV_URL,
|
||||
utils,
|
||||
};
|
||||
use log::info;
|
||||
use log::{error, info};
|
||||
use regex::Regex;
|
||||
use std::{collections::HashMap, fs, path::PathBuf, vec};
|
||||
use tauri::{api, command, AppHandle, Manager};
|
||||
@@ -29,7 +29,7 @@ pub fn parse_prompt(data: String) -> Vec<PromptRecord> {
|
||||
let mut list = vec![];
|
||||
for result in rdr.deserialize() {
|
||||
let record: PromptRecord = result.unwrap_or_else(|err| {
|
||||
info!("parse_prompt_error: {}", err);
|
||||
error!("parse_prompt: {}", err);
|
||||
PromptRecord {
|
||||
cmd: None,
|
||||
act: "".to_string(),
|
||||
@@ -84,12 +84,12 @@ pub fn get_download_list(pathname: &str) -> (Vec<serde_json::Value>, PathBuf) {
|
||||
info!("get_download_list: {}", pathname);
|
||||
let download_path = utils::app_root().join(PathBuf::from(pathname));
|
||||
let content = fs::read_to_string(&download_path).unwrap_or_else(|err| {
|
||||
info!("download_list_error: {}", err);
|
||||
error!("download_list: {}", err);
|
||||
fs::write(&download_path, "[]").unwrap();
|
||||
"[]".to_string()
|
||||
});
|
||||
let list = serde_json::from_str::<Vec<serde_json::Value>>(&content).unwrap_or_else(|err| {
|
||||
info!("download_list_parse_error: {}", err);
|
||||
error!("download_list_parse: {}", err);
|
||||
vec![]
|
||||
});
|
||||
|
||||
@@ -249,13 +249,12 @@ pub async fn sync_prompts(app: AppHandle, time: u64) -> Option<Vec<ModelRecord>>
|
||||
|
||||
#[command]
|
||||
pub async fn sync_user_prompts(url: String, data_type: String) -> Option<Vec<ModelRecord>> {
|
||||
info!("sync_user_prompts: url => {}", url);
|
||||
let res = utils::get_data(&url, None).await.unwrap_or_else(|err| {
|
||||
info!("chatgpt_http_error: {}", err);
|
||||
error!("chatgpt_http: {}", err);
|
||||
None
|
||||
});
|
||||
|
||||
info!("chatgpt_http_url: {}", url);
|
||||
|
||||
if let Some(v) = res {
|
||||
let data;
|
||||
if data_type == "csv" {
|
||||
@@ -264,11 +263,11 @@ pub async fn sync_user_prompts(url: String, data_type: String) -> Option<Vec<Mod
|
||||
} else if data_type == "json" {
|
||||
info!("chatgpt_http_json_parse");
|
||||
data = serde_json::from_str(&v).unwrap_or_else(|err| {
|
||||
info!("chatgpt_http_json_parse_error: {}", err);
|
||||
error!("chatgpt_http_json_parse: {}", err);
|
||||
vec![]
|
||||
});
|
||||
} else {
|
||||
info!("chatgpt_http_unknown_type");
|
||||
error!("chatgpt_http_unknown_type");
|
||||
data = vec![];
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ pub fn init() -> Menu {
|
||||
|
||||
let update_prompt = CustomMenuItem::new("update_prompt".to_string(), "Prompt");
|
||||
let update_silent = CustomMenuItem::new("update_silent".to_string(), "Silent");
|
||||
let _update_disable = CustomMenuItem::new("update_disable".to_string(), "Disable");
|
||||
// let _update_disable = CustomMenuItem::new("update_disable".to_string(), "Disable");
|
||||
|
||||
let popup_search = CustomMenuItem::new("popup_search".to_string(), "Pop-up Search");
|
||||
let popup_search_menu = if app_conf.popup_search {
|
||||
@@ -74,6 +74,7 @@ pub fn init() -> Menu {
|
||||
system_tray
|
||||
};
|
||||
|
||||
let auto_update = app_conf.get_auto_update();
|
||||
let preferences_menu = Submenu::new(
|
||||
"Preferences",
|
||||
Menu::with_items([
|
||||
@@ -114,16 +115,16 @@ pub fn init() -> Menu {
|
||||
Submenu::new(
|
||||
"Auto Update",
|
||||
Menu::new()
|
||||
.add_item(if app_conf.auto_update == "Prompt" {
|
||||
.add_item(if auto_update == "prompt" {
|
||||
update_prompt.selected()
|
||||
} else {
|
||||
update_prompt
|
||||
})
|
||||
.add_item(if app_conf.auto_update == "Silent" {
|
||||
.add_item(if auto_update == "silent" {
|
||||
update_silent.selected()
|
||||
} else {
|
||||
update_silent
|
||||
}), // .add_item(if app_conf.auto_update == "Disable" {
|
||||
}), // .add_item(if auto_update == "disable" {
|
||||
// update_disable.selected()
|
||||
// } else {
|
||||
// update_disable
|
||||
@@ -321,21 +322,21 @@ pub fn menu_handler(event: WindowMenuEvent<tauri::Wry>) {
|
||||
.get_item("update_silent")
|
||||
.set_selected(true)
|
||||
.unwrap();
|
||||
"Silent"
|
||||
"silent"
|
||||
}
|
||||
"update_disable" => {
|
||||
menu_handle
|
||||
.get_item("update_disable")
|
||||
.set_selected(true)
|
||||
.unwrap();
|
||||
"Disable"
|
||||
"disable"
|
||||
}
|
||||
_ => {
|
||||
menu_handle
|
||||
.get_item("update_prompt")
|
||||
.set_selected(true)
|
||||
.unwrap();
|
||||
"Prompt"
|
||||
"prompt"
|
||||
}
|
||||
};
|
||||
AppConf::read()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::{app::window, conf::AppConf, utils};
|
||||
use log::info;
|
||||
use log::{error, info};
|
||||
use tauri::{utils::config::WindowUrl, window::WindowBuilder, App, GlobalShortcutManager, Manager};
|
||||
use wry::application::accelerator::Accelerator;
|
||||
|
||||
@@ -33,11 +33,11 @@ pub fn init(app: &mut App) -> std::result::Result<(), Box<dyn std::error::Error>
|
||||
}
|
||||
})
|
||||
.unwrap_or_else(|err| {
|
||||
info!("global_shortcut_register_error: {}", err);
|
||||
error!("global_shortcut_register_error: {}", err);
|
||||
});
|
||||
}
|
||||
Err(err) => {
|
||||
info!("global_shortcut_parse_error: {}", err);
|
||||
error!("global_shortcut_parse_error: {}", err);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -93,10 +93,11 @@ pub fn init(app: &mut App) -> std::result::Result<(), Box<dyn std::error::Error>
|
||||
}
|
||||
|
||||
// auto_update
|
||||
if app_conf.auto_update != "Disable" {
|
||||
info!("stepup::run_check_update");
|
||||
let auto_update = app_conf.get_auto_update();
|
||||
if auto_update != "disable" {
|
||||
info!("run_check_update");
|
||||
let app = app.handle();
|
||||
utils::run_check_update(app, app_conf.auto_update == "Silent", None);
|
||||
utils::run_check_update(app, auto_update == "silent", None);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user