ErrorPage.tsx 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import React from 'react';
  2. import { useNavigate } from 'react-router-dom';
  3. import { px2vw, px2vh, px2fluidFontSize } from '@/utils/viewport';
  4. import lumiImage from '@/assets/Lumi-image.png';
  5. import './WelcomePage.css';
  6. /**
  7. * 错误页面组件
  8. * 显示友好的错误信息,并提供返回选项
  9. */
  10. export const ErrorPage: React.FC = () => {
  11. const navigate = useNavigate();
  12. // 跳转到欢迎页面
  13. const handleRefresh = () => {
  14. navigate('/welcome');
  15. };
  16. return (
  17. <div className="mobile-container fixed top-0 left-0 animate-fade-in">
  18. <div className="content-card safe-area-inset relative flex flex-col h-screen overflow-hidden">
  19. {/* 内容容器 - 与 WelcomePage 的 welcome-content 类似 */}
  20. <div className="welcome-content" style={{ position: 'relative', width: '100%', minHeight: 'calc(var(--vh, 1vh) * 100)' }}>
  21. {/* 错误文字和按钮容器 - 位置与 hello 图片一致 */}
  22. <div
  23. style={{
  24. position: 'absolute',
  25. top: '19%',
  26. left: '12%',
  27. width: '65.33%',
  28. }}
  29. >
  30. {/* 错误文字 */}
  31. <h1
  32. className="font-medium text-white"
  33. style={{
  34. fontSize: px2fluidFontSize(31),
  35. lineHeight: px2vh(50),
  36. whiteSpace: 'normal',
  37. wordBreak: 'keep-all',
  38. margin: 0,
  39. marginBottom: px2vh(20),
  40. }}
  41. >
  42. 出错啦,请刷新尝试
  43. </h1>
  44. {/* 刷新尝试按钮 - 在文字下方 */}
  45. <button
  46. type="button"
  47. onClick={handleRefresh}
  48. className="relative text-white font-semibold tracking-[0.5px] transition-all touch-manipulation"
  49. style={{
  50. width: px2vw(163),
  51. height: px2vh(56),
  52. borderRadius: px2vw(100),
  53. backgroundColor: 'transparent',
  54. border: 'none',
  55. display: 'flex',
  56. alignItems: 'center',
  57. justifyContent: 'center',
  58. marginTop: px2vh(20),
  59. }}
  60. aria-label="点击刷新尝试"
  61. >
  62. → 点击刷新尝试
  63. </button>
  64. </div>
  65. </div>
  66. {/* Lumi 图片 - 左下角,与 WelcomePage 样式一致 */}
  67. <img
  68. src={lumiImage}
  69. alt="Lumi"
  70. className="welcome-lumi"
  71. />
  72. </div>
  73. </div>
  74. );
  75. };