feat(client): 改进启动窗口、维护交互与操作图标
- feat(client): 增加无边框动画启动窗口,加载完成后恢复主窗口 - feat(ui): 为操作按钮引入本地 Material Symbols Rounded 图标 - fix(maintenance): 移除烧录前无效的原生确认框,保留页面检查与后端校验 - fix(maintenance): 统一板卡示意风格并修正装甲板比例和图传右侧 USB 接线 - docs: 按 humanizer-zh 润色项目文档并将写作约定纳入 AGENTS.md 验证:前端构建、Tauri 主机编译与启动配置测试通过;维护流程 4 项测试通过;目录回归 4 项通过。已检查浏览器受影响页面与 Windows 原生启动窗口切换。 未执行设备烧录、板上运行或多显示器与高 DPI 验证。
This commit is contained in:
52 files changed
+965
-440
No files matched your search
@@ -30,6 +30,7 @@ mod firmware_build;
|
||||
mod recording;
|
||||
mod server;
|
||||
mod state;
|
||||
mod startup;
|
||||
|
||||
use std::error::Error;
|
||||
use std::path::PathBuf;
|
||||
@@ -310,8 +311,11 @@ fn run() -> Result<(), Box<dyn Error>> {
|
||||
.plugin(tauri_plugin_dialog::init())
|
||||
.manage(Arc::clone(&state))
|
||||
.manage(latency_recorder)
|
||||
.manage(startup::StartupState::default())
|
||||
.manage(Arc::new(maintenance::MaintenanceState::default()))
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
startup::finish_startup,
|
||||
startup::cancel_startup,
|
||||
maintenance::maintenance_list_ports,
|
||||
maintenance::maintenance_load_bundle,
|
||||
maintenance::maintenance_probe,
|
||||
@@ -375,7 +379,8 @@ fn run() -> Result<(), Box<dyn Error>> {
|
||||
}
|
||||
let state = window.state::<Arc<AppState>>();
|
||||
|
||||
if state.config().role.needs_password() && !state.is_unlocked() {
|
||||
if window.state::<startup::StartupState>().finished()
|
||||
&& state.config().role.needs_password() && !state.is_unlocked() {
|
||||
api.prevent_close();
|
||||
state.push(server::WireMsg::ConfirmQuit);
|
||||
}
|
||||
@@ -392,7 +397,8 @@ fn run() -> Result<(), Box<dyn Error>> {
|
||||
}
|
||||
let state = app.state::<Arc<AppState>>();
|
||||
|
||||
if state.config().role.needs_password() && !state.is_unlocked() {
|
||||
if app.state::<startup::StartupState>().finished()
|
||||
&& state.config().role.needs_password() && !state.is_unlocked() {
|
||||
api.prevent_exit();
|
||||
state.push(server::WireMsg::ConfirmQuit);
|
||||
return;
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
//! 同一个窗口先显示无边框启动卡片,准备完成后恢复桌面窗口。
|
||||
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
|
||||
use tauri::{LogicalSize, Manager, State, WebviewWindow};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct StartupState {
|
||||
finished: AtomicBool,
|
||||
}
|
||||
|
||||
impl StartupState {
|
||||
pub fn finished(&self) -> bool {
|
||||
self.finished.load(Ordering::Acquire)
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn finish_startup(window: WebviewWindow, state: State<'_, StartupState>) -> Result<(), String> {
|
||||
if state.finished() {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
// 隐藏期间恢复边框和尺寸,避免启动卡片随最大化过程被拉伸。
|
||||
window.hide().map_err(|err| err.to_string())?;
|
||||
let result = (|| -> tauri::Result<()> {
|
||||
window.set_fullscreen(false)?;
|
||||
window.set_decorations(true)?;
|
||||
window.set_resizable(true)?;
|
||||
window.set_min_size(Some(LogicalSize::new(900.0, 600.0)))?;
|
||||
window.set_size(LogicalSize::new(1440.0, 900.0))?;
|
||||
window.center()?;
|
||||
Ok(())
|
||||
})();
|
||||
// 即使窗口设置失败,也要重新显示错误和重试入口。
|
||||
let shown = window.show();
|
||||
result.and(shown).map_err(|err| err.to_string())?;
|
||||
// 显示后再请求最大化,避免 Windows 隐藏窗口只更新最大化标志。
|
||||
window.maximize().map_err(|err| err.to_string())?;
|
||||
state.finished.store(true, Ordering::Release);
|
||||
let _ = window.set_focus();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn cancel_startup(window: WebviewWindow, state: State<'_, StartupState>) -> Result<(), String> {
|
||||
if state.finished() {
|
||||
return Err("启动已完成,请从主界面退出。".into());
|
||||
}
|
||||
if window
|
||||
.state::<std::sync::Arc<crate::maintenance::MaintenanceState>>()
|
||||
.is_busy()
|
||||
{
|
||||
return Err("固件维护正在进行,请等待完成。".into());
|
||||
}
|
||||
window.app_handle().exit(0);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn initial_window_is_a_compact_frameless_splash() {
|
||||
let config: serde_json::Value =
|
||||
serde_json::from_str(include_str!("../tauri.conf.json")).unwrap();
|
||||
let window = &config["app"]["windows"][0];
|
||||
assert_eq!(window["label"], "main");
|
||||
assert_eq!(window["decorations"], false);
|
||||
assert_eq!(window["maximized"], false);
|
||||
assert_eq!(window["resizable"], false);
|
||||
assert_eq!(window["center"], true);
|
||||
assert!(window["width"].as_u64().unwrap() <= 700);
|
||||
assert!(window["height"].as_u64().unwrap() <= 500);
|
||||
}
|
||||
}
|
||||
@@ -14,12 +14,12 @@
|
||||
{
|
||||
"label": "main",
|
||||
"title": "RMIC::2026",
|
||||
"width": 1440,
|
||||
"height": 900,
|
||||
"minWidth": 900,
|
||||
"minHeight": 600,
|
||||
"maximized": true,
|
||||
"resizable": true,
|
||||
"width": 640,
|
||||
"height": 420,
|
||||
"center": true,
|
||||
"decorations": false,
|
||||
"maximized": false,
|
||||
"resizable": false,
|
||||
"fullscreen": false
|
||||
}
|
||||
],
|
||||
|
||||
Reference in new issue
Block a user