chore: dashboard

This commit is contained in:
lencx
2023-01-24 18:34:31 +08:00
parent 4a7ee4dcf5
commit ba438b0640
12 changed files with 211 additions and 106 deletions

View File

@@ -235,7 +235,7 @@ pub fn menu_handler(event: WindowMenuEvent<tauri::Wry>) {
utils::run_check_update(app, false, None);
}
// Preferences
"control_center" => window::control_window(&app),
"control_center" => window::control_window(app.clone()),
"restart" => tauri::api::process::restart(&app.env()),
"inject_script" => open(&app, script_path),
"go_conf" => utils::open_file(utils::chat_root()),
@@ -431,7 +431,7 @@ pub fn tray_handler(handle: &AppHandle, event: SystemTrayEvent) {
}
}
SystemTrayEvent::MenuItemClick { id, .. } => match id.as_str() {
"control_center" => window::control_window(&app),
"control_center" => window::control_window(app),
"restart" => tauri::api::process::restart(&handle.env()),
"show_dock_icon" => {
ChatConfJson::amend(&serde_json::json!({ "hide_dock_icon": false }), Some(app)).unwrap();

View File

@@ -6,7 +6,7 @@ use wry::application::accelerator::Accelerator;
pub fn init(app: &mut App) -> std::result::Result<(), Box<dyn std::error::Error>> {
info!("stepup");
let chat_conf = ChatConfJson::get_chat_conf();
let url = chat_conf.origin.to_string();
let url = chat_conf.main_origin.to_string();
let theme = ChatConfJson::theme();
let handle = app.app_handle();
@@ -50,7 +50,7 @@ pub fn init(app: &mut App) -> std::result::Result<(), Box<dyn std::error::Error>
} else {
let app = app.handle();
tauri::async_runtime::spawn(async move {
let link = if chat_conf.dashboard {
let link = if chat_conf.main_dashboard {
"index.html"
} else {
&url
@@ -65,7 +65,7 @@ pub fn init(app: &mut App) -> std::result::Result<(), Box<dyn std::error::Error>
main_win = main_win.hidden_title(true);
}
if url == "https://chat.openai.com" && !chat_conf.dashboard {
if url == "https://chat.openai.com" && !chat_conf.main_dashboard {
main_win = main_win
.initialization_script(include_str!("../vendors/floating-ui-core.js"))
.initialization_script(include_str!("../vendors/floating-ui-dom.js"))

View File

@@ -93,12 +93,12 @@ pub fn dalle2_window(
}
}
pub fn control_window(handle: &tauri::AppHandle) {
let app = handle.clone();
#[tauri::command]
pub fn control_window(handle: tauri::AppHandle) {
tauri::async_runtime::spawn(async move {
if app.app_handle().get_window("main").is_none() {
if handle.get_window("main").is_none() {
WindowBuilder::new(
&app,
&handle,
"main",
WindowUrl::App("index.html?type=control".into()),
)
@@ -110,7 +110,7 @@ pub fn control_window(handle: &tauri::AppHandle) {
.build()
.unwrap();
} else {
let main_win = app.app_handle().get_window("main").unwrap();
let main_win = handle.get_window("main").unwrap();
main_win.show().unwrap();
main_win.set_focus().unwrap();
}