mirror of
https://github.com/FranP-code/ChatGPT.git
synced 2025-10-13 00:13:25 +00:00
feat: add menu item
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
use crate::{
|
||||
app::window,
|
||||
conf::{self, ChatConfJson},
|
||||
utils,
|
||||
};
|
||||
@@ -69,6 +70,9 @@ pub fn init(chat_conf: &conf::ChatConfJson, context: &Context<EmbeddedAssets>) -
|
||||
always_on_top_menu.into(),
|
||||
#[cfg(target_os = "macos")]
|
||||
titlebar_menu.into(),
|
||||
CustomMenuItem::new("switch_origin".to_string(), "Switch Origin")
|
||||
.accelerator("CmdOrCtrl+O")
|
||||
.into(),
|
||||
CustomMenuItem::new("inject_script".to_string(), "Inject Script")
|
||||
.accelerator("CmdOrCtrl+J")
|
||||
.into(),
|
||||
@@ -152,6 +156,10 @@ pub fn menu_handler(event: WindowMenuEvent<tauri::Wry>) {
|
||||
// Preferences
|
||||
"inject_script" => open(&app, script_path),
|
||||
"awesome" => open(&app, conf::AWESOME_URL.to_string()),
|
||||
"switch_origin" => {
|
||||
window::origin_window(&app);
|
||||
// app.get_window("origin").unwrap().show();
|
||||
}
|
||||
"titlebar" => {
|
||||
let chat_conf = conf::ChatConfJson::get_chat_conf();
|
||||
ChatConfJson::amend(&serde_json::json!({ "titlebar": !chat_conf.titlebar })).unwrap();
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
use crate::{app::window, conf, utils};
|
||||
use crate::{
|
||||
app::window,
|
||||
conf::{ChatConfJson, USER_AGENT},
|
||||
utils,
|
||||
};
|
||||
use tauri::{utils::config::WindowUrl, window::WindowBuilder, App, Manager};
|
||||
|
||||
pub fn init(
|
||||
app: &mut App,
|
||||
chat_conf: conf::ChatConfJson,
|
||||
chat_conf: ChatConfJson,
|
||||
) -> std::result::Result<(), Box<dyn std::error::Error>> {
|
||||
let tauri_conf = utils::get_tauri_conf().unwrap();
|
||||
let url = tauri_conf.build.dev_path.to_string();
|
||||
let theme = conf::ChatConfJson::theme();
|
||||
let url = chat_conf.origin.to_string();
|
||||
let theme = ChatConfJson::theme();
|
||||
window::mini_window(&app.app_handle());
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
@@ -18,13 +21,13 @@ pub fn init(
|
||||
.hidden_title(true)
|
||||
.theme(theme)
|
||||
.always_on_top(chat_conf.always_on_top)
|
||||
.title_bar_style(conf::ChatConfJson::titlebar())
|
||||
.title_bar_style(ChatConfJson::titlebar())
|
||||
.initialization_script(&utils::user_script())
|
||||
.initialization_script(include_str!("../assets/html2canvas.js"))
|
||||
.initialization_script(include_str!("../assets/jspdf.js"))
|
||||
.initialization_script(include_str!("../assets/core.js"))
|
||||
.initialization_script(include_str!("../assets/export.js"))
|
||||
.user_agent(conf::USER_AGENT)
|
||||
.user_agent(USER_AGENT)
|
||||
.build()?;
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
@@ -40,7 +43,7 @@ pub fn init(
|
||||
.initialization_script(include_str!("../assets/jspdf.js"))
|
||||
.initialization_script(include_str!("../assets/core.js"))
|
||||
.initialization_script(include_str!("../assets/export.js"))
|
||||
.user_agent(conf::USER_AGENT)
|
||||
.user_agent(USER_AGENT)
|
||||
.build()?;
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -2,12 +2,10 @@ use crate::{conf, utils};
|
||||
use tauri::{utils::config::WindowUrl, window::WindowBuilder};
|
||||
|
||||
pub fn mini_window(handle: &tauri::AppHandle) {
|
||||
let tauri_conf = utils::get_tauri_conf().unwrap();
|
||||
let url = tauri_conf.build.dev_path.to_string();
|
||||
// let chat_conf = conf::ChatConfJson::get_chat_conf();
|
||||
let chat_conf = conf::ChatConfJson::get_chat_conf();
|
||||
let theme = conf::ChatConfJson::theme();
|
||||
|
||||
WindowBuilder::new(handle, "mini", WindowUrl::App(url.into()))
|
||||
WindowBuilder::new(handle, "mini", WindowUrl::App(chat_conf.origin.into()))
|
||||
.resizable(false)
|
||||
.fullscreen(false)
|
||||
.inner_size(360.0, 540.0)
|
||||
@@ -25,3 +23,16 @@ pub fn mini_window(handle: &tauri::AppHandle) {
|
||||
.hide()
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
pub fn origin_window(handle: &tauri::AppHandle) {
|
||||
let theme = conf::ChatConfJson::theme();
|
||||
|
||||
WindowBuilder::new(handle, "main", WindowUrl::External("/".parse().unwrap()))
|
||||
.resizable(false)
|
||||
.fullscreen(false)
|
||||
.inner_size(400.0, 300.0)
|
||||
.always_on_top(true)
|
||||
.theme(theme)
|
||||
.build()
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user