mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-08-07 11:52:34 +00:00
fix(plugins): improve settings layout fetching with native capture function
This commit is contained in:
parent
a44aaf4ef7
commit
835473115f
1 changed files with 13 additions and 6 deletions
|
|
@ -83,21 +83,28 @@ internal object PluginRuntime {
|
|||
val callCode = """
|
||||
(async function() {
|
||||
try {
|
||||
var onSettings = module.exports.onSettings || globalThis.onSettings;
|
||||
if (onSettings) {
|
||||
var onSettings = (typeof module !== 'undefined' && module.exports && module.exports.onSettings) || globalThis.onSettings;
|
||||
if (typeof onSettings === 'function') {
|
||||
var layout = await onSettings();
|
||||
globalThis.__settings_layout_result = JSON.stringify(layout || []);
|
||||
__capture_settings_result(JSON.stringify(layout || []));
|
||||
} else {
|
||||
globalThis.__settings_layout_result = null;
|
||||
__capture_settings_result("[]");
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("onSettings error:", e);
|
||||
globalThis.__settings_layout_result = null;
|
||||
__capture_settings_result("[]");
|
||||
}
|
||||
})();
|
||||
""".trimIndent()
|
||||
|
||||
var captureResult: String? = null
|
||||
jsRuntime.function("__capture_settings_result") { args ->
|
||||
captureResult = args.getOrNull(0)?.toString()
|
||||
null
|
||||
}
|
||||
|
||||
evaluate<Any?>(callCode)
|
||||
resultJson = evaluate<String?>("globalThis.__settings_layout_result")
|
||||
resultJson = captureResult
|
||||
}
|
||||
resultJson
|
||||
} catch (e: Exception) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue