feat: 新增工作台模式、系统托盘,修复多平台兼容性问题

1. 新增工作台三栏布局模式,适配宽屏设备
2. 添加跨平台系统托盘支持,新增托盘图标资源
3. 修复工作台模式下导航返回异常问题
4. 统一JSON类型安全解析,替换硬类型转换
5. 增加macOS深度链接支持,统一渠道分发信息
6. 优化部分页面生命周期和状态加载逻辑
7. 移除废弃的nearby_connections依赖
This commit is contained in:
Developer
2026-06-19 06:43:55 +08:00
parent 6a02a313b2
commit 83720002e6
194 changed files with 11716 additions and 3120 deletions

View File

@@ -2,6 +2,7 @@
#include <dwmapi.h>
#include <flutter_windows.h>
#include <shellscalingapi.h>
#include "resource.h"
@@ -216,6 +217,22 @@ Win32Window::MessageHandler(HWND hwnd,
case WM_DWMCOLORIZATIONCOLORCHANGED:
UpdateTheme(hwnd);
return 0;
case WM_GETMINMAXINFO: {
// 处理窗口最小尺寸限制
MINMAXINFO* mmi = reinterpret_cast<MINMAXINFO*>(lparam);
if (min_width_ > 0 && min_height_ > 0) {
// 获取当前 DPI 缩放因子
HMONITOR monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
UINT dpi = FlutterDesktopGetDpiForMonitor(monitor);
double scale_factor = dpi / 96.0;
// 设置最小跟踪尺寸(物理像素)
mmi->ptMinTrackSize.x = static_cast<LONG>(min_width_ * scale_factor);
mmi->ptMinTrackSize.y = static_cast<LONG>(min_height_ * scale_factor);
}
return 0;
}
}
return DefWindowProc(window_handle_, message, wparam, lparam);
@@ -292,3 +309,116 @@ void Win32Window::SetDarkMode(HWND const window, bool dark_mode) {
DwmSetWindowAttribute(window, DWMWA_USE_IMMERSIVE_DARK_MODE,
&enable_dark_mode, sizeof(enable_dark_mode));
}
// ============================================================
// 静态成员变量初始化
// ============================================================
bool Win32Window::fullscreen_ = false;
RECT Win32Window::saved_window_rect_ = {0};
LONG Win32Window::saved_window_style_ = 0;
LONG Win32Window::saved_window_ex_style_ = 0;
WINDOWPLACEMENT Win32Window::saved_placement_ = {sizeof(WINDOWPLACEMENT)};
unsigned int Win32Window::min_width_ = 400;
unsigned int Win32Window::min_height_ = 600;
// ============================================================
// 窗口管理扩展方法实现
// ============================================================
void Win32Window::SetWindowTitle(HWND const window,
const std::wstring& title) {
SetWindowTextW(window, title.c_str());
}
void Win32Window::SetFullscreen(HWND const window, bool fullscreen) {
if (fullscreen == fullscreen_) {
return; // 状态未变化
}
if (fullscreen) {
// 进入全屏:保存当前窗口状态
saved_window_style_ = GetWindowLong(window, GWL_STYLE);
saved_window_ex_style_ = GetWindowLong(window, GWL_EXSTYLE);
GetWindowPlacement(window, &saved_placement_);
GetWindowRect(window, &saved_window_rect_);
// 移除标题栏和边框,设置为全屏样式
LONG new_style = saved_window_style_ & ~WS_OVERLAPPEDWINDOW;
SetWindowLong(window, GWL_STYLE, new_style);
// 获取屏幕尺寸并最大化
HMONITOR monitor = MonitorFromWindow(window, MONITOR_DEFAULTTONEAREST);
MONITORINFO monitor_info;
monitor_info.cbSize = sizeof(monitor_info);
GetMonitorInfo(monitor, &monitor_info);
SetWindowPos(window, HWND_TOP, monitor_info.rcMonitor.left,
monitor_info.rcMonitor.top,
monitor_info.rcMonitor.right - monitor_info.rcMonitor.left,
monitor_info.rcMonitor.bottom - monitor_info.rcMonitor.top,
SWP_NOZORDER | SWP_FRAMECHANGED | SWP_SHOWWINDOW);
fullscreen_ = true;
} else {
// 退出全屏:恢复保存的窗口状态
SetWindowLong(window, GWL_STYLE, saved_window_style_);
SetWindowLong(window, GWL_EXSTYLE, saved_window_ex_style_);
SetWindowPlacement(window, &saved_placement_);
SetWindowPos(window, nullptr, saved_window_rect_.left,
saved_window_rect_.top,
saved_window_rect_.right - saved_window_rect_.left,
saved_window_rect_.bottom - saved_window_rect_.top,
SWP_NOZORDER | SWP_FRAMECHANGED | SWP_SHOWWINDOW);
fullscreen_ = false;
}
}
bool Win32Window::IsFullscreen(HWND const window) {
return fullscreen_;
}
void Win32Window::SetMinSize(HWND const window, unsigned int width,
unsigned int height) {
min_width_ = width;
min_height_ = height;
}
void Win32Window::PerformHapticFeedback(HWND const window, int feedback_type) {
// Windows 无原生触觉反馈,使用 MessageBeep 模拟
// feedback_type: 0=light, 1=medium, 2=heavy, 3=selection
UINT beep_type = MB_OK; // 默认
switch (feedback_type) {
case 0: // light
beep_type = 0xFFFFFFFF; // 简单蜂鸣
break;
case 1: // medium
beep_type = MB_ICONINFORMATION;
break;
case 2: // heavy
beep_type = MB_ICONWARNING;
break;
case 3: // selection
beep_type = 0xFFFFFFFF;
break;
default:
break;
}
MessageBeep(beep_type);
}
std::string Win32Window::GetSystemAppearance() {
DWORD light_mode;
DWORD light_mode_size = sizeof(light_mode);
LSTATUS result = RegGetValue(HKEY_CURRENT_USER,
kGetPreferredBrightnessRegKey,
kGetPreferredBrightnessRegValue,
RRF_RT_REG_DWORD, nullptr, &light_mode,
&light_mode_size);
if (result == ERROR_SUCCESS && light_mode == 0) {
return "dark";
}
return "light";
}