🌱 尝试适配linux

https://docs.gtk.org/gio/type_func.Application.id_is_valid.html
This commit is contained in:
BTMuli
2026-01-16 19:38:33 +08:00
parent 00381a092e
commit 79ead78eaf
6 changed files with 15 additions and 9 deletions

View File

@@ -16,7 +16,7 @@ use crate::commands::{
create_window, execute_js, get_dir_size, hide_main_window, init_app, is_in_admin, launch_game,
quit_app, read_text_scale,
};
use tauri::{generate_context, generate_handler, Emitter, Manager, Window, WindowEvent};
use tauri::{Emitter, Manager, Window, WindowEvent, generate_context, generate_handler};
// 子窗口 label 的数组
pub const SUB_WINDOW_LABELS: [&str; 3] = ["Sub_window", "Dev_JSON", "mhy_client"];
@@ -26,7 +26,7 @@ fn window_event_handler(app: &Window, event: &WindowEvent) {
match event {
WindowEvent::CloseRequested { api, .. } => {
api.prevent_close();
if app.label() == "TeyvatGuide" {
if app.label() == "Teyvat.Guide" {
// 主窗口:发送事件让前端根据配置决定是隐藏还是退出
let _ = app.emit("main-window-close-requested", ());
} else {

View File

@@ -7,7 +7,7 @@
#[cfg(target_os = "windows")]
fn enable_dpi_v2() {
use windows_sys::Win32::UI::HiDpi::{
SetProcessDpiAwarenessContext, DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2,
DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2, SetProcessDpiAwarenessContext,
};
unsafe {
@@ -22,8 +22,14 @@ fn main() {
release: sentry::release_name!().into(),
send_default_pii: true,
..Default::default()
}));
},
));
#[cfg(target_os = "windows")]
enable_dpi_v2();
#[cfg(target_os = "linux")]
unsafe {
// Not unsafe if you don't use edition 2024
std::env::set_var("WEBKIT_DISABLE_DMABUF_RENDERER", "1");
}
teyvat_guide_lib::run()
}