addScript method
添加脚本文件
Implementation
@override
Future<dynamic> addScript(String pageName, String scriptSource, dynamic props) async {
// var scriptSource = await rootBundle.loadString(script);
var fairProps;
if (props != null && props['fairProps'] != null) {
fairProps = props['fairProps'];
} else {
fairProps = '{}';
}
if (fairProps is String) {
fairProps = fairProps.replaceAll('\\', '\\\\');
}
scriptSource = scriptSource.replaceFirst(RegExp(r'#FairProps#'), fairProps);
scriptSource = scriptSource.replaceAll(RegExp(r'#FairKey#'), pageName);
var map = <dynamic, dynamic>{};
map[FairMessage.PATH] = scriptSource;
map[FairMessage.PAGE_NAME] = pageName;
return _channel!.loadJS(jsonEncode(map), null);
}