♻️ 初步更改,cargo build

This commit is contained in:
目棃
2024-07-02 19:29:24 +08:00
parent ac63baed2c
commit 1214501691
16 changed files with 5679 additions and 1602 deletions

View File

@@ -1,25 +1,21 @@
//! @file src/client/mod.rs
//! @desc 客户端模块,负责操作米游社客户端
//! @since Beta v0.4.5
//! @since Beta v0.4.10
mod menu;
use tauri::async_runtime::block_on;
use tauri::{AppHandle, Manager, WindowBuilder, WindowEvent, WindowUrl};
use tauri::{AppHandle, Manager, WebviewWindowBuilder, WindowEvent};
use tauri_utils::config::WebviewUrl;
#[tauri::command]
pub async fn create_mhy_client(handle: AppHandle, func: String, url: String) {
let mut mhy_window_config = handle.config().tauri.windows.get(1).unwrap().clone();
let mut mhy_window_config = handle.config().app.windows.get(1).unwrap().clone();
mhy_window_config.visible = true;
if url != "" {
mhy_window_config.url = WindowUrl::External(url.parse().unwrap());
mhy_window_config.url = WebviewUrl::External(url.parse().unwrap());
} else {
mhy_window_config.url = menu::get_mhy_client_url(func.clone());
}
// if pc {
// let user_agent = mhy_window_config.user_agent.as_ref().unwrap();
// let version = user_agent.split("/").last().unwrap();
// mhy_window_config.user_agent = Some(format!("Mozilla/5.0 (Windows NT 10.0; Win64; x64) miHoYoBBS/{}", version));
// }
if func == "birthday"
|| func == "web_act"
|| url.starts_with("https://webstatic.mihoyo.com/ys/event/e20220303-birthday/index.html")
@@ -27,7 +23,7 @@ pub async fn create_mhy_client(handle: AppHandle, func: String, url: String) {
mhy_window_config.width = 1280.0;
mhy_window_config.height = 720.0;
}
let window_get = handle.get_window("mhy_client");
let window_get = handle.get_webview_window("mhy_client");
if window_get.is_some() {
let mhy_client = window_get.unwrap();
mhy_client.on_window_event(move |e| {
@@ -39,9 +35,10 @@ pub async fn create_mhy_client(handle: AppHandle, func: String, url: String) {
mhy_client.close().unwrap();
return;
}
WindowBuilder::from_config(&handle, mhy_window_config)
.menu(menu::create_mhy_menu(func))
.build()
WebviewWindowBuilder::from_config(&handle, &mhy_window_config)
.expect("failed to create mhy_client")
.on_menu_event(move |event| menu::handle_menu_event(handle.clone(), event));
.menu(menu::create_mhy_menu(func.clone(), handle.clone()))
.build()
.expect("failed to add menu")
.on_menu_event(move |app, event| menu::handle_menu_event(app, event));
}