mirror of
https://github.com/lencx/ChatGPT.git
synced 2024-10-01 01:06:13 -04:00
chore: dalle2
This commit is contained in:
parent
b97d3a55f2
commit
7ee9b0c716
@ -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 构建,因其安全限制,会导致部分操作按钮无效,建议前往浏览器操作。
|
||||
|
||||
### #️⃣ 菜单项
|
||||
|
||||
|
@ -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
|
||||
|
||||
<!-- - Web access capability ([#20](https://github.com/lencx/ChatGPT/issues/20)) -->
|
||||
- `Control Center` - Feature Enhancements
|
||||
- Integration with [DALL·E 2](https://openai.com/dall-e-2/) ([#122](https://github.com/lencx/ChatGPT/issues/122))
|
||||
- ...
|
||||
|
||||
## 👀 Preview
|
||||
|
||||
<img width="320" src="./assets/install.png" alt="install"> <img width="320" src="./assets/chatgpt-control-center-general.png" alt="control center">
|
||||
<img width="320" src="./assets/chatgpt-export.png" alt="export"> <img width="320" src="./assets/chatgpt-dalle2-tray.png" alt="dalle2 tray">
|
||||
<img width="320" src="./assets/auto-update.png" alt="auto update">
|
||||
<img width="320" src="./assets/install.png" alt="install"> <img width="320" src="./assets/chatgpt-popup-search.png" alt="popup search">
|
||||
<img width="320" src="./assets/chatgpt-control-center-general.png" alt="control center"> <img width="320" src="./assets/chatgpt-export.png" alt="export">
|
||||
<img width="320" src="./assets/chatgpt-dalle2-tray.png" alt="dalle2 tray"> <img width="320" src="./assets/auto-update.png" alt="auto update">
|
||||
|
||||
## ❓FAQ
|
||||
|
||||
|
@ -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)
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 739 KiB After Width: | Height: | Size: 742 KiB |
BIN
assets/chatgpt-popup-search.png
Normal file
BIN
assets/chatgpt-popup-search.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 580 KiB |
@ -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<tauri::Wry>) {
|
||||
let win = Some(event.window()).unwrap();
|
||||
let app = win.app_handle();
|
||||
let state: tauri::State<conf::ChatState> = 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<tauri::Wry>) {
|
||||
"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<tauri::Wry>) {
|
||||
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),
|
||||
|
@ -66,7 +66,7 @@ pub fn init(app: &mut App) -> std::result::Result<(), Box<dyn std::error::Error>
|
||||
.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<dyn std::error::Error>
|
||||
.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)
|
||||
|
@ -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<String>, 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();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -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');
|
@ -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<bool>,
|
||||
}
|
||||
|
||||
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,
|
||||
|
@ -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,
|
||||
|
6
src/view/General.tsx
vendored
6
src/view/General.tsx
vendored
@ -33,10 +33,10 @@ const OriginLabel = ({ url }: { url: string }) => {
|
||||
)
|
||||
}
|
||||
|
||||
const Dalle2SearchLabel = () => {
|
||||
const PopupSearchLabel = () => {
|
||||
return (
|
||||
<span>
|
||||
DALL·E 2 Search
|
||||
Pop-up Search
|
||||
{' '}
|
||||
<Tooltip title={(
|
||||
<div>
|
||||
@ -137,7 +137,7 @@ export default function General() {
|
||||
<Switch />
|
||||
</Form.Item>
|
||||
)}
|
||||
<Form.Item label={<Dalle2SearchLabel />} name="dalle2_search" valuePropName="checked">
|
||||
<Form.Item label={<PopupSearchLabel />} name="popup_search" valuePropName="checked">
|
||||
<Switch />
|
||||
</Form.Item>
|
||||
<Form.Item label="Theme" name="theme">
|
||||
|
Loading…
Reference in New Issue
Block a user