1
0
mirror of https://github.com/lencx/ChatGPT.git synced 2024-10-01 01:06:13 -04:00

chore: dalle2

This commit is contained in:
lencx 2023-01-06 22:58:26 +08:00
parent 8022594ace
commit de5533d942
7 changed files with 20 additions and 22 deletions

View File

@ -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

View File

@ -61,7 +61,7 @@ pub fn reset_chat_conf() -> ChatConfJson {
#[command]
pub fn run_check_update(app: AppHandle, silent: bool, has_msg: Option<bool>) {
utils::run_check_update(app, silent, has_msg).unwrap();
utils::run_check_update(app, silent, has_msg);
}
#[command]

View File

@ -229,7 +229,7 @@ pub fn menu_handler(event: WindowMenuEvent<tauri::Wry>) {
);
}
"check_update" => {
utils::run_check_update(app, false, None).unwrap();
utils::run_check_update(app, false, None);
}
// Preferences
"control_center" => window::control_window(&app),

View File

@ -100,7 +100,7 @@ pub fn init(app: &mut App) -> std::result::Result<(), Box<dyn std::error::Error>
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(())

View File

@ -50,7 +50,7 @@ pub fn dalle2_window(handle: &tauri::AppHandle, query: Option<String>, 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)

View File

@ -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)
}

View File

@ -130,7 +130,8 @@ pub async fn get_data(
}
}
pub fn run_check_update(app: AppHandle<Wry>, silent: bool, has_msg: Option<bool>) -> Result<()> {
pub fn run_check_update(app: AppHandle<Wry>, silent: bool, has_msg: Option<bool>) {
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<Wry>, silent: bool, has_msg: Option<bool>
}
}
});
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<Wry>, update: UpdateResponse<Wry>) -> 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<Wry>, update: UpdateResponse<Wry>) -> Result<()> {
info!("silent_install");
let windows = app.windows();
let parent_window = windows.values().next();