diff --git a/README.md b/README.md index 460760d..08f3a08 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,7 @@ You can look at **[awesome-chatgpt-prompts](https://github.com/f/awesome-chatgpt - Powerful menu items - Support for slash commands and their configuration (can be configured manually or synchronized from a file [#55](https://github.com/lencx/ChatGPT/issues/55)) - Customize global shortcuts ([#108](https://github.com/lencx/ChatGPT/issues/108)) -- DALL·E 2 Search (mouse selected content [#122](https://github.com/lencx/ChatGPT/issues/122)) +- DALL·E 2 Search (mouse selected content [#122](https://github.com/lencx/ChatGPT/issues/122), use no more than 400 characters): The application is built using Tauri, and due to its security restrictions, some of the action buttons will not work, so we recommend going to your browser. ## #️⃣ MenuItem diff --git a/src-tauri/src/app/cmd.rs b/src-tauri/src/app/cmd.rs index 8755da4..adff518 100644 --- a/src-tauri/src/app/cmd.rs +++ b/src-tauri/src/app/cmd.rs @@ -61,7 +61,7 @@ pub fn reset_chat_conf() -> ChatConfJson { #[command] pub fn run_check_update(app: AppHandle, silent: bool, has_msg: Option) { - utils::run_check_update(app, silent, has_msg).unwrap(); + utils::run_check_update(app, silent, has_msg); } #[command] diff --git a/src-tauri/src/app/menu.rs b/src-tauri/src/app/menu.rs index 8bf5cd8..0af7115 100644 --- a/src-tauri/src/app/menu.rs +++ b/src-tauri/src/app/menu.rs @@ -229,7 +229,7 @@ pub fn menu_handler(event: WindowMenuEvent) { ); } "check_update" => { - utils::run_check_update(app, false, None).unwrap(); + utils::run_check_update(app, false, None); } // Preferences "control_center" => window::control_window(&app), diff --git a/src-tauri/src/app/setup.rs b/src-tauri/src/app/setup.rs index 7b90f29..2ac2ddb 100644 --- a/src-tauri/src/app/setup.rs +++ b/src-tauri/src/app/setup.rs @@ -100,7 +100,7 @@ pub fn init(app: &mut App) -> std::result::Result<(), Box if chat_conf.auto_update != "Disable" { info!("stepup::run_check_update"); let app = app.handle(); - utils::run_check_update(app, chat_conf.auto_update == "Silent", None).unwrap(); + utils::run_check_update(app, chat_conf.auto_update == "Silent", None); } Ok(()) diff --git a/src-tauri/src/app/window.rs b/src-tauri/src/app/window.rs index 94d6e92..56022ae 100644 --- a/src-tauri/src/app/window.rs +++ b/src-tauri/src/app/window.rs @@ -50,7 +50,7 @@ pub fn dalle2_window(handle: &tauri::AppHandle, query: Option, title: Op WindowBuilder::new( &app, format!("dalle2_{}", timestamp), - WindowUrl::App("https://labs.openai.com/".into()), + WindowUrl::App("https://labs.openai.com".into()), ) .title(title.unwrap_or_else(|| "DALL·E 2".to_string())) .resizable(true) diff --git a/src-tauri/src/assets/dalle2.js b/src-tauri/src/assets/dalle2.js index 30dfdee..9a5b2a4 100644 --- a/src-tauri/src/assets/dalle2.js +++ b/src-tauri/src/assets/dalle2.js @@ -1,34 +1,30 @@ // *** Core Script - DALL·E 2 *** async function init() { + document.addEventListener("click", (e) => { + const origin = e.target.closest("a"); + if (origin && origin.href && origin.target !== '_self') { + if (/\/(login|signup)$/.test(window.location.href)) { + origin.target = '_self'; + } else { + invoke('open_link', { url: origin.href }); + } + } + }); + if (window.searchInterval) { clearInterval(window.searchInterval); } window.searchInterval = setInterval(() => { - // const searchForm = document.querySelector('.image-prompt-form-wrapper form'); - // const searchBtn = document.querySelector('.image-prompt-form-wrapper form .image-prompt-btn'); const searchInput = document.querySelector('.image-prompt-form-wrapper form>.text-input'); if (searchInput) { - document.addEventListener("click", (e) => { - const origin = e.target.closest("a"); - if (origin && origin.href && origin.target !== '_self') { - invoke('open_link', { url: origin.href }); - } - }); - clearInterval(window.searchInterval); if (!window.__CHATGPT_QUERY__) return; const query = decodeURIComponent(window.__CHATGPT_QUERY__); searchInput.focus(); searchInput.value = query; - searchInput.setAttribute('value', query); - // searchInput.dispatchEvent(new CustomEvent('change')); - // searchForm.classList.add('focused'); - // searchBtn.classList.add('active-style'); - // searchBtn.removeAttribute('disabled'); - // searchBtn.classList.remove('btn-disabled', 'btn-disabled-style'); } }, 200) } diff --git a/src-tauri/src/utils.rs b/src-tauri/src/utils.rs index b36e8f0..608936f 100644 --- a/src-tauri/src/utils.rs +++ b/src-tauri/src/utils.rs @@ -130,7 +130,8 @@ pub async fn get_data( } } -pub fn run_check_update(app: AppHandle, silent: bool, has_msg: Option) -> Result<()> { +pub fn run_check_update(app: AppHandle, silent: bool, has_msg: Option) { + info!("run_check_update: silent={} has_msg={:?}", silent, has_msg); tauri::async_runtime::spawn(async move { let result = app.updater().check().await; let update_resp = result.unwrap(); @@ -154,13 +155,13 @@ pub fn run_check_update(app: AppHandle, silent: bool, has_msg: Option } } }); - Ok(()) } // Copy private api in tauri/updater/mod.rs. TODO: refactor to public api // Prompt a dialog asking if the user want to install the new version // Maybe we should add an option to customize it in future versions. pub async fn prompt_for_install(app: AppHandle, update: UpdateResponse) -> Result<()> { + info!("prompt_for_install"); let windows = app.windows(); let parent_window = windows.values().next(); let package_info = app.package_info().clone(); @@ -207,6 +208,7 @@ Release Notes: } pub async fn silent_install(app: AppHandle, update: UpdateResponse) -> Result<()> { + info!("silent_install"); let windows = app.windows(); let parent_window = windows.values().next();