✨ 2.0 Upgrade Plan
This commit is contained in:
12
src-tauri/Cargo.lock
generated
12
src-tauri/Cargo.lock
generated
@@ -2451,6 +2451,7 @@ dependencies = [
|
||||
"tauri-plugin-oauth",
|
||||
"tauri-plugin-shell",
|
||||
"tauri-plugin-window-state",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3409,6 +3410,15 @@ version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
||||
|
||||
[[package]]
|
||||
name = "signal-hook-registry"
|
||||
version = "1.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "simd-adler32"
|
||||
version = "0.3.7"
|
||||
@@ -4178,7 +4188,9 @@ dependencies = [
|
||||
"bytes",
|
||||
"libc",
|
||||
"mio",
|
||||
"parking_lot",
|
||||
"pin-project-lite",
|
||||
"signal-hook-registry",
|
||||
"socket2",
|
||||
"tokio-macros",
|
||||
"windows-sys 0.52.0",
|
||||
|
||||
@@ -28,6 +28,7 @@ tauri-plugin-http = "2.0.3"
|
||||
[target."cfg(not(any(target_os = \"android\", target_os = \"ios\")))".dependencies]
|
||||
tauri-plugin-global-shortcut = { version = "2.0.1" }
|
||||
tauri-plugin-shell = "2.0.0"
|
||||
tokio = { version = "1", features = ["full"] }
|
||||
|
||||
[dev-dependencies]
|
||||
cargo-bloat = "0.12.1"
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
"height": 780,
|
||||
"resizable": true,
|
||||
"always_on_top": false,
|
||||
"dark_mode": false,
|
||||
"activation_shortcut": "",
|
||||
"disabled_web_shortcuts": false
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ pub struct WindowConfig {
|
||||
pub resizable: bool,
|
||||
pub url_type: String,
|
||||
pub always_on_top: bool,
|
||||
pub dark_mode: bool,
|
||||
pub disabled_web_shortcuts: bool,
|
||||
pub activation_shortcut: String,
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ use std::fs::{self, File};
|
||||
use std::io::Write;
|
||||
use std::str::FromStr;
|
||||
use tauri::http::Method;
|
||||
use tauri_plugin_http::reqwest::{ClientBuilder, Request};
|
||||
use tauri::{command, AppHandle, Manager, Url, WebviewWindow};
|
||||
use tauri_plugin_http::reqwest::{ClientBuilder, Request};
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
pub struct DownloadFileParams {
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
use tauri::{
|
||||
image::Image,
|
||||
menu::{MenuBuilder, MenuItemBuilder},
|
||||
tray::{MouseButton, MouseButtonState, TrayIconBuilder, TrayIconEvent},
|
||||
tray::TrayIconBuilder,
|
||||
AppHandle, Manager,
|
||||
};
|
||||
use tauri_plugin_window_state::{AppHandleExt, StateFlags};
|
||||
|
||||
use super::config::PakeConfig;
|
||||
|
||||
pub fn set_system_tray(app: &AppHandle, pake_config: &PakeConfig) -> tauri::Result<()> {
|
||||
pub fn set_system_tray(app: &AppHandle) -> tauri::Result<()> {
|
||||
let hide_app = MenuItemBuilder::with_id("hide_app", "Hide").build(app)?;
|
||||
let show_app = MenuItemBuilder::with_id("show_app", "Show").build(app)?;
|
||||
let quit = MenuItemBuilder::with_id("quit", "Quit").build(app)?;
|
||||
@@ -17,32 +14,7 @@ pub fn set_system_tray(app: &AppHandle, pake_config: &PakeConfig) -> tauri::Resu
|
||||
.build()?;
|
||||
app.app_handle().remove_tray_by_id("pake-tray");
|
||||
let tray = TrayIconBuilder::new()
|
||||
.icon(Image::from_path(pake_config.system_tray_path.as_str())?)
|
||||
.menu(&menu)
|
||||
.on_tray_icon_event(move |tray, event| {
|
||||
if let TrayIconEvent::Click {
|
||||
button: MouseButton::Left,
|
||||
button_state: MouseButtonState::Up,
|
||||
..
|
||||
} = event
|
||||
{
|
||||
println!("click");
|
||||
|
||||
let app = tray.app_handle();
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
{
|
||||
if let Some(webview_window) = app.get_webview_window("pake") {
|
||||
let _ = webview_window.show();
|
||||
let _ = webview_window.set_focus();
|
||||
}
|
||||
}
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
tauri::AppHandle::show(&app.app_handle()).unwrap();
|
||||
}
|
||||
}
|
||||
})
|
||||
.on_menu_event(move |app, event| match event.id().as_ref() {
|
||||
"hide_app" => {
|
||||
app.get_webview_window("pake").unwrap().minimize().unwrap();
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::{path::PathBuf, str::FromStr};
|
||||
use tauri::{App, Url, WebviewUrl, WebviewWindow, WebviewWindowBuilder};
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
use tauri::TitleBarStyle;
|
||||
use tauri::{Theme, TitleBarStyle};
|
||||
|
||||
pub fn get_window(app: &mut App, config: &PakeConfig, _data_dir: PathBuf) -> WebviewWindow {
|
||||
let window_config = config
|
||||
@@ -31,7 +31,6 @@ pub fn get_window(app: &mut App, config: &PakeConfig, _data_dir: PathBuf) -> Web
|
||||
.resizable(window_config.resizable)
|
||||
.fullscreen(window_config.fullscreen)
|
||||
.inner_size(window_config.width, window_config.height)
|
||||
.disable_drag_drop_handler()
|
||||
.always_on_top(window_config.always_on_top)
|
||||
.initialization_script(&config_script)
|
||||
.initialization_script(include_str!("../inject/component.js"))
|
||||
@@ -41,7 +40,6 @@ pub fn get_window(app: &mut App, config: &PakeConfig, _data_dir: PathBuf) -> Web
|
||||
.initialization_script(include_str!("../inject/custom.js"));
|
||||
|
||||
if config.proxy_url != "" {
|
||||
println!("{}", &config.proxy_url);
|
||||
window_builder =
|
||||
window_builder.proxy_url(Url::from_str(&config.proxy_url.as_str()).unwrap());
|
||||
}
|
||||
@@ -53,12 +51,18 @@ pub fn get_window(app: &mut App, config: &PakeConfig, _data_dir: PathBuf) -> Web
|
||||
} else {
|
||||
TitleBarStyle::Visible
|
||||
};
|
||||
window_builder = window_builder.title_bar_style(title_bar_style)
|
||||
window_builder = window_builder.title_bar_style(title_bar_style);
|
||||
|
||||
if window_config.dark_mode {
|
||||
window_builder = window_builder.theme(Some(Theme::Dark));
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
{
|
||||
window_builder = window_builder.data_directory(_data_dir);
|
||||
window_builder = window_builder
|
||||
.data_directory(_data_dir)
|
||||
.title(app.package_info().name.clone());
|
||||
}
|
||||
|
||||
window_builder.build().expect("Failed to build window")
|
||||
|
||||
4
src-tauri/src/inject/style.js
vendored
4
src-tauri/src/inject/style.js
vendored
@@ -342,6 +342,10 @@ window.addEventListener('DOMContentLoaded', _event => {
|
||||
padding-top: 20px;
|
||||
}
|
||||
|
||||
#__next > div.relative.z-0.flex.h-full.w-full.overflow-hidden > div.flex-shrink-0.overflow-x-hidden.bg-token-sidebar-surface-primary > div > div > div > div > nav, #__next > div.relative.z-0.flex.h-full.w-full.overflow-hidden > div.relative.flex.h-full.max-w-full.flex-1.flex-col.overflow-hidden > main {
|
||||
padding-top: 6px;
|
||||
}
|
||||
|
||||
#__next > div.AnnouncementWrapper_container__Z51yh > div > aside.SidebarLayout_sidebar__SXeDJ.SidebarLayout_left__k163a > div > div > header{
|
||||
padding-left: 84px;
|
||||
padding-top: 10px;
|
||||
|
||||
@@ -12,6 +12,9 @@ use tauri_plugin_window_state::Builder as windowStatePlugin;
|
||||
use util::{get_data_dir, get_pake_config};
|
||||
use window::get_window;
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
use std::time::Duration;
|
||||
|
||||
pub fn run_app() {
|
||||
let (pake_config, tauri_config) = get_pake_config();
|
||||
|
||||
@@ -39,7 +42,7 @@ pub fn run_app() {
|
||||
_window.show().unwrap();
|
||||
|
||||
if show_system_tray {
|
||||
let _ = set_system_tray(&app.app_handle(), &pake_config);
|
||||
let _ = set_system_tray(&app.app_handle());
|
||||
} else {
|
||||
app.app_handle().remove_tray_by_id("pake-tray");
|
||||
}
|
||||
@@ -74,14 +77,24 @@ pub fn run_app() {
|
||||
})
|
||||
.on_window_event(|window, event| {
|
||||
if let tauri::WindowEvent::CloseRequested { api, .. } = event {
|
||||
let window = window.clone();
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
window.minimize().unwrap();
|
||||
window.hide().unwrap();
|
||||
let window_handle = window.clone();
|
||||
tauri::async_runtime::spawn(async move {
|
||||
if window_handle.is_fullscreen().unwrap_or(false) {
|
||||
window_handle.set_fullscreen(false).unwrap();
|
||||
// Give a small delay to ensure the full-screen exit operation is completed.
|
||||
tokio::time::sleep(Duration::from_millis(900)).await;
|
||||
}
|
||||
window_handle.minimize().unwrap();
|
||||
window_handle.hide().unwrap();
|
||||
});
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
event.window().close().unwrap();
|
||||
window.close().unwrap();
|
||||
|
||||
api.prevent_close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user