diff --git a/README-ZH_CN.md b/README-ZH_CN.md
index fe4141f..fc48c43 100644
--- a/README-ZH_CN.md
+++ b/README-ZH_CN.md
@@ -90,7 +90,7 @@
- 应用菜单功能强大
- 支持斜杠命令及其配置(可手动配置或从文件同步 [#55](https://github.com/lencx/ChatGPT/issues/55))
- 自定义全局快捷键 ([#108](https://github.com/lencx/ChatGPT/issues/108))
-- DALL·E 2 搜索 ([#122](https://github.com/lencx/ChatGPT/issues/122) 鼠标选中文本,不超过 400 个字符):应用使用 Tauri 构建,因其安全限制,会导致部分操作按钮无效,建议前往浏览器操作。
+- 划词搜索 ([#122](https://github.com/lencx/ChatGPT/issues/122) 鼠标选中文本,不超过 400 个字符):应用使用 Tauri 构建,因其安全限制,会导致部分操作按钮无效,建议前往浏览器操作。
### #️⃣ 菜单项
diff --git a/README.md b/README.md
index 4086336..ae26d86 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 ([#122](https://github.com/lencx/ChatGPT/issues/122) mouse selected content, 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.
+- Pop-up Search ([#122](https://github.com/lencx/ChatGPT/issues/122) mouse selected content, 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
@@ -174,14 +174,13 @@ Currently, only json and csv are supported for synchronizing custom files, and t
- `Control Center` - Feature Enhancements
-- Integration with [DALL·E 2](https://openai.com/dall-e-2/) ([#122](https://github.com/lencx/ChatGPT/issues/122))
- ...
## 👀 Preview
-
-
-
+
+
+
## ❓FAQ
diff --git a/UPDATE_LOG.md b/UPDATE_LOG.md
index 25cc34b..062cce6 100644
--- a/UPDATE_LOG.md
+++ b/UPDATE_LOG.md
@@ -5,7 +5,7 @@
feat:
- theme enhancement (Light, Dark, System)
- automatic updates support `silent` settings
-- generate images according to the content: select the ChatGPT content with the mouse, the `DALL·E 2` button appears, and click to jump (note: because the search content filled by the script cannot trigger the event directly, you need to enter a space in the input box to make the button clickable).
+- pop-up search: select the ChatGPT content with the mouse, the `DALL·E 2` button appears, and click to jump (note: because the search content filled by the script cannot trigger the event directly, you need to enter a space in the input box to make the button clickable).
fix:
- close the main window and hide it in the tray (windows systems)
diff --git a/assets/chatgpt-menu.png b/assets/chatgpt-menu.png
index bd5e4c2..5697725 100644
Binary files a/assets/chatgpt-menu.png and b/assets/chatgpt-menu.png differ
diff --git a/assets/chatgpt-popup-search.png b/assets/chatgpt-popup-search.png
new file mode 100644
index 0000000..650f344
Binary files /dev/null and b/assets/chatgpt-popup-search.png differ
diff --git a/src-tauri/src/app/menu.rs b/src-tauri/src/app/menu.rs
index 5a9495b..681fe92 100644
--- a/src-tauri/src/app/menu.rs
+++ b/src-tauri/src/app/menu.rs
@@ -41,7 +41,6 @@ pub fn init() -> Menu {
stay_on_top
};
-
#[cfg(target_os = "macos")]
let titlebar =
CustomMenuItem::new("titlebar".to_string(), "Titlebar").accelerator("CmdOrCtrl+B");
@@ -56,11 +55,11 @@ pub fn init() -> Menu {
let update_silent = CustomMenuItem::new("update_silent".to_string(), "Silent");
let _update_disable = CustomMenuItem::new("update_disable".to_string(), "Disable");
- let dalle2_search = CustomMenuItem::new("dalle2_search".to_string(), "DALL·E 2 Search");
- let dalle2_search_menu = if chat_conf.dalle2_search {
- dalle2_search.selected()
+ let popup_search = CustomMenuItem::new("popup_search".to_string(), "Pop-up Search");
+ let popup_search_menu = if chat_conf.popup_search {
+ popup_search.selected()
} else {
- dalle2_search
+ popup_search
};
#[cfg(target_os = "macos")]
@@ -126,7 +125,7 @@ pub fn init() -> Menu {
)
.into(),
MenuItem::Separator.into(),
- dalle2_search_menu.into(),
+ popup_search_menu.into(),
CustomMenuItem::new("sync_prompts".to_string(), "Sync Prompts").into(),
MenuItem::Separator.into(),
CustomMenuItem::new("go_conf".to_string(), "Go to Config")
@@ -219,12 +218,9 @@ pub fn init() -> Menu {
pub fn menu_handler(event: WindowMenuEvent) {
let win = Some(event.window()).unwrap();
let app = win.app_handle();
- let state: tauri::State = app.state();
let script_path = utils::script_path().to_string_lossy().to_string();
let menu_id = event.menu_item_id();
-
- let core_window = app.get_window("core").unwrap();
- let menu_handle = core_window.menu_handle();
+ let menu_handle = win.menu_handle();
match menu_id {
// App
@@ -246,17 +242,18 @@ pub fn menu_handler(event: WindowMenuEvent) {
"go_conf" => utils::open_file(utils::chat_root()),
"clear_conf" => utils::clear_conf(&app),
"awesome" => open(&app, conf::AWESOME_URL.to_string()),
- "dalle2_search" => {
+ "popup_search" => {
let chat_conf = conf::ChatConfJson::get_chat_conf();
- let dalle2_search = !chat_conf.dalle2_search;
+ let popup_search = !chat_conf.popup_search;
menu_handle
.get_item(menu_id)
- .set_selected(dalle2_search)
+ .set_selected(popup_search)
+ .unwrap();
+ ChatConfJson::amend(&serde_json::json!({ "popup_search": popup_search }), None)
.unwrap();
- ChatConfJson::amend(&serde_json::json!({ "dalle2_search": dalle2_search }), None).unwrap();
cmd::window_reload(app.clone(), "core");
cmd::window_reload(app, "tray");
- },
+ }
"sync_prompts" => {
tauri::api::dialog::ask(
app.get_window("core").as_ref(),
@@ -323,14 +320,14 @@ pub fn menu_handler(event: WindowMenuEvent) {
ChatConfJson::amend(&serde_json::json!({ "auto_update": auto_update }), None).unwrap();
}
"stay_on_top" => {
- let mut stay_on_top = state.stay_on_top.lock().unwrap();
- *stay_on_top = !*stay_on_top;
+ let chat_conf = conf::ChatConfJson::get_chat_conf();
+ let stay_on_top = !chat_conf.stay_on_top;
menu_handle
.get_item(menu_id)
- .set_selected(*stay_on_top)
+ .set_selected(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();
+ win.set_always_on_top(stay_on_top).unwrap();
+ ChatConfJson::amend(&serde_json::json!({ "stay_on_top": stay_on_top }), None).unwrap();
}
// Window
"dalle2" => window::dalle2_window(&app, None, None),
diff --git a/src-tauri/src/app/setup.rs b/src-tauri/src/app/setup.rs
index 2ac2ddb..ca3c0c4 100644
--- a/src-tauri/src/app/setup.rs
+++ b/src-tauri/src/app/setup.rs
@@ -66,7 +66,7 @@ pub fn init(app: &mut App) -> std::result::Result<(), Box
.initialization_script(include_str!("../vendors/html2canvas.js"))
.initialization_script(include_str!("../vendors/jspdf.js"))
.initialization_script(include_str!("../assets/core.js"))
- .initialization_script(include_str!("../assets/dalle2.core.js"))
+ .initialization_script(include_str!("../assets/popup.core.js"))
.initialization_script(include_str!("../assets/export.js"))
.initialization_script(include_str!("../assets/cmd.js"))
.user_agent(&chat_conf.ua_window)
@@ -87,7 +87,7 @@ pub fn init(app: &mut App) -> std::result::Result<(), Box
.initialization_script(include_str!("../vendors/html2canvas.js"))
.initialization_script(include_str!("../vendors/jspdf.js"))
.initialization_script(include_str!("../assets/core.js"))
- .initialization_script(include_str!("../assets/dalle2.core.js"))
+ .initialization_script(include_str!("../assets/popup.core.js"))
.initialization_script(include_str!("../assets/export.js"))
.initialization_script(include_str!("../assets/cmd.js"))
.user_agent(&chat_conf.ua_window)
diff --git a/src-tauri/src/app/window.rs b/src-tauri/src/app/window.rs
index a4edebc..901a327 100644
--- a/src-tauri/src/app/window.rs
+++ b/src-tauri/src/app/window.rs
@@ -1,7 +1,7 @@
use crate::{conf, utils};
use log::info;
use std::time::SystemTime;
-use tauri::{utils::config::WindowUrl, window::WindowBuilder};
+use tauri::{utils::config::WindowUrl, window::WindowBuilder, Manager};
pub fn tray_window(handle: &tauri::AppHandle) {
let chat_conf = conf::ChatConfJson::get_chat_conf();
@@ -22,7 +22,7 @@ pub fn tray_window(handle: &tauri::AppHandle) {
.initialization_script(include_str!("../vendors/floating-ui-dom.js"))
.initialization_script(include_str!("../assets/core.js"))
.initialization_script(include_str!("../assets/cmd.js"))
- .initialization_script(include_str!("../assets/dalle2.core.js"))
+ .initialization_script(include_str!("../assets/popup.core.js"))
.user_agent(&chat_conf.ua_tray)
.build()
.unwrap()
@@ -72,13 +72,19 @@ pub fn dalle2_window(handle: &tauri::AppHandle, query: Option, title: Op
pub fn control_window(handle: &tauri::AppHandle) {
let app = handle.clone();
tauri::async_runtime::spawn(async move {
- WindowBuilder::new(&app, "main", WindowUrl::App("index.html".into()))
- .title("Control Center")
- .resizable(true)
- .fullscreen(false)
- .inner_size(800.0, 600.0)
- .min_inner_size(800.0, 600.0)
- .build()
- .unwrap();
+ if app.app_handle().get_window("main").is_none() {
+ WindowBuilder::new(&app, "main", WindowUrl::App("index.html".into()))
+ .title("Control Center")
+ .resizable(true)
+ .fullscreen(false)
+ .inner_size(800.0, 600.0)
+ .min_inner_size(800.0, 600.0)
+ .build()
+ .unwrap();
+ } else {
+ let main_win = app.app_handle().get_window("main").unwrap();
+ main_win.show().unwrap();
+ main_win.set_focus().unwrap();
+ }
});
}
diff --git a/src-tauri/src/assets/dalle2.core.js b/src-tauri/src/assets/popup.core.js
similarity index 98%
rename from src-tauri/src/assets/dalle2.core.js
rename to src-tauri/src/assets/popup.core.js
index ab89b27..3eb7b02 100644
--- a/src-tauri/src/assets/dalle2.core.js
+++ b/src-tauri/src/assets/popup.core.js
@@ -2,7 +2,7 @@
async function init() {
const chatConf = await invoke('get_chat_conf') || {};
- if (!chatConf.dalle2_search) return;
+ if (!chatConf.popup_search) return;
if (!window.FloatingUIDOM) return;
const styleDom = document.createElement('style');
diff --git a/src-tauri/src/conf.rs b/src-tauri/src/conf.rs
index c34b316..e2ba14a 100644
--- a/src-tauri/src/conf.rs
+++ b/src-tauri/src/conf.rs
@@ -2,7 +2,7 @@ use crate::utils::{chat_root, create_file, exists};
use anyhow::Result;
use log::info;
use serde_json::Value;
-use std::{collections::BTreeMap, fs, path::PathBuf, sync::Mutex};
+use std::{collections::BTreeMap, fs, path::PathBuf};
use tauri::{Manager, Theme};
#[cfg(target_os = "macos")]
@@ -21,7 +21,7 @@ pub const DEFAULT_CHAT_CONF: &str = r#"{
"auto_update": "Prompt",
"theme": "Light",
"titlebar": true,
- "dalle2_search": true,
+ "popup_search": true,
"global_shortcut": "",
"hide_dock_icon": false,
"default_origin": "https://chat.openai.com",
@@ -34,7 +34,7 @@ pub const DEFAULT_CHAT_CONF_MAC: &str = r#"{
"auto_update": "Prompt",
"theme": "Light",
"titlebar": false,
- "dalle2_search": true,
+ "popup_search": true,
"global_shortcut": "",
"hide_dock_icon": false,
"default_origin": "https://chat.openai.com",
@@ -43,18 +43,6 @@ pub const DEFAULT_CHAT_CONF_MAC: &str = r#"{
"ua_tray": ""
}"#;
-pub struct ChatState {
- pub stay_on_top: Mutex,
-}
-
-impl ChatState {
- pub fn default(chat_conf: ChatConfJson) -> Self {
- ChatState {
- stay_on_top: Mutex::new(chat_conf.stay_on_top),
- }
- }
-}
-
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)]
pub struct ChatConfJson {
// support macOS only
@@ -65,7 +53,7 @@ pub struct ChatConfJson {
pub theme: String,
// auto update policy, Prompt/Silent/Disable
pub auto_update: String,
- pub dalle2_search: bool,
+ pub popup_search: bool,
pub stay_on_top: bool,
pub default_origin: String,
pub origin: String,
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index 8820dfe..5d9db81 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -8,7 +8,7 @@ mod conf;
mod utils;
use app::{cmd, fs_extra, menu, setup};
-use conf::{ChatConfJson, ChatState};
+use conf::ChatConfJson;
use tauri::api::path;
use tauri_plugin_autostart::MacosLauncher;
use tauri_plugin_log::{
@@ -21,7 +21,6 @@ async fn main() {
ChatConfJson::init();
// If the file does not exist, creating the file will block menu synchronization
utils::create_chatgpt_prompts();
- let chat_conf = ChatConfJson::get_chat_conf();
let context = tauri::generate_context!();
let colors = ColoredLevelConfig {
error: Color::Red,
@@ -46,7 +45,6 @@ async fn main() {
])
.build(),
)
- .manage(ChatState::default(chat_conf))
.invoke_handler(tauri::generate_handler![
cmd::drag_window,
cmd::fullscreen,
diff --git a/src/view/General.tsx b/src/view/General.tsx
index e77d287..6dfbdab 100644
--- a/src/view/General.tsx
+++ b/src/view/General.tsx
@@ -33,10 +33,10 @@ const OriginLabel = ({ url }: { url: string }) => {
)
}
-const Dalle2SearchLabel = () => {
+const PopupSearchLabel = () => {
return (
- DALL·E 2 Search
+ Pop-up Search
{' '}
@@ -137,7 +137,7 @@ export default function General() {
)}
- } name="dalle2_search" valuePropName="checked">
+ } name="popup_search" valuePropName="checked">