export './wechat_env_web.dart'
    if (dart.library.html) './wechat_env_web.dart'
    if (dart.library.io) './wechat_env_native.dart';

import 'package:universal_html/html.dart' as html;

String get kOpenId => getOpenId();

/// 获取当前URL中的OpenId
String getOpenId() {
  // 获取当前URL
  String currentUrl = html.window.location.href;
  // 移除URL中的#号
  currentUrl = currentUrl.replaceAll('#', '');
  // 解析URL
  Uri uri = Uri.parse(currentUrl);
  Map<String, String> queryParams = uri.queryParameters;
  return queryParams['openid'] ?? '';
}
