mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-13 21:32:18 +00:00
login window tweaks
This commit is contained in:
1 parent
8068ca1c7b
commit
c2c13ef92c
4 files changed
+19
-11
No files matched your search
+1
-1
@@ -1,10 +1,10 @@
|
||||
use crate::core::commands::response::shorthand::{Response, SimpleResponse};
|
||||
use crate::core::state::data_dir::app_data_root::AppDataRoot;
|
||||
use crate::services::worldlabs::state::worldlabs_credential_manager::WorldlabsCredentialManager;
|
||||
use errors::AnyhowResult;
|
||||
use log::{error, info};
|
||||
use serde_derive::Deserialize;
|
||||
use tauri::State;
|
||||
use crate::services::worldlabs::state::worldlabs_credential_manager::WorldlabsCredentialManager;
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn worldlabs_clear_credentials_command(
|
||||
|
||||
-1
@@ -2,7 +2,6 @@ use cookie_store::cookie_store::CookieStore;
|
||||
use errors::AnyhowResult;
|
||||
use once_cell::sync::Lazy;
|
||||
use reqwest::Url;
|
||||
use std::collections::HashSet;
|
||||
use tauri::webview::Cookie;
|
||||
use tauri::WebviewWindow;
|
||||
|
||||
|
||||
+15
-6
@@ -7,6 +7,7 @@ use errors::AnyhowResult;
|
||||
use once_cell::sync::Lazy;
|
||||
use reqwest::Url;
|
||||
use std::time::Duration;
|
||||
use log::info;
|
||||
use tauri::{AppHandle, Manager, WebviewUrl, WebviewWindowBuilder};
|
||||
|
||||
/// Name of the window
|
||||
@@ -17,11 +18,11 @@ pub (super) static START_URL: Lazy<Url> = Lazy::new(|| {
|
||||
});
|
||||
|
||||
pub (super) static WORLDLABS_HOMEPAGE_URL: Lazy<Url> = Lazy::new(|| {
|
||||
Url::parse("https://grok.com/").expect("URL should parse")
|
||||
Url::parse("https://marble.worldlabs.ai/").expect("URL should parse")
|
||||
});
|
||||
|
||||
pub (super) static WORLDLABS_LOGIN_URL: Lazy<Url> = Lazy::new(|| {
|
||||
Url::parse("https://accounts.x.ai/sign-in?redirect=grok-com").expect("URL should parse")
|
||||
Url::parse("https://marble.worldlabs.ai/").expect("URL should parse")
|
||||
});
|
||||
|
||||
pub async fn worldlabs_login_window_open(
|
||||
@@ -43,7 +44,7 @@ pub async fn worldlabs_login_window_open(
|
||||
.resizable(true)
|
||||
.visible(true)
|
||||
.closable(true)
|
||||
.min_inner_size(200.0, 800.0)
|
||||
.min_inner_size(800.0, 800.0)
|
||||
.focused(true)
|
||||
.devtools(true)
|
||||
.build()?;
|
||||
@@ -55,10 +56,18 @@ pub async fn worldlabs_login_window_open(
|
||||
|
||||
webview.navigate(WORLDLABS_HOMEPAGE_URL.clone())?;
|
||||
|
||||
// NB: We're starting to get Cloudflare protection screens. Let's try to avoid.
|
||||
tokio::time::sleep(Duration::from_millis(100)).await;
|
||||
tokio::time::sleep(Duration::from_millis(200)).await;
|
||||
|
||||
webview.navigate(WORLDLABS_LOGIN_URL.clone())?;
|
||||
for _ in 0 .. 100 {
|
||||
tokio::time::sleep(Duration::from_millis(100)).await;
|
||||
info!("Running script...");
|
||||
|
||||
// Close "welcome"
|
||||
webview.eval(r#"document.querySelectorAll("div:has(h2) ~ button[data-slot=dialog-close]")"#)?;
|
||||
|
||||
// Open "login"
|
||||
webview.eval(r#"document.querySelectorAll("button:has(span[data-slot=avatar])").forEach((el) => el.click())"#)?;
|
||||
}
|
||||
|
||||
let app_handle = app.clone();
|
||||
let app_data_root = app_data_root.clone();
|
||||
|
||||
+3
-3
@@ -9,6 +9,9 @@ use crate::services::grok::state::grok_credential_manager::GrokCredentialManager
|
||||
use crate::services::sora::events::sora_login_success_event::SoraLoginSuccessEvent;
|
||||
use crate::services::sora::state::sora_credential_manager::SoraCredentialManager;
|
||||
use crate::services::sora::windows::sora_login_window::extract_sora_webview_cookies::extract_sora_webview_cookies;
|
||||
use crate::services::worldlabs::state::worldlabs_credential_manager::WorldlabsCredentialManager;
|
||||
use crate::services::worldlabs::windows::worldlabs_login_window::worldlabs_login_webview_extract_cookies::worldlabs_login_webview_extract_cookies;
|
||||
use crate::services::worldlabs::windows::worldlabs_login_window::worldlabs_login_window_open::WORLDLABS_LOGIN_WINDOW_NAME;
|
||||
use anyhow::anyhow;
|
||||
use cookie_store::cookie_store::CookieStore;
|
||||
use enums::common::generation_provider::GenerationProvider;
|
||||
@@ -18,9 +21,6 @@ use openai_sora_client::creds::sora_credential_set::SoraCredentialSet;
|
||||
use openai_sora_client::recipes::maybe_upgrade_or_renew_session::maybe_upgrade_or_renew_session;
|
||||
use openai_sora_client::utils::has_session_cookie::{has_session_cookie, SessionCookiePresence};
|
||||
use tauri::{AppHandle, Manager, WebviewWindow};
|
||||
use crate::services::worldlabs::state::worldlabs_credential_manager::WorldlabsCredentialManager;
|
||||
use crate::services::worldlabs::windows::worldlabs_login_window::worldlabs_login_webview_extract_cookies::worldlabs_login_webview_extract_cookies;
|
||||
use crate::services::worldlabs::windows::worldlabs_login_window::worldlabs_login_window_open::WORLDLABS_LOGIN_WINDOW_NAME;
|
||||
|
||||
pub async fn worldlabs_login_window_thread(
|
||||
app: AppHandle,
|
||||
|
||||
Reference in new issue
Block a user