收紧桌面壳主窗口启动门禁
按 label=main 解析 Tauri 主窗口配置并补写宿主上下文 缺少主窗口配置时阻断启动而不是静默跳过 WebView 创建 补充桌面壳配置门禁和 Rust 单测覆盖 同步宿主壳方案文档与共享决策记录
This commit is contained in:
@@ -1560,7 +1560,11 @@ const requiredRustHostSnippets = [
|
||||
'desktop_h5_url_with_host_context(target_url)',
|
||||
'desktop_h5_url_with_host_context(normalized_url)',
|
||||
'desktop_window_config_with_runtime_platform',
|
||||
'desktop_window_config_with_runtime_platform(config)',
|
||||
'DESKTOP_MAIN_WINDOW_LABEL: &str = "main"',
|
||||
'desktop_main_window_config_from_windows',
|
||||
'.find(|window| window.label == DESKTOP_MAIN_WINDOW_LABEL)',
|
||||
'tauri::Error::WindowNotFound',
|
||||
'desktop_main_window_config(app)?',
|
||||
'should_allow_desktop_webview_navigation',
|
||||
'desktop_external_navigation_url',
|
||||
'open_desktop_external_navigation',
|
||||
@@ -1754,6 +1758,7 @@ for (const entrypointOnlySnippet of [
|
||||
for (const appSetupSnippet of [
|
||||
'tauri::Builder::default()',
|
||||
'crate::host_bridge::host_bridge_request',
|
||||
'desktop_main_window_config(app)?',
|
||||
'WebviewWindowBuilder::from_config',
|
||||
]) {
|
||||
if (!app.includes(appSetupSnippet)) {
|
||||
@@ -1761,6 +1766,18 @@ for (const appSetupSnippet of [
|
||||
}
|
||||
}
|
||||
|
||||
for (const blockedAppSetupSnippet of [
|
||||
'app.config().app.windows.get(0)',
|
||||
'app.config().app.windows[0]',
|
||||
'if let Some(config) = window_config',
|
||||
]) {
|
||||
if (app.includes(blockedAppSetupSnippet)) {
|
||||
throw new Error(
|
||||
`desktop shell app.rs must resolve the labeled main window before startup, not ${blockedAppSetupSnippet}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
for (const snippet of requiredRustHostSnippets) {
|
||||
if (!rustHostSource.includes(snippet)) {
|
||||
throw new Error(`desktop shell Rust host bridge missing ${snippet}`);
|
||||
|
||||
Reference in New Issue
Block a user