mirror of
https://github.com/FranP-code/ChatGPT.git
synced 2025-10-13 00:13:25 +00:00
chore: fmt
This commit is contained in:
@@ -1,4 +1,14 @@
|
|||||||
edition = "2021"
|
max_width = 100
|
||||||
max_width = 120
|
hard_tabs = false
|
||||||
tab_spaces = 2
|
tab_spaces = 2
|
||||||
newline_style = "Auto"
|
newline_style = "Auto"
|
||||||
|
use_small_heuristics = "Default"
|
||||||
|
reorder_imports = true
|
||||||
|
reorder_modules = true
|
||||||
|
remove_nested_parens = true
|
||||||
|
edition = "2021"
|
||||||
|
merge_derives = true
|
||||||
|
use_try_shorthand = false
|
||||||
|
use_field_init_shorthand = false
|
||||||
|
force_explicit_abi = true
|
||||||
|
# imports_granularity = "Crate"
|
||||||
@@ -267,7 +267,9 @@ pub fn download_list(pathname: &str, dir: &str, filename: Option<String>, id: Op
|
|||||||
|
|
||||||
#[command]
|
#[command]
|
||||||
pub async fn sync_prompts(app: AppHandle, time: u64) -> Option<Vec<ModelRecord>> {
|
pub async fn sync_prompts(app: AppHandle, time: u64) -> Option<Vec<ModelRecord>> {
|
||||||
let res = utils::get_data(GITHUB_PROMPTS_CSV_URL, Some(&app)).await.unwrap();
|
let res = utils::get_data(GITHUB_PROMPTS_CSV_URL, Some(&app))
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
if let Some(v) = res {
|
if let Some(v) = res {
|
||||||
let data = parse_prompt(v)
|
let data = parse_prompt(v)
|
||||||
@@ -289,7 +291,9 @@ pub async fn sync_prompts(app: AppHandle, time: u64) -> Option<Vec<ModelRecord>>
|
|||||||
|
|
||||||
let model = utils::chat_root().join("chat.model.json");
|
let model = utils::chat_root().join("chat.model.json");
|
||||||
let model_cmd = utils::chat_root().join("chat.model.cmd.json");
|
let model_cmd = utils::chat_root().join("chat.model.cmd.json");
|
||||||
let chatgpt_prompts = utils::chat_root().join("cache_model").join("chatgpt_prompts.json");
|
let chatgpt_prompts = utils::chat_root()
|
||||||
|
.join("cache_model")
|
||||||
|
.join("chatgpt_prompts.json");
|
||||||
|
|
||||||
if !utils::exists(&model) {
|
if !utils::exists(&model) {
|
||||||
fs::write(
|
fs::write(
|
||||||
@@ -304,7 +308,11 @@ pub async fn sync_prompts(app: AppHandle, time: u64) -> Option<Vec<ModelRecord>>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// chatgpt_prompts.json
|
// chatgpt_prompts.json
|
||||||
fs::write(chatgpt_prompts, serde_json::to_string_pretty(&data).unwrap()).unwrap();
|
fs::write(
|
||||||
|
chatgpt_prompts,
|
||||||
|
serde_json::to_string_pretty(&data).unwrap(),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
let cmd_data = cmd_list();
|
let cmd_data = cmd_list();
|
||||||
|
|
||||||
// chat.model.cmd.json
|
// chat.model.cmd.json
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ use crate::{
|
|||||||
utils,
|
utils,
|
||||||
};
|
};
|
||||||
use tauri::{
|
use tauri::{
|
||||||
AppHandle, CustomMenuItem, Manager, Menu, MenuItem, Submenu, SystemTray, SystemTrayEvent, SystemTrayMenu,
|
AppHandle, CustomMenuItem, Manager, Menu, MenuItem, Submenu, SystemTray, SystemTrayEvent,
|
||||||
SystemTrayMenuItem, WindowMenuEvent,
|
SystemTrayMenu, SystemTrayMenuItem, WindowMenuEvent,
|
||||||
};
|
};
|
||||||
use tauri_plugin_positioner::{on_tray_event, Position, WindowExt};
|
use tauri_plugin_positioner::{on_tray_event, Position, WindowExt};
|
||||||
|
|
||||||
@@ -33,7 +33,8 @@ pub fn init() -> Menu {
|
|||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
|
|
||||||
let stay_on_top = CustomMenuItem::new("stay_on_top".to_string(), "Stay On Top").accelerator("CmdOrCtrl+T");
|
let stay_on_top =
|
||||||
|
CustomMenuItem::new("stay_on_top".to_string(), "Stay On Top").accelerator("CmdOrCtrl+T");
|
||||||
let stay_on_top_menu = if chat_conf.stay_on_top {
|
let stay_on_top_menu = if chat_conf.stay_on_top {
|
||||||
stay_on_top.selected()
|
stay_on_top.selected()
|
||||||
} else {
|
} else {
|
||||||
@@ -98,7 +99,11 @@ pub fn init() -> Menu {
|
|||||||
} else {
|
} else {
|
||||||
theme_light.selected()
|
theme_light.selected()
|
||||||
})
|
})
|
||||||
.add_item(if is_dark { theme_dark.selected() } else { theme_dark })
|
.add_item(if is_dark {
|
||||||
|
theme_dark.selected()
|
||||||
|
} else {
|
||||||
|
theme_dark
|
||||||
|
})
|
||||||
.add_item(if is_system {
|
.add_item(if is_system {
|
||||||
theme_system.selected()
|
theme_system.selected()
|
||||||
} else {
|
} else {
|
||||||
@@ -162,13 +167,21 @@ pub fn init() -> Menu {
|
|||||||
"View",
|
"View",
|
||||||
Menu::new()
|
Menu::new()
|
||||||
.add_item(CustomMenuItem::new("go_back".to_string(), "Go Back").accelerator("CmdOrCtrl+Left"))
|
.add_item(CustomMenuItem::new("go_back".to_string(), "Go Back").accelerator("CmdOrCtrl+Left"))
|
||||||
.add_item(CustomMenuItem::new("go_forward".to_string(), "Go Forward").accelerator("CmdOrCtrl+Right"))
|
|
||||||
.add_item(CustomMenuItem::new("scroll_top".to_string(), "Scroll to Top of Screen").accelerator("CmdOrCtrl+Up"))
|
|
||||||
.add_item(
|
.add_item(
|
||||||
CustomMenuItem::new("scroll_bottom".to_string(), "Scroll to Bottom of Screen").accelerator("CmdOrCtrl+Down"),
|
CustomMenuItem::new("go_forward".to_string(), "Go Forward").accelerator("CmdOrCtrl+Right"),
|
||||||
|
)
|
||||||
|
.add_item(
|
||||||
|
CustomMenuItem::new("scroll_top".to_string(), "Scroll to Top of Screen")
|
||||||
|
.accelerator("CmdOrCtrl+Up"),
|
||||||
|
)
|
||||||
|
.add_item(
|
||||||
|
CustomMenuItem::new("scroll_bottom".to_string(), "Scroll to Bottom of Screen")
|
||||||
|
.accelerator("CmdOrCtrl+Down"),
|
||||||
)
|
)
|
||||||
.add_native_item(MenuItem::Separator)
|
.add_native_item(MenuItem::Separator)
|
||||||
.add_item(CustomMenuItem::new("reload".to_string(), "Refresh the Screen").accelerator("CmdOrCtrl+R")),
|
.add_item(
|
||||||
|
CustomMenuItem::new("reload".to_string(), "Refresh the Screen").accelerator("CmdOrCtrl+R"),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
let window_menu = Submenu::new(
|
let window_menu = Submenu::new(
|
||||||
@@ -183,11 +196,15 @@ pub fn init() -> Menu {
|
|||||||
let help_menu = Submenu::new(
|
let help_menu = Submenu::new(
|
||||||
"Help",
|
"Help",
|
||||||
Menu::new()
|
Menu::new()
|
||||||
.add_item(CustomMenuItem::new("chatgpt_log".to_string(), "ChatGPT Log"))
|
.add_item(CustomMenuItem::new(
|
||||||
|
"chatgpt_log".to_string(),
|
||||||
|
"ChatGPT Log",
|
||||||
|
))
|
||||||
.add_item(CustomMenuItem::new("update_log".to_string(), "Update Log"))
|
.add_item(CustomMenuItem::new("update_log".to_string(), "Update Log"))
|
||||||
.add_item(CustomMenuItem::new("report_bug".to_string(), "Report Bug"))
|
.add_item(CustomMenuItem::new("report_bug".to_string(), "Report Bug"))
|
||||||
.add_item(
|
.add_item(
|
||||||
CustomMenuItem::new("dev_tools".to_string(), "Toggle Developer Tools").accelerator("CmdOrCtrl+Shift+I"),
|
CustomMenuItem::new("dev_tools".to_string(), "Toggle Developer Tools")
|
||||||
|
.accelerator("CmdOrCtrl+Shift+I"),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -232,7 +249,10 @@ pub fn menu_handler(event: WindowMenuEvent<tauri::Wry>) {
|
|||||||
"popup_search" => {
|
"popup_search" => {
|
||||||
let chat_conf = conf::ChatConfJson::get_chat_conf();
|
let chat_conf = conf::ChatConfJson::get_chat_conf();
|
||||||
let popup_search = !chat_conf.popup_search;
|
let popup_search = !chat_conf.popup_search;
|
||||||
menu_handle.get_item(menu_id).set_selected(popup_search).unwrap();
|
menu_handle
|
||||||
|
.get_item(menu_id)
|
||||||
|
.set_selected(popup_search)
|
||||||
|
.unwrap();
|
||||||
ChatConfJson::amend(&serde_json::json!({ "popup_search": popup_search }), None).unwrap();
|
ChatConfJson::amend(&serde_json::json!({ "popup_search": popup_search }), None).unwrap();
|
||||||
cmd::window_reload(app.clone(), "core");
|
cmd::window_reload(app.clone(), "core");
|
||||||
cmd::window_reload(app, "tray");
|
cmd::window_reload(app, "tray");
|
||||||
@@ -253,10 +273,16 @@ pub fn menu_handler(event: WindowMenuEvent<tauri::Wry>) {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
"hide_dock_icon" => ChatConfJson::amend(&serde_json::json!({ "hide_dock_icon": true }), Some(app)).unwrap(),
|
"hide_dock_icon" => {
|
||||||
|
ChatConfJson::amend(&serde_json::json!({ "hide_dock_icon": true }), Some(app)).unwrap()
|
||||||
|
}
|
||||||
"titlebar" => {
|
"titlebar" => {
|
||||||
let chat_conf = conf::ChatConfJson::get_chat_conf();
|
let chat_conf = conf::ChatConfJson::get_chat_conf();
|
||||||
ChatConfJson::amend(&serde_json::json!({ "titlebar": !chat_conf.titlebar }), None).unwrap();
|
ChatConfJson::amend(
|
||||||
|
&serde_json::json!({ "titlebar": !chat_conf.titlebar }),
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
tauri::api::process::restart(&app.env());
|
tauri::api::process::restart(&app.env());
|
||||||
}
|
}
|
||||||
"system_tray" => {
|
"system_tray" => {
|
||||||
@@ -279,15 +305,24 @@ pub fn menu_handler(event: WindowMenuEvent<tauri::Wry>) {
|
|||||||
}
|
}
|
||||||
let auto_update = match menu_id {
|
let auto_update = match menu_id {
|
||||||
"update_silent" => {
|
"update_silent" => {
|
||||||
menu_handle.get_item("update_silent").set_selected(true).unwrap();
|
menu_handle
|
||||||
|
.get_item("update_silent")
|
||||||
|
.set_selected(true)
|
||||||
|
.unwrap();
|
||||||
"Silent"
|
"Silent"
|
||||||
}
|
}
|
||||||
"update_disable" => {
|
"update_disable" => {
|
||||||
menu_handle.get_item("update_disable").set_selected(true).unwrap();
|
menu_handle
|
||||||
|
.get_item("update_disable")
|
||||||
|
.set_selected(true)
|
||||||
|
.unwrap();
|
||||||
"Disable"
|
"Disable"
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
menu_handle.get_item("update_prompt").set_selected(true).unwrap();
|
menu_handle
|
||||||
|
.get_item("update_prompt")
|
||||||
|
.set_selected(true)
|
||||||
|
.unwrap();
|
||||||
"Prompt"
|
"Prompt"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -296,7 +331,10 @@ pub fn menu_handler(event: WindowMenuEvent<tauri::Wry>) {
|
|||||||
"stay_on_top" => {
|
"stay_on_top" => {
|
||||||
let chat_conf = conf::ChatConfJson::get_chat_conf();
|
let chat_conf = conf::ChatConfJson::get_chat_conf();
|
||||||
let stay_on_top = !chat_conf.stay_on_top;
|
let stay_on_top = !chat_conf.stay_on_top;
|
||||||
menu_handle.get_item(menu_id).set_selected(stay_on_top).unwrap();
|
menu_handle
|
||||||
|
.get_item(menu_id)
|
||||||
|
.set_selected(stay_on_top)
|
||||||
|
.unwrap();
|
||||||
win.set_always_on_top(stay_on_top).unwrap();
|
win.set_always_on_top(stay_on_top).unwrap();
|
||||||
ChatConfJson::amend(&serde_json::json!({ "stay_on_top": stay_on_top }), None).unwrap();
|
ChatConfJson::amend(&serde_json::json!({ "stay_on_top": stay_on_top }), None).unwrap();
|
||||||
}
|
}
|
||||||
@@ -341,10 +379,19 @@ pub fn tray_menu() -> SystemTray {
|
|||||||
if cfg!(target_os = "macos") {
|
if cfg!(target_os = "macos") {
|
||||||
SystemTray::new().with_menu(
|
SystemTray::new().with_menu(
|
||||||
SystemTrayMenu::new()
|
SystemTrayMenu::new()
|
||||||
.add_item(CustomMenuItem::new("control_center".to_string(), "Control Center"))
|
.add_item(CustomMenuItem::new(
|
||||||
|
"control_center".to_string(),
|
||||||
|
"Control Center",
|
||||||
|
))
|
||||||
.add_native_item(SystemTrayMenuItem::Separator)
|
.add_native_item(SystemTrayMenuItem::Separator)
|
||||||
.add_item(CustomMenuItem::new("show_dock_icon".to_string(), "Show Dock Icon"))
|
.add_item(CustomMenuItem::new(
|
||||||
.add_item(CustomMenuItem::new("hide_dock_icon".to_string(), "Hide Dock Icon"))
|
"show_dock_icon".to_string(),
|
||||||
|
"Show Dock Icon",
|
||||||
|
))
|
||||||
|
.add_item(CustomMenuItem::new(
|
||||||
|
"hide_dock_icon".to_string(),
|
||||||
|
"Hide Dock Icon",
|
||||||
|
))
|
||||||
.add_item(CustomMenuItem::new("show_core".to_string(), "Show ChatGPT"))
|
.add_item(CustomMenuItem::new("show_core".to_string(), "Show ChatGPT"))
|
||||||
.add_native_item(SystemTrayMenuItem::Separator)
|
.add_native_item(SystemTrayMenuItem::Separator)
|
||||||
.add_item(CustomMenuItem::new("quit".to_string(), "Quit ChatGPT")),
|
.add_item(CustomMenuItem::new("quit".to_string(), "Quit ChatGPT")),
|
||||||
@@ -352,7 +399,10 @@ pub fn tray_menu() -> SystemTray {
|
|||||||
} else {
|
} else {
|
||||||
SystemTray::new().with_menu(
|
SystemTray::new().with_menu(
|
||||||
SystemTrayMenu::new()
|
SystemTrayMenu::new()
|
||||||
.add_item(CustomMenuItem::new("control_center".to_string(), "Control Center"))
|
.add_item(CustomMenuItem::new(
|
||||||
|
"control_center".to_string(),
|
||||||
|
"Control Center",
|
||||||
|
))
|
||||||
.add_item(CustomMenuItem::new("show_core".to_string(), "Show ChatGPT"))
|
.add_item(CustomMenuItem::new("show_core".to_string(), "Show ChatGPT"))
|
||||||
.add_native_item(SystemTrayMenuItem::Separator)
|
.add_native_item(SystemTrayMenuItem::Separator)
|
||||||
.add_item(CustomMenuItem::new("quit".to_string(), "Quit ChatGPT")),
|
.add_item(CustomMenuItem::new("quit".to_string(), "Quit ChatGPT")),
|
||||||
|
|||||||
@@ -31,7 +31,12 @@ pub fn tray_window(handle: &tauri::AppHandle) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dalle2_window(handle: &tauri::AppHandle, query: Option<String>, title: Option<String>, is_new: Option<bool>) {
|
pub fn dalle2_window(
|
||||||
|
handle: &tauri::AppHandle,
|
||||||
|
query: Option<String>,
|
||||||
|
title: Option<String>,
|
||||||
|
is_new: Option<bool>,
|
||||||
|
) {
|
||||||
info!("dalle2_query: {:?}", query);
|
info!("dalle2_query: {:?}", query);
|
||||||
let theme = conf::ChatConfJson::theme();
|
let theme = conf::ChatConfJson::theme();
|
||||||
let app = handle.clone();
|
let app = handle.clone();
|
||||||
@@ -57,18 +62,22 @@ pub fn dalle2_window(handle: &tauri::AppHandle, query: Option<String>, title: Op
|
|||||||
|
|
||||||
if app.get_window("dalle2").is_none() {
|
if app.get_window("dalle2").is_none() {
|
||||||
tauri::async_runtime::spawn(async move {
|
tauri::async_runtime::spawn(async move {
|
||||||
WindowBuilder::new(&app, label, WindowUrl::App("https://labs.openai.com".into()))
|
WindowBuilder::new(
|
||||||
.title(title.unwrap_or_else(|| "DALL·E 2".to_string()))
|
&app,
|
||||||
.resizable(true)
|
label,
|
||||||
.fullscreen(false)
|
WindowUrl::App("https://labs.openai.com".into()),
|
||||||
.inner_size(800.0, 600.0)
|
)
|
||||||
.always_on_top(false)
|
.title(title.unwrap_or_else(|| "DALL·E 2".to_string()))
|
||||||
.theme(theme)
|
.resizable(true)
|
||||||
.initialization_script(include_str!("../scripts/core.js"))
|
.fullscreen(false)
|
||||||
.initialization_script(&query)
|
.inner_size(800.0, 600.0)
|
||||||
.initialization_script(include_str!("../scripts/dalle2.js"))
|
.always_on_top(false)
|
||||||
.build()
|
.theme(theme)
|
||||||
.unwrap();
|
.initialization_script(include_str!("../scripts/core.js"))
|
||||||
|
.initialization_script(&query)
|
||||||
|
.initialization_script(include_str!("../scripts/dalle2.js"))
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
let dalle2_win = app.get_window("dalle2").unwrap();
|
let dalle2_win = app.get_window("dalle2").unwrap();
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ pub const ISSUES_URL: &str = "https://github.com/lencx/ChatGPT/issues";
|
|||||||
pub const UPDATE_LOG_URL: &str = "https://github.com/lencx/ChatGPT/blob/main/UPDATE_LOG.md";
|
pub const UPDATE_LOG_URL: &str = "https://github.com/lencx/ChatGPT/blob/main/UPDATE_LOG.md";
|
||||||
pub const AWESOME_URL: &str = "https://github.com/lencx/ChatGPT/blob/main/AWESOME.md";
|
pub const AWESOME_URL: &str = "https://github.com/lencx/ChatGPT/blob/main/AWESOME.md";
|
||||||
pub const BUY_COFFEE: &str = "https://www.buymeacoffee.com/lencx";
|
pub const BUY_COFFEE: &str = "https://www.buymeacoffee.com/lencx";
|
||||||
pub const GITHUB_PROMPTS_CSV_URL: &str = "https://raw.githubusercontent.com/f/awesome-chatgpt-prompts/main/prompts.csv";
|
pub const GITHUB_PROMPTS_CSV_URL: &str =
|
||||||
|
"https://raw.githubusercontent.com/f/awesome-chatgpt-prompts/main/prompts.csv";
|
||||||
pub const DEFAULT_CHAT_CONF: &str = r#"{
|
pub const DEFAULT_CHAT_CONF: &str = r#"{
|
||||||
"stay_on_top": false,
|
"stay_on_top": false,
|
||||||
"auto_update": "Prompt",
|
"auto_update": "Prompt",
|
||||||
@@ -148,7 +149,10 @@ impl ChatConfJson {
|
|||||||
config.insert(k, v);
|
config.insert(k, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
fs::write(ChatConfJson::conf_path(), serde_json::to_string_pretty(&config)?)?;
|
fs::write(
|
||||||
|
ChatConfJson::conf_path(),
|
||||||
|
serde_json::to_string_pretty(&config)?,
|
||||||
|
)?;
|
||||||
|
|
||||||
if let Some(handle) = app {
|
if let Some(handle) = app {
|
||||||
tauri::api::process::restart(&handle.env());
|
tauri::api::process::restart(&handle.env());
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
#![cfg_attr(all(not(debug_assertions), target_os = "windows"), windows_subsystem = "windows")]
|
#![cfg_attr(
|
||||||
|
all(not(debug_assertions), target_os = "windows"),
|
||||||
|
windows_subsystem = "windows"
|
||||||
|
)]
|
||||||
|
|
||||||
mod app;
|
mod app;
|
||||||
mod conf;
|
mod conf;
|
||||||
@@ -48,7 +51,10 @@ async fn main() {
|
|||||||
.build(),
|
.build(),
|
||||||
)
|
)
|
||||||
.plugin(tauri_plugin_positioner::init())
|
.plugin(tauri_plugin_positioner::init())
|
||||||
.plugin(tauri_plugin_autostart::init(MacosLauncher::LaunchAgent, None))
|
.plugin(tauri_plugin_autostart::init(
|
||||||
|
MacosLauncher::LaunchAgent,
|
||||||
|
None,
|
||||||
|
))
|
||||||
.invoke_handler(tauri::generate_handler![
|
.invoke_handler(tauri::generate_handler![
|
||||||
cmd::drag_window,
|
cmd::drag_window,
|
||||||
cmd::fullscreen,
|
cmd::fullscreen,
|
||||||
|
|||||||
@@ -64,7 +64,11 @@ pub fn open_file(path: PathBuf) {
|
|||||||
Command::new("open").arg("-R").arg(path).spawn().unwrap();
|
Command::new("open").arg("-R").arg(path).spawn().unwrap();
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
Command::new("explorer").arg("/select,").arg(path).spawn().unwrap();
|
Command::new("explorer")
|
||||||
|
.arg("/select,")
|
||||||
|
.arg(path)
|
||||||
|
.spawn()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
// https://askubuntu.com/a/31071
|
// https://askubuntu.com/a/31071
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
@@ -78,12 +82,17 @@ pub fn clear_conf(app: &tauri::AppHandle) {
|
|||||||
"Path: {}\nAre you sure to clear all ChatGPT configurations? Please backup in advance if necessary!",
|
"Path: {}\nAre you sure to clear all ChatGPT configurations? Please backup in advance if necessary!",
|
||||||
root.to_string_lossy()
|
root.to_string_lossy()
|
||||||
);
|
);
|
||||||
tauri::api::dialog::ask(app.get_window("core").as_ref(), "Clear Config", msg, move |is_ok| {
|
tauri::api::dialog::ask(
|
||||||
if is_ok {
|
app.get_window("core").as_ref(),
|
||||||
fs::remove_dir_all(root).unwrap();
|
"Clear Config",
|
||||||
tauri::api::process::restart(&app2.env());
|
msg,
|
||||||
}
|
move |is_ok| {
|
||||||
});
|
if is_ok {
|
||||||
|
fs::remove_dir_all(root).unwrap();
|
||||||
|
tauri::api::process::restart(&app2.env());
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn merge(v: &Value, fields: &HashMap<String, Value>) -> Value {
|
pub fn merge(v: &Value, fields: &HashMap<String, Value>) -> Value {
|
||||||
@@ -104,7 +113,10 @@ pub fn gen_cmd(name: String) -> String {
|
|||||||
re.replace_all(&name, "_").to_lowercase()
|
re.replace_all(&name, "_").to_lowercase()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_data(url: &str, app: Option<&tauri::AppHandle>) -> Result<Option<String>, reqwest::Error> {
|
pub async fn get_data(
|
||||||
|
url: &str,
|
||||||
|
app: Option<&tauri::AppHandle>,
|
||||||
|
) -> Result<Option<String>, reqwest::Error> {
|
||||||
let res = reqwest::get(url).await?;
|
let res = reqwest::get(url).await?;
|
||||||
let is_ok = res.status() == 200;
|
let is_ok = res.status() == 200;
|
||||||
let body = res.text().await?;
|
let body = res.text().await?;
|
||||||
@@ -222,7 +234,11 @@ pub async fn silent_install(app: AppHandle<Wry>, update: UpdateResponse<Wry>) ->
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_hidden(entry: &walkdir::DirEntry) -> bool {
|
pub fn is_hidden(entry: &walkdir::DirEntry) -> bool {
|
||||||
entry.file_name().to_str().map(|s| s.starts_with('.')).unwrap_or(false)
|
entry
|
||||||
|
.file_name()
|
||||||
|
.to_str()
|
||||||
|
.map(|s| s.starts_with('.'))
|
||||||
|
.unwrap_or(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn vec_to_hashmap(
|
pub fn vec_to_hashmap(
|
||||||
|
|||||||
Reference in New Issue
Block a user