feat: 优化 URL 生成逻辑并添加同步品牌信息功能
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@@ -124,7 +125,6 @@ class _H5ShellPageState extends State<H5ShellPage> with WidgetsBindingObserver {
|
||||
WidgetsBinding.instance.addObserver(this);
|
||||
_homeUrl = AppConfig.homeUrl(
|
||||
appName: widget.shellBranding.appName,
|
||||
appLogo: widget.shellBranding.appLogo,
|
||||
);
|
||||
_controller = _buildController()..loadRequest(Uri.parse(_homeUrl));
|
||||
}
|
||||
@@ -187,6 +187,7 @@ class _H5ShellPageState extends State<H5ShellPage> with WidgetsBindingObserver {
|
||||
}
|
||||
},
|
||||
onPageFinished: (_) {
|
||||
unawaited(_syncShellBranding());
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_progress = 100;
|
||||
@@ -253,6 +254,23 @@ class _H5ShellPageState extends State<H5ShellPage> with WidgetsBindingObserver {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _syncShellBranding() {
|
||||
final payload = jsonEncode({
|
||||
'name': widget.shellBranding.appName,
|
||||
'logo': widget.shellBranding.appLogo,
|
||||
});
|
||||
final script = '''
|
||||
(() => {
|
||||
try {
|
||||
const brand = $payload;
|
||||
window.sessionStorage.setItem('OPENIM_FLUTTER_SHELL_BRAND', JSON.stringify(brand));
|
||||
window.dispatchEvent(new CustomEvent('openim-shell-branding-updated', { detail: brand }));
|
||||
} catch (_) {}
|
||||
})();
|
||||
''';
|
||||
return _runJavaScriptSafely(script);
|
||||
}
|
||||
|
||||
Future<void> _stopWebMedia() {
|
||||
return _runJavaScriptSafely(_stopWebMediaScript);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user