Zzx/feature/webview kmp - #591
Conversation
Initialize the Desktop JCEF runtime and provide platform bridge hosts for Desktop and iOS.
将 mine 模块的 IAboutService 迁移至 login:api 的 ILegalNoticeService, 消除重复的跳转服务定义;同时统一 WebView 默认标题与返回逐级回退逻辑。
There was a problem hiding this comment.
🟡 Changes recommended
It introduces a confirmed WebView title fallback bug in AppScheme.jumpHttp and expands cross-platform WebView security exposure (ATS relaxation + unrestricted bridge origins) that should be tightened before merge.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR introduces a new KMP-friendly “universal WebView” navigation entry (backed by MultiWeb) and consolidates legal notice (user agreement / privacy policy) navigation to use AppScheme-based routing across platforms, while also cleaning up legacy Android-only WebView / service glue and renaming webView packages to webview.
Changes:
- Add
cyxbs://webviewroute +WebViewNavArgument/WebViewScreen, and rerouteAppScheme.jump(http/https)through it. - Unify user agreement / privacy policy via
ILegalNoticeService(commonMain) and URLs inWebsiteConfig, removing AndroidLegalNoticeActivityand the mine-sideIAboutService. - Introduce MultiWeb platform hosts (Android/iOS/Desktop/Web) plus Desktop JCEF runtime bootstrap; update callers/imports/layouts to the new
webviewpackage.
File summaries
| File | Description |
|---|---|
| gradle/libs.versions.toml | Add MultiWeb version + compose artifact alias. |
| cyxbs-pages/notification/src/androidMain/res/layout/notification_activity_web.xml | Update LiteJsWebView class package path (webview). |
| cyxbs-pages/notification/src/androidMain/kotlin/com/cyxbs/pages/notification/ui/activity/WebActivity.kt | Update LiteJsWebView import package (webview). |
| cyxbs-pages/mine/src/commonMain/kotlin/com/cyxbs/pages/mine/sign/ui/SignScreen.kt | Replace systemBarsPadding() with statusBarsPadding(). |
| cyxbs-pages/mine/src/commonMain/kotlin/com/cyxbs/pages/mine/about/ui/AboutNavEntry.kt | Switch “user agreement / privacy policy” actions to ILegalNoticeService. |
| cyxbs-pages/mine/src/commonMain/kotlin/com/cyxbs/pages/mine/about/service/IAboutService.kt | Remove mine-specific About service interface. |
| cyxbs-pages/mine/src/androidMain/res/layout/mine_activity_feedback_detail.xml | Update LiteJsWebView class package path (webview). |
| cyxbs-pages/mine/src/androidMain/kotlin/com/cyxbs/pages/mine/service/AboutServiceImpl.kt | Remove Android implementation of removed IAboutService. |
| cyxbs-pages/mine/src/androidMain/kotlin/com/cyxbs/pages/mine/page/feedback/center/ui/FeedbackDetailActivity.kt | Update LiteJsWebView import package (webview). |
| cyxbs-pages/map/src/commonMain/kotlin/com/cyxbs/pages/map/widget/MapWidget.kt | Move anchor scaling computation into graphicsLayer draw scope. |
| cyxbs-pages/map/src/commonMain/kotlin/com/cyxbs/pages/map/viewmodel/MapComposeViewModel.kt | Guard initFocus to run once per VM instance. |
| cyxbs-pages/map/src/commonMain/kotlin/com/cyxbs/pages/map/ui/MapSheetNavEntry.kt | Formatting-only change. |
| cyxbs-pages/login/src/commonMain/kotlin/com/cyxbs/pages/login/viewmodel/LoginViewModel.kt | Route agreement/privacy clicks through ILegalNoticeService in commonMain. |
| cyxbs-pages/login/src/commonMain/kotlin/com/cyxbs/pages/login/service/LegalNoticeServiceImpl.kt | New commonMain ILegalNoticeService impl that jumps to URLs via AppScheme. |
| cyxbs-pages/login/src/androidMain/res/layout/login_activity_privacy.xml | Remove legacy Android WebView layout for legal notice activity. |
| cyxbs-pages/login/src/androidMain/kotlin/com/cyxbs/pages/login/viewmodel/LoginViewModel.android.kt | Remove Android overrides for legal notice navigation (now commonMain). |
| cyxbs-pages/login/src/androidMain/kotlin/com/cyxbs/pages/login/ui/LegalNoticeActivity.kt | Remove legacy Android activity-based legal notice WebView. |
| cyxbs-pages/login/src/androidMain/kotlin/com/cyxbs/pages/login/service/LegalNoticeServiceImpl.kt | Remove Android-only service impl that launched LegalNoticeActivity. |
| cyxbs-pages/login/src/androidMain/AndroidManifest.xml | Remove LegalNoticeActivity registration (manifest now empty). |
| cyxbs-pages/login/api/src/commonMain/kotlin/com/cyxbs/pages/login/api/ILegalNoticeService.kt | Introduce commonMain ILegalNoticeService with “open*Screen” APIs. |
| cyxbs-pages/login/api/src/androidMain/kotlin/com/cyxbs/pages/login/api/ILegalNoticeService.kt | Remove AndroidMain-only interface variant with “start*Activity” APIs. |
| cyxbs-pages/grades/src/androidMain/res/layout/grades_activity_container.xml | Update LiteJsWebView class package path (webview). |
| cyxbs-pages/grades/src/androidMain/kotlin/com/cyxbs/pages/grades/ui/main/ContainerActivity.kt | Update LiteJsWebView import package (webview). |
| cyxbs-pages/discover/src/commonMain/kotlin/com/cyxbs/pages/discover/home/DiscoverPage.kt | Add cross-platform banner click fallback that appends default title + jumps via AppScheme. |
| cyxbs-pages/discover/src/androidMain/kotlin/com/cyxbs/pages/discover/pages/discover/DiscoverNavPlatformImpl.kt | Update default-title query key to WebViewNavArgument.DEFAULT_TITLE_QUERY_PARAMETER. |
| cyxbs-components/navigation/src/webMain/kotlin/com/cyxbs/components/navigation/SchemeUtils.web.kt | Remove legacy per-platform jumpHttp stub (no longer used). |
| cyxbs-components/navigation/src/iosMain/kotlin/com/cyxbs/components/navigation/SchemeUtils.ios.kt | Remove legacy per-platform jumpHttp stub (no longer used). |
| cyxbs-components/navigation/src/desktopMain/kotlin/com/cyxbs/components/navigation/SchemeUtils.desktop.kt | Remove legacy per-platform jumpHttp stub (no longer used). |
| cyxbs-components/navigation/src/commonMain/kotlin/com/cyxbs/components/navigation/NavigationTable.kt | Add NAV_WEBVIEW route constant. |
| cyxbs-components/navigation/src/commonMain/kotlin/com/cyxbs/components/navigation/AppScheme.kt | Implement http(s) handling by routing to cyxbs://webview with query parameters. |
| cyxbs-components/navigation/src/androidMain/kotlin/com/cyxbs/components/navigation/SchemeUtils.android.kt | Remove legacy Android WebViewFactory + jumpHttp actual implementation. |
| cyxbs-components/config/src/commonMain/kotlin/com/cyxbs/components/config/WebsiteConfig.kt | Add USER_AGREEMENT_URL and PRIVACY_POLICY_URL constants (hideTitle=true). |
| cyxbs-components/base/src/webMain/kotlin/com/cyxbs/components/base/webview/WebViewPlatformHost.web.kt | Add web platform host (currently no-op / default init). |
| cyxbs-components/base/src/iosMain/kotlin/com/cyxbs/components/base/webview/WebViewPlatformHost.ios.kt | Add iOS MultiWeb host with navigation policy + legacy bridge handling. |
| cyxbs-components/base/src/desktopMain/kotlin/com/cyxbs/components/base/webview/WebViewPlatformHost.desktop.kt | Add Desktop MultiWeb host with EDT dispatching + bridge handling. |
| cyxbs-components/base/src/desktopMain/kotlin/com/cyxbs/components/base/webview/DesktopWebViewRuntime.kt | Add Desktop JCEF runtime/bootstrap helpers for MultiWeb. |
| cyxbs-components/base/src/commonMain/kotlin/com/cyxbs/components/base/webview/WebViewScreen.kt | New common WebView UI (top bar, back handling, fullscreen awareness). |
| cyxbs-components/base/src/commonMain/kotlin/com/cyxbs/components/base/webview/WebViewPlatformHost.kt | New expect/actual platform host contract for WebView page. |
| cyxbs-components/base/src/commonMain/kotlin/com/cyxbs/components/base/webview/WebViewNavEntry.kt | New AppNav entry for NAV_WEBVIEW. |
| cyxbs-components/base/src/commonMain/kotlin/com/cyxbs/components/base/webview/WebViewNavArgument.kt | New serializable argument for WebView routing and defaults. |
| cyxbs-components/base/src/androidMain/kotlin/com/cyxbs/components/base/webview/WebViewPlatformHost.android.kt | Add Android MultiWeb host + legacy bridge capability mapping (sensor/save/fullscreen). |
| cyxbs-components/base/src/androidMain/kotlin/com/cyxbs/components/base/webview/WebViewBaseCallBack.kt | Rename package to webview. |
| cyxbs-components/base/src/androidMain/kotlin/com/cyxbs/components/base/webView/WebViewActivity.kt | Remove legacy Android activity-based WebView implementation. |
| cyxbs-components/base/src/androidMain/kotlin/com/cyxbs/components/base/webview/LiteJsWebView.kt | Rename package to webview (legacy WebView still used by some XML screens). |
| cyxbs-components/base/src/androidMain/kotlin/com/cyxbs/components/base/webview/IAndroidWebView.kt | Rename package to webview. |
| cyxbs-components/base/src/androidMain/kotlin/com/cyxbs/components/base/webview/AndroidWebViewSensorExtension.kt | New sensor extension bridging sensor values to JS via MultiWeb controller. |
| cyxbs-components/base/src/androidMain/kotlin/com/cyxbs/components/base/webview/AndroidWebViewImageSaver.kt | New image-save flow (permission + confirm + download + MediaScanner) for bridge. |
| cyxbs-components/base/src/androidMain/kotlin/com/cyxbs/components/base/webview/AndroidWebView.kt | Rename package to webview. |
| cyxbs-components/base/src/androidMain/AndroidManifest.xml | Remove legacy WebViewActivity activity registration. |
| cyxbs-components/base/build.gradle.kts | Add MultiWeb compose dependency to base commonMain. |
| cyxbs-applications/test/AppNav.md | Document new webview deeplink route + argument type. |
| cyxbs-applications/pro/AppNav.md | Document new webview deeplink route + argument type. |
| cyxbs-applications/multiplatform/src/desktopMain/kotlin/CyxbsDesktopApp.kt | Initialize/bind/request MultiWeb Desktop runtime lifecycle on app start/exit. |
| cyxbs-applications/multiplatform/iosApp/iosApp/Info.plist | Add ATS relaxation for WebView content. |
| cyxbs-applications/multiplatform/iosApp/iosApp.xcodeproj/project.pbxproj | Skip Gradle build phase when OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED=YES. |
| build.gradle.kts | Trailing whitespace-only cleanup. |
Review details
- Files reviewed: 54/56 changed files
- Comments generated: 5
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| private val bridgeExtension = NativeWebViewBridgeExtension( | ||
| originPolicy = ScriptBridgeOriginPolicy.UnsafeAnyHttpOrHttps, | ||
| host = this, | ||
| enableLegacyJavaScriptExecution = true, | ||
| ) |
| private val bridgeExtension = NativeWebViewBridgeExtension( | ||
| originPolicy = ScriptBridgeOriginPolicy.UnsafeAnyHttpOrHttps, | ||
| host = this, | ||
| enableLegacyJavaScriptExecution = true, | ||
| ) |
| <key>NSAppTransportSecurity</key> | ||
| <dict> | ||
| <key>NSAllowsArbitraryLoadsInWebContent</key> | ||
| <true/> | ||
| </dict> |
| private val bridgeExtension = NativeWebViewBridgeExtension( | ||
| originPolicy = ScriptBridgeOriginPolicy.UnsafeAnyHttpOrHttps, | ||
| host = this, | ||
| enableLegacyJavaScriptExecution = true, | ||
| ) |
| .appendQueryParameter( | ||
| "defaultTitle", | ||
| uri.getQueryParameter("defaultTitle") ?: DEFAULT_WEB_VIEW_TITLE, | ||
| ) |
原逻辑始终拼接 defaultTitle 参数,无值时写入空串,导致 WebViewNavArgument 的默认值“网页”被覆盖,网页自身也无标题时标题栏空白。改为与 title 一致, 仅当原始 URL 真正携带该参数时才追加。
No description provided.