统一桌面外链打开 helper
让桌面 WebView 外链和 HostBridge 外链共用 opener helper 用配置检查禁止 HostBridge 直接调用 opener 同步桌面壳外链 helper 共用决策记录
This commit is contained in:
@@ -83,6 +83,14 @@ const desktopShellNetworkSource = fs.readFileSync(
|
||||
desktopShellNetworkPath,
|
||||
'utf8',
|
||||
);
|
||||
const desktopShellNavigationPath = new URL(
|
||||
'../src-tauri/src/shell/navigation.rs',
|
||||
import.meta.url,
|
||||
);
|
||||
const desktopShellNavigationSource = fs.readFileSync(
|
||||
desktopShellNavigationPath,
|
||||
'utf8',
|
||||
);
|
||||
const productionSourceRoots = [
|
||||
new URL('../package.json', import.meta.url),
|
||||
new URL('../src-tauri/Cargo.toml', import.meta.url),
|
||||
@@ -1589,6 +1597,26 @@ if (desktopHostBridgeDispatchSource.includes('json!(HostBridgeRuntime {')) {
|
||||
throw new Error('desktop shell host.getRuntime must be built by desktop_runtime()');
|
||||
}
|
||||
|
||||
if (
|
||||
!desktopShellNavigationSource.includes('pub(crate) fn open_normalized_desktop_external_url') ||
|
||||
!desktopShellNavigationSource.includes(
|
||||
'open_normalized_desktop_external_url(app, external_url)',
|
||||
)
|
||||
) {
|
||||
throw new Error(
|
||||
'desktop shell WebView external navigation must use the shared external opener helper',
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
!desktopHostBridgeDispatchSource.includes('open_normalized_desktop_external_url(&app, url)') ||
|
||||
desktopHostBridgeDispatchSource.includes('app.opener().open_url(')
|
||||
) {
|
||||
throw new Error(
|
||||
'desktop shell app.openExternalUrl must use the shared external opener helper',
|
||||
);
|
||||
}
|
||||
|
||||
if (config.build?.frontendDist !== '../../../dist') {
|
||||
throw new Error('desktop shell must package the root H5 dist');
|
||||
}
|
||||
@@ -1930,6 +1958,7 @@ const requiredRustHostSnippets = [
|
||||
'desktop_main_window_config(app)?',
|
||||
'should_allow_desktop_webview_navigation',
|
||||
'desktop_external_navigation_url',
|
||||
'open_normalized_desktop_external_url',
|
||||
'open_desktop_external_navigation',
|
||||
'.on_navigation(move |url|',
|
||||
'.on_new_window(move |url, _features|',
|
||||
|
||||
Reference in New Issue
Block a user