ShareSuccessPage.tsx 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. import { useEffect, useState } from 'react';
  2. import { useNavigate } from 'react-router-dom';
  3. import { setStorage, STORAGE_KEYS, getUserId, getVisitedRoutes, loadBackgroundImageConfig, getBackgroundImageUrlByIdSync } from '@/utils/storage';
  4. import { updateUserUIState } from '@/utils/api';
  5. import { px2vmin } from '@/utils/viewport';
  6. import { getOssUrl } from '@/utils/oss';
  7. // const fullProgressBar = getOssUrl('full-progress-bar.png'); // Unused
  8. const avatarAnimaZone = getOssUrl('Avatar-anima-zone-cap.png');
  9. const continueChatBtn = getOssUrl('continue-chat.png');
  10. // 新年背景图片 ID
  11. const NEW_YEAR_BACKGROUND_IMAGE_ID = 'happynewyear';
  12. export const ShareSuccessPage = () => {
  13. const navigate = useNavigate();
  14. const [backgroundImageUrl, setBackgroundImageUrl] = useState<string>('');
  15. useEffect(() => {
  16. // 记录用户当前所在页面
  17. setStorage(STORAGE_KEYS.CURRENT_PAGE, 'share-success');
  18. const visited = getVisitedRoutes();
  19. const userId = getUserId();
  20. if (userId) {
  21. updateUserUIState(userId, {
  22. current_page: 'share-success',
  23. visited_routes: visited,
  24. }).catch(() => {
  25. // 同步失败不影响前端流程
  26. });
  27. }
  28. // 加载背景图片配置并获取新年背景图片 URL
  29. const loadBackgroundImage = async () => {
  30. try {
  31. await loadBackgroundImageConfig();
  32. const url = getBackgroundImageUrlByIdSync(NEW_YEAR_BACKGROUND_IMAGE_ID);
  33. if (url) {
  34. setBackgroundImageUrl(url);
  35. } else {
  36. console.warn(`[ShareSuccessPage] 未找到背景图片: ${NEW_YEAR_BACKGROUND_IMAGE_ID}`);
  37. }
  38. } catch (error) {
  39. console.error('[ShareSuccessPage] 加载背景图片配置失败:', error);
  40. }
  41. };
  42. loadBackgroundImage();
  43. }, []);
  44. const handleContinueChat = () => {
  45. navigate('/chatbot');
  46. };
  47. return (
  48. <div
  49. style={{
  50. position: 'fixed',
  51. top: 0,
  52. left: 0,
  53. width: '100vw',
  54. height: '100vh',
  55. backgroundImage: backgroundImageUrl ? `url(${backgroundImageUrl})` : 'none',
  56. backgroundSize: 'cover',
  57. backgroundPosition: 'center',
  58. backgroundRepeat: 'no-repeat',
  59. overflow: 'hidden',
  60. }}
  61. >
  62. {/* 顶部进度条 */}
  63. <img
  64. src={getOssUrl('03-two-gift.gif')}
  65. alt="full progress bar"
  66. style={{
  67. position: 'absolute',
  68. left: '50%',
  69. top: px2vmin(64),
  70. width: px2vmin(195),
  71. transform: 'translateX(-50%)',
  72. }}
  73. />
  74. {/* 中部头像动画区域 */}
  75. <img
  76. src={avatarAnimaZone}
  77. alt="avatar anima zone"
  78. style={{
  79. position: 'absolute',
  80. left: '50%',
  81. top: px2vmin(192),
  82. width: px2vmin(343),
  83. transform: 'translateX(-50%)',
  84. }}
  85. />
  86. {/* 标题文案 */}
  87. <div
  88. style={{
  89. position: 'absolute',
  90. left: '50%',
  91. top: px2vmin(504),
  92. transform: 'translateX(-50%)',
  93. color: '#FFFFFF',
  94. fontSize: px2vmin(24),
  95. fontWeight: 'bold',
  96. whiteSpace: 'nowrap',
  97. }}
  98. >
  99. Happy New Year!
  100. </div>
  101. {/* 描述文案 */}
  102. <div
  103. style={{
  104. position: 'absolute',
  105. left: '50%',
  106. top: px2vmin(552),
  107. transform: 'translateX(-50%)',
  108. color: '#FFFFFF',
  109. fontSize: px2vmin(14),
  110. textAlign: 'center',
  111. width: px2vmin(230),
  112. }}
  113. >
  114. 感谢你将 Lumi 分享给更多朋友!新年限定背景已为你点亮,快带着新气象和 Lumi 继续新年的第一次对话吧
  115. </div>
  116. {/* 继续对话按钮 */}
  117. <button
  118. type="button"
  119. onClick={handleContinueChat}
  120. style={{
  121. position: 'absolute',
  122. left: '50%',
  123. top: px2vmin(656),
  124. transform: 'translateX(-50%)',
  125. border: 'none',
  126. padding: 0,
  127. background: 'none',
  128. width: px2vmin(279),
  129. }}
  130. >
  131. <img
  132. src={continueChatBtn}
  133. alt="Continue to chat"
  134. style={{
  135. width: '100%',
  136. display: 'block',
  137. }}
  138. />
  139. </button>
  140. </div>
  141. );
  142. };