diff --git a/fair/lib/src/internal/flexbuffer/fair_js_decoder.dart b/fair/lib/src/internal/flexbuffer/fair_js_decoder.dart index ce6e1de9..dd1bbc84 100644 --- a/fair/lib/src/internal/flexbuffer/fair_js_decoder.dart +++ b/fair/lib/src/internal/flexbuffer/fair_js_decoder.dart @@ -17,6 +17,9 @@ class FairJSFairJSDecoderHelper { return beforePath; } if (beforePath.startsWith('http')) { + if (beforePath.endsWith('.json') || beforePath.endsWith('.bin')) { + beforePath = beforePath.replaceFirst(RegExp(r"\.(json|bin)$"), ".js"); + } return beforePath; } else { //加载其它路径判断待定 diff --git a/fair/lib/src/runtime/fair_message_dispatcher.dart b/fair/lib/src/runtime/fair_message_dispatcher.dart index f91713e2..2e1e1c15 100644 --- a/fair/lib/src/runtime/fair_message_dispatcher.dart +++ b/fair/lib/src/runtime/fair_message_dispatcher.dart @@ -55,7 +55,7 @@ class FairHandler { } void register(FairMessageCallback state) { - log('register state: ${state.getMessageKey}'); + log('register state: ${state.getMessageKey()}'); pageHistories[state.getMessageKey()] = state; } diff --git a/fair/lib/src/widget.dart b/fair/lib/src/widget.dart index 2e43a5af..453d7bc9 100644 --- a/fair/lib/src/widget.dart +++ b/fair/lib/src/widget.dart @@ -181,10 +181,13 @@ class FairState extends State with Loader, AutomaticKeepAliveClientM if (mounted) { var name = state2key; var path = widget.path ?? _fairApp!.pathOfBundle(widget.name ?? ''); + if (path?.endsWith('.js') == true) { + path = path?.replaceFirst(RegExp(r"\.(js)$"), ".bin"); + } bundleType = - widget.path != null && widget.path?.startsWith('http') == true - ? 'Http' - : 'Asset'; + widget.path != null && widget.path?.startsWith('http') == true + ? 'Http' + : 'Asset'; parse(context, page: name, url: path, data: widget.data ?? {}) .then((value) { @@ -208,20 +211,21 @@ class FairState extends State with Loader, AutomaticKeepAliveClientM stackTrace: jsSource, highlightLines: [loadJsErrorLineNumber ?? -1], solution: - 'Unsupported JavaScript syntax, please check and correct your Dart method coding!', + 'Unsupported JavaScript syntax, please check and correct your Dart method coding!', ), ); } var builder = widget.holder ?? _fairApp?.placeholderBuilder; var result = _child ?? builder?.call(context); if (!kReleaseMode && _fairApp!.debugShowFairBanner) { - result = _CheckedModeBanner(bundleType??'', child: result??Container()); + result = + _CheckedModeBanner(bundleType ?? '', child: result ?? Container()); } - return result??Container(); + return result ?? Container(); } @override - bool get wantKeepAlive => widget.wantKeepAlive??false; + bool get wantKeepAlive => widget.wantKeepAlive ?? false; /// Implementations of this method should end with a call to the inherited /// method, as in `super.dispose()`. @@ -237,9 +241,9 @@ class FairState extends State with Loader, AutomaticKeepAliveClientM @override void call(String t) { - var params={}; + var params = {}; try { - params= jsonDecode(t); + params = jsonDecode(t); } catch (e) { print(e); } @@ -253,7 +257,7 @@ class FairState extends State with Loader, AutomaticKeepAliveClientM /// Delegate for business logic. The delegate share similar life-circle with [State]. class FairDelegate extends RuntimeFairDelegate { FairState? _state; - late String _key; + late String _key; void _bindState(FairState? state) { assert(state != null, 'FairState should not be null');