manager: add external link warning for WebUI#3553
Draft
u9521 wants to merge 4 commits into
Draft
Conversation
Collaborator
Collaborator
|
restructure 和功能改动参在一起不好 review, 另外就是个人觉得弹窗有点多余了 |
Contributor
Author
Contributor
Author
关于重构的问题,之前试过直接改,问题有点多。 弹窗功能确实值得商榷,主要是有人提了个webui跳转外链ksu接口暴露的问题,就写了个弹窗,但是还有一点问题,页面内的iframe也是能用到接口的。跳转外链去接口也会有一些问题。弹窗也算是个折中的方案。 最后的想法是把外部内容全禁掉,设置里面加个开关允许webui加载外部内容,再后续把开关删了。 |
u9521
marked this pull request as draft
July 20, 2026 03:14
clean Model-View-Intent (MVI) architecture with unidirectional data flow. Architecture changes: - Introduce WebUIViewModel as the single owner of state and effects - Replace mutable WebUIState with an @immutable data class driven by StateFlow, ensuring correct Compose recomposition skipping - Define WebUIIntent as a sealed interface for all user/system actions - Define WebUIEffect (SharedFlow) for one-shot side effects such as Toast, finish, file chooser launch, and JS evaluation - Extract WebUIRuntime to hold platform objects (WebView, Shell, FileCallback) that cannot be part of immutable state Package restructuring: - bridge/ - WebViewInterface (JS bridge) - model/ - Insets, WebUIState, WebUIIntent, WebUIEffect, WebUIOverlay - runtime/ - WebUIRuntime - ui/ - WebUIScreen, WebUILoading, WebUIEventHandler, WebUIEventsMaterial, WebUIEventsMiuix, WebUILifecycle, WebViewContainer - util/ - MimeUtil, WebUIExtensions - viewmodel/ - WebUIViewModel - webview/ - WebViewClients, WebViewConstants, WebViewFactory, WebViewPreparer - webview/asset/ - MonetColorsProvider, SuFilePathHandler Other improvements: - Add displayCutout union to systemBars insets for better cutout handling - Wrap WebUI content in theme-aware Surface (Material3 / Miuix) so the background color is provided by the theme instead of being manually set on each composable - Move JS dialog state (alert/confirm/prompt) from JsResult stored in state to pending fields in ViewModel, keeping only display data in the overlay sealed interface - Move file chooser flow from UI event to effect, launching via ActivityResultLauncher from the Activity's effect collector - Extract LoadingContent into standalone WebUILoading composable - Extract WebView creation, constants, and client setup into dedicated files under webview/ Signed-off-by: u9521 <63995396+u9521@users.noreply.github.com>
Intercept navigation away from trusted WebUI and local loopback origins instead of loading external destinations in the embedded WebView. Present a localized warning screen in both Material and Miuix modes, allowing users to return to the WebUI or explicitly open the URL in an external browser. Track the flow through WebUI state, intents, and effects, pause the WebView while the warning is displayed, and make the system back action dismiss it first. Handle missing browser applications with a toast and read the WebView debugging preference through SettingsRepository.
Use a buffered channel for one-shot effects, reset transient state when a module becomes ready, and allow local URL schemes inside the WebView. Also make WebView assignment observable and clean up external-link warning state after its exit animation. Signed-off-by: u9521 <63995396+u9521@users.noreply.github.com>
Signed-off-by: u9521 <63995396+u9521@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


refactor WebUI, add a warning before opening links outside the module WebUI, and provide an opt-in setting for loading external WebUI content