mirror of
https://github.com/RSSNext/Folo.git
synced 2026-10-29 12:12:59 +08:00
- Refactored WebViewManager to improve lifecycle management and state handling. - Introduced a debug panel for monitoring WebView state and actions in development mode. - Updated JavaScript injection methods to use a centralized dispatch system for better maintainability. - Improved handling of local HTML loading and state replay after process termination. - Added new functions for debugging, including state retrieval and flushing pending scripts. This update aims to enhance the overall performance and usability of the WebView component, providing developers with better tools for debugging and state management. Signed-off-by: Innei <tukon479@gmail.com>
45 lines
1022 B
JavaScript
45 lines
1022 B
JavaScript
//
|
|
// at_end.js
|
|
// Pods
|
|
//
|
|
// Created by Innei on 2025/2/6.
|
|
//
|
|
|
|
;(() => {
|
|
const root = document.querySelector("#root")
|
|
let ticking = false
|
|
const handleHeight = () => {
|
|
if (ticking) return
|
|
ticking = true
|
|
setTimeout(() => {
|
|
try {
|
|
window.webkit.messageHandlers.message.postMessage(
|
|
JSON.stringify({
|
|
type: "setContentHeight",
|
|
payload: root?.scrollHeight || document.documentElement.scrollHeight,
|
|
}),
|
|
)
|
|
} finally {
|
|
ticking = false
|
|
}
|
|
}, 16)
|
|
}
|
|
window.addEventListener("load", handleHeight)
|
|
const observer = new ResizeObserver(handleHeight)
|
|
|
|
setTimeout(() => {
|
|
handleHeight()
|
|
}, 1000)
|
|
observer.observe(root)
|
|
|
|
// Fallback: ensure readiness is signaled at end if not yet sent
|
|
if (!window.__FO_WEBVIEW_READY__) {
|
|
try {
|
|
window.__FO_WEBVIEW_READY__ = true
|
|
window.webkit.messageHandlers.message.postMessage(JSON.stringify({ type: "ready" }))
|
|
} catch {
|
|
/* empty */
|
|
}
|
|
}
|
|
})()
|