part of '../../core_app.dart';

const Duration _releaseStartupWatchdogDuration = Duration(seconds: 15);
const Duration _debugStartupWatchdogDuration = Duration(seconds: 15);

// ── 错误提示映射 ──

String _friendlyErrorTitle(WebResourceError error) {
  return switch (error.errorType) {
    WebResourceErrorType.timeout => '请求超时',
    WebResourceErrorType.hostLookup ||
    WebResourceErrorType.connect ||
    WebResourceErrorType.io => '网络连接失败',
    WebResourceErrorType.failedSslHandshake => '安全连接失败',
    _ => '页面加载失败',
  };
}

String _friendlyErrorMessage(WebResourceError error) {
  return switch (error.errorType) {
    WebResourceErrorType.timeout => '当前网络较慢，请稍后重新加载。',
    WebResourceErrorType.hostLookup ||
    WebResourceErrorType.connect ||
    WebResourceErrorType.io => '没有成功连接到服务器，请检查网络后重试。',
    WebResourceErrorType.failedSslHandshake => '当前站点证书校验失败，请稍后再试。',
    _ =>
      error.description.trim().isEmpty
          ? '请稍后重新加载页面。'
          : error.description.trim(),
  };
}
