mirror of
https://github.com/FranP-code/ChatGPT.git
synced 2025-10-13 00:13:25 +00:00
chore: dalle2
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
use crate::{conf, utils};
|
||||
use log::info;
|
||||
use std::time::SystemTime;
|
||||
use tauri::{utils::config::WindowUrl, window::WindowBuilder};
|
||||
|
||||
@@ -27,7 +28,8 @@ pub fn tray_window(handle: &tauri::AppHandle) {
|
||||
});
|
||||
}
|
||||
|
||||
pub fn dalle2_window(handle: &tauri::AppHandle, query: String) {
|
||||
pub fn dalle2_window(handle: &tauri::AppHandle, query: Option<String>, title: Option<String>) {
|
||||
info!("dalle2_query: {:?}", query);
|
||||
let timestamp = SystemTime::now()
|
||||
.duration_since(SystemTime::UNIX_EPOCH)
|
||||
.unwrap()
|
||||
@@ -35,22 +37,32 @@ pub fn dalle2_window(handle: &tauri::AppHandle, query: String) {
|
||||
let theme = conf::ChatConfJson::theme();
|
||||
let app = handle.clone();
|
||||
|
||||
let query = if query.is_some() {
|
||||
format!(
|
||||
"window.addEventListener('DOMContentLoaded', function() {{\nwindow.__CHATGPT_QUERY__='{}';\n}})",
|
||||
query.unwrap()
|
||||
)
|
||||
} else {
|
||||
"".to_string()
|
||||
};
|
||||
|
||||
tauri::async_runtime::spawn(async move {
|
||||
WindowBuilder::new(&app, format!("dalle2_{}", timestamp), WindowUrl::App("https://labs.openai.com".into()))
|
||||
.title("ChatGPT & DALL·E 2")
|
||||
.resizable(true)
|
||||
.fullscreen(false)
|
||||
.inner_size(800.0, 600.0)
|
||||
.always_on_top(false)
|
||||
.theme(theme)
|
||||
.initialization_script(include_str!("../assets/core.js"))
|
||||
.initialization_script(&format!(
|
||||
"window.addEventListener('DOMContentLoaded', function() {{\nwindow.__CHATGPT_QUERY__='{}';\n}})",
|
||||
query
|
||||
))
|
||||
.initialization_script(include_str!("../assets/dalle2.js"))
|
||||
.build()
|
||||
.unwrap();
|
||||
WindowBuilder::new(
|
||||
&app,
|
||||
format!("dalle2_{}", timestamp),
|
||||
WindowUrl::App("https://labs.openai.com/".into()),
|
||||
)
|
||||
.title(title.unwrap_or_else(|| "DALL·E 2".to_string()))
|
||||
.resizable(true)
|
||||
.fullscreen(false)
|
||||
.inner_size(800.0, 600.0)
|
||||
.always_on_top(false)
|
||||
.theme(theme)
|
||||
.initialization_script(include_str!("../assets/core.js"))
|
||||
.initialization_script(&query)
|
||||
.initialization_script(include_str!("../assets/dalle2.js"))
|
||||
.build()
|
||||
.unwrap();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user