123456789101112131415161718192021222324252627282930313233 |
- import 'package:universal_html/html.dart' as html;
- ///获取参数类
- class ParameterHelper {
- ///参数集,第二窗口使用
- static Map<String, String> parameterMap = {};
- ///Url带的参数
- static String searchUrl = '';
- ///获取App启动参数
- static Map<String, String> getAppStartParameters() {
- Map<String, String> map = {};
- var url = html.window.location.toString();
- final parameters = url.split('?');
- if (parameters.length > 1) {
- final parameterStr = parameters[1];
- final keyValues = parameterStr.split('&');
- for (var kv in keyValues) {
- final keyValue = kv.split('=');
- map[keyValue[0]] = keyValue[1];
- }
- if (map.isNotEmpty) {
- parameterMap = map;
- searchUrl = url;
- html.window.history.replaceState('', '', url);
- return map;
- }
- }
- return {};
- }
- }
|