加固原生壳生产入口门禁

桌面壳深链打开失败改为显式日志记录

移动壳生产导出校验共享主站 URL

原生壳方案文档同步生产入口验收规则
This commit is contained in:
2026-06-20 05:47:44 +08:00
parent 0cac82e982
commit 52526bd2ae
6 changed files with 87 additions and 9 deletions
@@ -1,3 +1,4 @@
use crate::shell::lifecycle::log_desktop_host_event_result;
use crate::shell::tray::show_main_window;
use crate::shell::webview::{desktop_h5_url_with_host_context, WEB_APP_ORIGIN};
use tauri::{Manager, Url, WebviewWindow};
@@ -62,13 +63,17 @@ pub(crate) fn normalize_desktop_deep_link_url(raw_url: &Url) -> Option<Url> {
desktop_h5_url_with_host_context(target_url)
}
fn open_desktop_deep_link_url(window: &WebviewWindow, url: &Url) {
fn open_desktop_deep_link_url(window: &WebviewWindow, url: &Url) -> tauri::Result<()> {
let Some(target_url) = normalize_desktop_deep_link_url(url) else {
return;
return Ok(());
};
let _ = window.navigate(target_url);
let _ = show_main_window(window.app_handle());
window.navigate(target_url)?;
show_main_window(window.app_handle())
}
fn log_desktop_deep_link_open_result(result: tauri::Result<()>) -> bool {
log_desktop_host_event_result("deep_link.open", result)
}
pub(crate) fn register_desktop_deep_link_events(app: &tauri::App) -> tauri::Result<()> {
@@ -79,7 +84,7 @@ pub(crate) fn register_desktop_deep_link_events(app: &tauri::App) -> tauri::Resu
};
for url in event.urls() {
open_desktop_deep_link_url(&window, &url);
log_desktop_deep_link_open_result(open_desktop_deep_link_url(&window, &url));
}
});
@@ -88,7 +93,7 @@ pub(crate) fn register_desktop_deep_link_events(app: &tauri::App) -> tauri::Resu
};
if let Ok(Some(urls)) = app.deep_link().get_current() {
for url in urls {
open_desktop_deep_link_url(&window, &url);
log_desktop_deep_link_open_result(open_desktop_deep_link_url(&window, &url));
}
}
@@ -225,4 +230,12 @@ mod tests {
Some("genarrative")
);
}
#[test]
fn desktop_deep_link_open_result_reports_success_and_failure() {
assert!(log_desktop_deep_link_open_result(Ok(())));
assert!(!log_desktop_deep_link_open_result(Err(
tauri::Error::AssetNotFound("deep-link".to_string())
)));
}
}