ProfilePage.tsx 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634
  1. import { useEffect, useState, useCallback, useRef } from 'react';
  2. import { useNavigate } from 'react-router-dom';
  3. import { useTranslation } from 'react-i18next';
  4. import { px2vmin, px2vmax, px2vw } from '@/utils/viewport';
  5. import {
  6. getUserInfo,
  7. updateUsername,
  8. updateBotName,
  9. getUserUIState,
  10. updateUserUIState,
  11. // 统一的 API 工具:包含 userId/token 头部和与 ws 一致的 base URL 推导
  12. getApiBaseUrl,
  13. getApiHeaders,
  14. } from '@/utils/api';
  15. import {
  16. getUserId,
  17. getStorage,
  18. setStorage,
  19. STORAGE_KEYS,
  20. setCurrentAvatarId as setAvatarIdToStorage,
  21. setCurrentBackgroundImageId as setBackgroundImageIdToStorage,
  22. getCurrentBackgroundImageId,
  23. clearUserSessionAndRedirectToBegin,
  24. } from '@/utils/storage';
  25. import { getOssUrl } from '@/utils/oss';
  26. import { MissionEnergyStoneModal } from '@/components/MissionEnergyStoneModal';
  27. import { UserAgreementModal } from '@/components/UserAgreementModal';
  28. import { PrivacyPolicyModal } from '@/components/PrivacyPolicyModal';
  29. const closeBtn = getOssUrl('close-btn.png');
  30. const editIcon = getOssUrl('mode_edit_outline.png');
  31. const conversationEnergyStoneCount = getOssUrl('conversion-energy-stone-count.png');
  32. const lumiNoCap = getOssUrl('Lumi-no-cap.png');
  33. const lumiCap = getOssUrl('Lumi-cap.png');
  34. const arrowRight = getOssUrl('arrow_right.png');
  35. const headCap = getOssUrl('head-cap.png');
  36. const bgHappyNewYear = getOssUrl('bg-happynewyear-s.png');
  37. const starBg = getOssUrl('star-bg.png');
  38. const rocketIcon = getOssUrl('Rocket.gif');
  39. const XIconImage = getOssUrl('x-icon.png');
  40. const primaryDefaultButton = getOssUrl('primary-default.png');
  41. const secondaryDefaultButton = getOssUrl('secondary-default.png');
  42. export const ProfilePage = () => {
  43. const { t } = useTranslation('profile');
  44. const { t: tCommon } = useTranslation('common');
  45. const navigate = useNavigate();
  46. const [username, setUsername] = useState<string>('');
  47. const [botName, setBotName] = useState<string>('');
  48. const [, setMissionStoneCount] = useState<number>(0);
  49. const [conversationStoneCount, setConversationStoneCount] = useState<number>(0);
  50. const [hasCap, setHasCap] = useState<boolean>(false);
  51. const [hasBackgroundReward, setHasBackgroundReward] = useState<boolean>(false);
  52. const [currentAvatarId, setCurrentAvatarId] = useState<string | null>(null);
  53. const [currentBackgroundImageId, setCurrentBackgroundImageId] = useState<string | null>(null);
  54. const [loading, setLoading] = useState<boolean>(true);
  55. const [userLevel, setUserLevel] = useState<number>(0);
  56. const [totalSpeechDurationMs, setTotalSpeechDurationMs] = useState<number>(0);
  57. const [showUsernameModal, setShowUsernameModal] = useState<boolean>(false);
  58. const [showBotNameModal, setShowBotNameModal] = useState<boolean>(false);
  59. const [tempUsername, setTempUsername] = useState<string>('');
  60. const [tempBotName, setTempBotName] = useState<string>('');
  61. const [isUsernameFocused, setIsUsernameFocused] = useState<boolean>(false);
  62. const [isBotNameFocused, setIsBotNameFocused] = useState<boolean>(false);
  63. const usernameInputRef = useRef<HTMLInputElement>(null);
  64. const botNameInputRef = useRef<HTMLInputElement>(null);
  65. const [showEnergyStoneModal, setShowEnergyStoneModal] = useState<boolean>(false);
  66. const [energyStoneModalType, setEnergyStoneModalType] = useState<'mission' | 'conversation'>('mission');
  67. const [showFeedbackModal, setShowFeedbackModal] = useState<boolean>(false);
  68. const [feedbackText, setFeedbackText] = useState<string>('');
  69. const [isSubmittingFeedback, setIsSubmittingFeedback] = useState<boolean>(false);
  70. const [showAgreementModal, setShowAgreementModal] = useState<boolean>(false);
  71. const [showPrivacyPolicyModal, setShowPrivacyPolicyModal] = useState<boolean>(false);
  72. // const cancelBtnImage = getOssUrl('cancel.png'); // Unused - replaced by primary buttons
  73. // const changeBtnImage = getOssUrl('change.png'); // Unused - replaced by primary buttons
  74. // const changeBtnActiveImage = getOssUrl('change-a.png'); // Unused - replaced by primary buttons
  75. // const sendBtnImage = getOssUrl('send.png'); // Unused - replaced by primary buttons
  76. // const sendBtnActiveImage = getOssUrl('send-a.png'); // Unused - replaced by primary buttons
  77. // 获取能量石数量
  78. const fetchEnergyStoneCounts = useCallback(
  79. async (userId: string) => {
  80. try {
  81. const apiBaseUrl = getApiBaseUrl();
  82. const request = async () =>
  83. fetch(`${apiBaseUrl}/api/users/${userId}/energy-stones/count`, {
  84. method: 'GET',
  85. headers: getApiHeaders(),
  86. });
  87. let response = await request();
  88. if (response.status === 401) {
  89. // 会话失效:清空本地状态并统一跳转到 /begin
  90. console.warn(
  91. '[ProfilePage] 请求能量石数量接口返回 401,认为会话失效,准备清空本地并跳转 /begin',
  92. {
  93. userId,
  94. }
  95. );
  96. clearUserSessionAndRedirectToBegin();
  97. return;
  98. }
  99. if (response.ok) {
  100. const data = await response.json();
  101. if (data.success && data.data) {
  102. setMissionStoneCount(data.data.mission_count || 0);
  103. setConversationStoneCount(data.data.conversation_count || 0);
  104. }
  105. }
  106. } catch (error) {
  107. console.error('[ProfilePage] 获取能量石数量失败:', error);
  108. }
  109. },
  110. []
  111. );
  112. // 获取用户头像信息
  113. const fetchUserAvatars = useCallback(
  114. async (userId: string) => {
  115. try {
  116. const apiBaseUrl = getApiBaseUrl();
  117. const request = async () =>
  118. fetch(`${apiBaseUrl}/api/users/${userId}/avatars`, {
  119. method: 'GET',
  120. headers: getApiHeaders(),
  121. });
  122. let response = await request();
  123. if (response.status === 401) {
  124. clearUserSessionAndRedirectToBegin();
  125. return;
  126. }
  127. if (response.ok) {
  128. const data = await response.json();
  129. if (data.success && data.data) {
  130. const avatarIds = data.data.avatar_ids || [];
  131. // 检查是否有注册赠送的形象(带帽子)
  132. const hasRegisteredCap = avatarIds.includes('avatar_registered_cap');
  133. setHasCap(hasRegisteredCap);
  134. }
  135. }
  136. } catch (error) {
  137. console.error('[ProfilePage] 获取用户头像信息失败:', error);
  138. }
  139. },
  140. []
  141. );
  142. // 获取用户背景图片信息
  143. const fetchUserBackgroundImages = useCallback(
  144. async (userId: string) => {
  145. try {
  146. const apiBaseUrl = getApiBaseUrl();
  147. const request = async () =>
  148. fetch(`${apiBaseUrl}/api/users/${userId}/background-images`, {
  149. method: 'GET',
  150. headers: getApiHeaders(),
  151. });
  152. let response = await request();
  153. if (response.status === 401) {
  154. clearUserSessionAndRedirectToBegin();
  155. return;
  156. }
  157. if (response.ok) {
  158. const data = await response.json();
  159. if (data.success && data.data) {
  160. const imageIds = data.data.image_ids || [];
  161. const hasNewYearBackground = imageIds.some((id: string) =>
  162. id.toLowerCase().includes('newyear') ||
  163. id.toLowerCase().includes('happynewyear') ||
  164. id.toLowerCase().includes('new_year')
  165. );
  166. setHasBackgroundReward(hasNewYearBackground);
  167. }
  168. }
  169. } catch (error) {
  170. console.error('[ProfilePage] 获取用户背景图片信息失败:', error);
  171. }
  172. },
  173. []
  174. );
  175. // 加载用户信息
  176. useEffect(() => {
  177. const loadUserData = async () => {
  178. const userId = getUserId();
  179. if (!userId) {
  180. navigate('/email-login');
  181. return;
  182. }
  183. try {
  184. // 获取用户基本信息(401 时由各接口内部的 401 分支负责处理会话失效)
  185. const userInfo = await getUserInfo(userId);
  186. if (userInfo.success && userInfo.data) {
  187. setUsername(userInfo.data.username || '');
  188. setBotName(userInfo.data.bot_name || getStorage(STORAGE_KEYS.LUMI_NAME) || 'Lumi');
  189. setUserLevel(userInfo.data.user_level || 0);
  190. // 同步当前背景图片状态(用于正确展示选中边框)
  191. const backgroundIdFromUser = userInfo.data.current_background_image_id || getCurrentBackgroundImageId();
  192. if (backgroundIdFromUser) {
  193. setCurrentBackgroundImageId(backgroundIdFromUser);
  194. // 存一份到 localStorage,保持与后端一致
  195. setBackgroundImageIdToStorage(backgroundIdFromUser);
  196. }
  197. setTotalSpeechDurationMs(userInfo.data.total_speech_duration_ms || 0);
  198. }
  199. // 获取用户 UI 状态(包含 current_avatar_id)
  200. const uiState = await getUserUIState(userId);
  201. if (uiState.success && uiState.data) {
  202. setCurrentAvatarId(uiState.data.current_avatar_id || null);
  203. }
  204. // 获取能量石数量
  205. await fetchEnergyStoneCounts(userId);
  206. // 获取用户头像信息
  207. await fetchUserAvatars(userId);
  208. // 获取用户背景图片信息
  209. await fetchUserBackgroundImages(userId);
  210. } catch (error) {
  211. console.error('加载用户数据失败:', error);
  212. } finally {
  213. setLoading(false);
  214. }
  215. };
  216. loadUserData();
  217. }, [navigate, fetchEnergyStoneCounts, fetchUserAvatars, fetchUserBackgroundImages]);
  218. // 防止弹窗打开时背景滚动
  219. useEffect(() => {
  220. if (showUsernameModal || showBotNameModal || showEnergyStoneModal || showFeedbackModal || showAgreementModal || showPrivacyPolicyModal) {
  221. document.body.style.overflow = 'hidden';
  222. } else {
  223. document.body.style.overflow = '';
  224. }
  225. return () => {
  226. document.body.style.overflow = '';
  227. };
  228. }, [showUsernameModal, showBotNameModal, showEnergyStoneModal, showFeedbackModal, showAgreementModal, showPrivacyPolicyModal]);
  229. const handleClose = useCallback(() => {
  230. navigate(-1);
  231. }, [navigate]);
  232. const handleHeadClick = useCallback(async () => {
  233. const userId = getUserId();
  234. if (!userId) return;
  235. if (!hasCap) {
  236. navigate('/first-login');
  237. return;
  238. }
  239. // 已拥有情况下,切换头像
  240. const newAvatarId = currentAvatarId === 'avatar_registered_cap'
  241. ? 'avatar_default'
  242. : 'avatar_registered_cap';
  243. try {
  244. const result = await updateUserUIState(userId, { current_avatar_id: newAvatarId });
  245. if (result.success) {
  246. setCurrentAvatarId(newAvatarId); // 更新 React state
  247. setAvatarIdToStorage(newAvatarId); // 同步到 localStorage
  248. }
  249. } catch (error) {
  250. console.error('切换头像失败:', error);
  251. }
  252. }, [hasCap, currentAvatarId, navigate]);
  253. // 打开编辑用户名弹窗
  254. const handleEditUsername = useCallback(() => {
  255. setTempUsername(username);
  256. setShowUsernameModal(true);
  257. setTimeout(() => {
  258. usernameInputRef.current?.focus();
  259. }, 0);
  260. }, [username]);
  261. // 检查用户名是否改变(且非空)
  262. const isUsernameChanged = tempUsername.trim() !== username.trim();
  263. // 保存用户名
  264. const handleSaveUsername = useCallback(async () => {
  265. const userId = getUserId();
  266. if (!userId || !tempUsername.trim()) {
  267. setShowUsernameModal(false);
  268. return;
  269. }
  270. try {
  271. const result = await updateUsername(userId, tempUsername.trim());
  272. if (result.success) {
  273. setUsername(tempUsername.trim());
  274. setShowUsernameModal(false);
  275. }
  276. } catch (error) {
  277. console.error('保存用户名失败:', error);
  278. setShowUsernameModal(false);
  279. }
  280. }, [tempUsername]);
  281. // 关闭编辑用户名弹窗
  282. const handleCloseUsernameModal = useCallback(() => {
  283. setShowUsernameModal(false);
  284. setTempUsername('');
  285. }, []);
  286. // 打开编辑 Lumi 名字弹窗
  287. const handleEditBotName = useCallback(() => {
  288. setTempBotName(botName);
  289. setShowBotNameModal(true);
  290. setTimeout(() => {
  291. botNameInputRef.current?.focus();
  292. }, 0);
  293. }, [botName]);
  294. // 检查 Lumi 名字是否改变(且非空)
  295. const isBotNameChanged = tempBotName.trim() !== botName.trim();
  296. // 保存 Lumi 名字
  297. const handleSaveBotName = useCallback(async () => {
  298. const userId = getUserId();
  299. if (!userId || !tempBotName.trim()) {
  300. setShowBotNameModal(false);
  301. return;
  302. }
  303. try {
  304. const result = await updateBotName(userId, tempBotName.trim());
  305. if (result.success) {
  306. setBotName(tempBotName.trim());
  307. setShowBotNameModal(false);
  308. // 同时更新 localStorage
  309. setStorage(STORAGE_KEYS.LUMI_NAME, tempBotName.trim());
  310. }
  311. } catch (error) {
  312. console.error('保存 Lumi 名字失败:', error);
  313. setShowBotNameModal(false);
  314. }
  315. }, [tempBotName]);
  316. // 关闭编辑 Lumi 名字弹窗
  317. const handleCloseBotNameModal = useCallback(() => {
  318. setShowBotNameModal(false);
  319. setTempBotName('');
  320. }, []);
  321. // 处理能量石点击
  322. const handleEnergyStoneClick = useCallback((stoneType: 'mission' | 'conversation') => {
  323. setEnergyStoneModalType(stoneType);
  324. setShowEnergyStoneModal(true);
  325. }, []);
  326. // 关闭能量石弹窗
  327. const handleCloseEnergyStoneModal = useCallback(() => {
  328. setShowEnergyStoneModal(false);
  329. }, []);
  330. // 打开反馈弹窗
  331. const handleOpenFeedbackModal = useCallback(() => {
  332. setShowFeedbackModal(true);
  333. setFeedbackText('');
  334. }, []);
  335. // 关闭反馈弹窗
  336. const handleCloseFeedbackModal = useCallback(() => {
  337. setShowFeedbackModal(false);
  338. setFeedbackText('');
  339. }, []);
  340. // 提交反馈
  341. const handleSubmitFeedback = useCallback(async () => {
  342. const userId = getUserId();
  343. if (!userId || !feedbackText.trim()) {
  344. return;
  345. }
  346. setIsSubmittingFeedback(true);
  347. try {
  348. const apiBaseUrl = getApiBaseUrl();
  349. const response = await fetch(`${apiBaseUrl}/api/users/${userId}/feedback`, {
  350. method: 'POST',
  351. headers: getApiHeaders(),
  352. body: JSON.stringify({ content: feedbackText.trim() }),
  353. });
  354. if (response.ok) {
  355. setShowFeedbackModal(false);
  356. setFeedbackText('');
  357. // 可以添加成功提示
  358. } else {
  359. console.error('提交反馈失败:', response.statusText);
  360. }
  361. } catch (error) {
  362. console.error('提交反馈异常:', error);
  363. } finally {
  364. setIsSubmittingFeedback(false);
  365. }
  366. }, [feedbackText]);
  367. // 计算升级所需时间和当前进度
  368. const getLevelProgress = useCallback(() => {
  369. const level = userLevel;
  370. const totalSeconds = Math.floor(totalSpeechDurationMs / 1000);
  371. // 定义各等级升级需要的时长(秒)
  372. const requiredTimesByLevel = [10, 30, 60, 120, 240, 240];
  373. // 获取当前等级升级需要的时长
  374. const requiredTime = requiredTimesByLevel[level] || 240;
  375. // 当前已沟通的时长(秒)= 总时长
  376. const currentTime = Math.max(0, totalSeconds);
  377. // 进度百分比 = 当前已沟通时长 / 升级需要的时长
  378. const progress = Math.min(100, (currentTime / requiredTime) * 100);
  379. return {
  380. currentTime,
  381. requiredTime,
  382. progress,
  383. displayText: `${currentTime}/${requiredTime}`,
  384. };
  385. }, [userLevel, totalSpeechDurationMs]);
  386. if (loading) {
  387. return (
  388. <div
  389. style={{
  390. width: '100vw',
  391. height: '100vh',
  392. backgroundColor: '#1A1821',
  393. display: 'flex',
  394. alignItems: 'center',
  395. justifyContent: 'center',
  396. color: '#fff',
  397. }}
  398. >
  399. {tCommon('message.loading')}
  400. </div>
  401. );
  402. }
  403. return (
  404. <>
  405. <style>{`
  406. @keyframes fadeIn {
  407. from {
  408. opacity: 0;
  409. }
  410. to {
  411. opacity: 1;
  412. }
  413. }
  414. .profile-modal-input::placeholder {
  415. color: rgba(245, 243, 240, 0.45);
  416. }
  417. .feedback-textarea::placeholder {
  418. color: rgba(245, 243, 240, 0.45);
  419. }
  420. `}</style>
  421. <div
  422. style={{
  423. height: '100vh',
  424. position: 'relative',
  425. overflow: 'hidden',
  426. }}
  427. >
  428. {/* 关闭按钮 */}
  429. <img
  430. src={closeBtn}
  431. alt="Close"
  432. onClick={handleClose}
  433. style={{
  434. width: px2vmin(30),
  435. height: px2vmin(30),
  436. position: 'absolute',
  437. top: px2vmin(62),
  438. right: px2vmin(27),
  439. cursor: 'pointer',
  440. zIndex: 100,
  441. }}
  442. />
  443. {/* 用户名字和编辑图标 */}
  444. <div
  445. style={{
  446. position: 'absolute',
  447. top: px2vmin(90),
  448. left: '50%',
  449. transform: 'translateX(-50%)',
  450. display: 'flex',
  451. alignItems: 'center',
  452. gap: px2vmin(8),
  453. zIndex: 10,
  454. }}
  455. >
  456. <span
  457. style={{
  458. fontSize: px2vmin(18),
  459. color: '#fff',
  460. fontWeight: 500,
  461. }}
  462. >
  463. {username || tCommon('userDefault')}
  464. </span>
  465. <img
  466. src={editIcon}
  467. alt="Edit"
  468. onClick={handleEditUsername}
  469. style={{
  470. width: px2vmin(20),
  471. height: px2vmin(20),
  472. cursor: 'pointer',
  473. }}
  474. />
  475. </div>
  476. {/* 用户等级显示区域 */}
  477. <div
  478. style={{
  479. position: 'absolute',
  480. top: px2vmin(166),
  481. left: '50%',
  482. transform: 'translateX(-50%)',
  483. width: px2vmin(343),
  484. height: px2vmin(38),
  485. display: 'flex',
  486. alignItems: 'center',
  487. justifyContent: 'flex-start',
  488. zIndex: 10,
  489. }}
  490. >
  491. {/* 对话能量石:放在等级行左侧 */}
  492. <div
  493. onClick={() => handleEnergyStoneClick('conversation')}
  494. style={{
  495. position: 'relative',
  496. width: px2vmin(70),
  497. height: px2vmin(32),
  498. cursor: 'pointer',
  499. flexShrink: 0,
  500. }}
  501. >
  502. <img
  503. src={conversationEnergyStoneCount}
  504. alt="Conversation Energy Stone"
  505. style={{
  506. width: '100%',
  507. height: '100%',
  508. }}
  509. />
  510. <span
  511. style={{
  512. position: 'absolute',
  513. top: '50%',
  514. left: '60%',
  515. transform: 'translate(-50%, -50%)',
  516. fontSize: px2vmin(10),
  517. color: '#000',
  518. fontWeight: 500,
  519. }}
  520. >
  521. {conversationStoneCount}
  522. </span>
  523. </div>
  524. {/* 等级和进度内容区域,与对话能量石间隔 16 */}
  525. <div
  526. style={{
  527. display: 'flex',
  528. alignItems: 'center',
  529. justifyContent: 'space-between',
  530. flex: 1,
  531. marginLeft: px2vmin(16),
  532. }}
  533. >
  534. {/* 第一个五角星 - 当前等级 */}
  535. <div
  536. style={{
  537. position: 'relative',
  538. display: 'flex',
  539. alignItems: 'center',
  540. justifyContent: 'center',
  541. }}
  542. >
  543. <img
  544. src={starBg}
  545. alt="Star"
  546. style={{
  547. width: px2vmin(32),
  548. height: px2vmin(32),
  549. }}
  550. />
  551. <span
  552. style={{
  553. position: 'absolute',
  554. top: '50%',
  555. left: '50%',
  556. transform: 'translate(-50%, -50%)',
  557. fontSize: px2vmin(10),
  558. color: '#000',
  559. fontWeight: 600,
  560. }}
  561. >
  562. {userLevel}
  563. </span>
  564. </div>
  565. {/* 进度条区域 */}
  566. <div
  567. style={{
  568. position: 'relative',
  569. flex: 1,
  570. marginLeft: px2vmin(8),
  571. marginRight: px2vmin(8),
  572. display: 'flex',
  573. alignItems: 'center',
  574. justifyContent: 'center',
  575. }}
  576. >
  577. {/* 进度条 - 与五角星居中对齐 */}
  578. <div
  579. style={{
  580. width: px2vmin(166),
  581. height: px2vmin(12),
  582. backgroundColor: 'rgba(255, 255, 255, 0.2)',
  583. borderRadius: px2vmin(6),
  584. overflow: 'hidden',
  585. position: 'relative',
  586. }}
  587. >
  588. <div
  589. style={{
  590. width: `${getLevelProgress().progress}%`,
  591. height: '100%',
  592. backgroundColor: '#BF9DF8',
  593. borderRadius: px2vmin(6),
  594. transition: 'width 0.3s ease',
  595. }}
  596. />
  597. </div>
  598. {/* 进度文字 - 绝对定位在进度条上方 */}
  599. <span
  600. style={{
  601. position: 'absolute',
  602. top: px2vmin(-16),
  603. left: '50%',
  604. transform: 'translateX(-50%)',
  605. fontSize: px2vmin(10),
  606. color: '#fff',
  607. lineHeight: 1,
  608. whiteSpace: 'nowrap',
  609. }}
  610. >
  611. {getLevelProgress().displayText}
  612. </span>
  613. </div>
  614. {/* 第三个元素 - 下一等级或火箭 */}
  615. <div
  616. style={{
  617. position: 'relative',
  618. display: 'flex',
  619. alignItems: 'center',
  620. justifyContent: 'center',
  621. }}
  622. >
  623. {userLevel >= 5 ? (
  624. <img
  625. src={rocketIcon}
  626. alt="Rocket"
  627. style={{
  628. width: px2vmin(32),
  629. height: px2vmin(32),
  630. }}
  631. />
  632. ) : (
  633. <>
  634. <img
  635. src={starBg}
  636. alt="Star"
  637. style={{
  638. width: px2vmin(32),
  639. height: px2vmin(32),
  640. }}
  641. />
  642. <span
  643. style={{
  644. position: 'absolute',
  645. top: '50%',
  646. left: '50%',
  647. transform: 'translate(-50%, -50%)',
  648. fontSize: px2vmin(10),
  649. color: '#000',
  650. fontWeight: 600,
  651. }}
  652. >
  653. {userLevel + 1}
  654. </span>
  655. </>
  656. )}
  657. </div>
  658. </div>
  659. </div>
  660. {/* 区域A */}
  661. <div
  662. style={{
  663. position: 'absolute',
  664. top: px2vmin(256),
  665. left: '50%',
  666. transform: 'translateX(-50%)',
  667. width: px2vmin(343),
  668. height: px2vmin(240),
  669. backgroundColor: '#4A4459',
  670. borderRadius: px2vmin(28),
  671. zIndex: 10,
  672. }}
  673. >
  674. {/* Lumi 头像 */}
  675. <img
  676. src={currentAvatarId === 'avatar_registered_cap' ? lumiCap : lumiNoCap}
  677. alt="Lumi"
  678. style={{
  679. width: px2vmin(180),
  680. height: px2vmin(180),
  681. position: 'absolute',
  682. left: 0,
  683. top: px2vmax(-56),
  684. }}
  685. />
  686. {/* Lumi名字和编辑图标 */}
  687. <div
  688. style={{
  689. position: 'absolute',
  690. left: px2vmin(200),
  691. marginRight: px2vmin(10),
  692. top: px2vmin(36),
  693. display: 'flex',
  694. alignItems: 'center',
  695. gap: px2vmin(8),
  696. }}
  697. >
  698. <span
  699. style={{
  700. fontSize: px2vmin(18),
  701. color: '#fff',
  702. fontWeight: 500,
  703. }}
  704. >
  705. {botName}
  706. </span>
  707. <img
  708. src={editIcon}
  709. alt="Edit"
  710. onClick={handleEditBotName}
  711. style={{
  712. width: px2vmin(20),
  713. height: px2vmin(20),
  714. cursor: 'pointer',
  715. }}
  716. />
  717. </div>
  718. {/* 区域B */}
  719. <div
  720. style={{
  721. position: 'absolute',
  722. left: '50%',
  723. transform: 'translateX(-50%)',
  724. top: px2vmin(108),
  725. width: px2vmin(311),
  726. height: px2vmin(116),
  727. display: 'flex',
  728. gap: px2vmin(15),
  729. }}
  730. >
  731. {/* 区域C */}
  732. <div
  733. style={{
  734. width: px2vmin(148),
  735. height: px2vmin(116),
  736. backgroundColor: 'rgba(245,243,240, 0.1)',
  737. borderRadius: px2vmin(15),
  738. position: 'relative',
  739. }}
  740. >
  741. {/* 112*92 容器 */}
  742. <div
  743. style={{
  744. position: 'absolute',
  745. top: px2vmin(12),
  746. left: '50%',
  747. transform: 'translateX(-50%)',
  748. width: px2vmin(112),
  749. height: px2vmin(92),
  750. }}
  751. >
  752. {/* 108*70 边框区域 */}
  753. <div
  754. onClick={handleHeadClick}
  755. style={{
  756. width: px2vmin(108),
  757. height: px2vmin(70),
  758. border: `2px solid ${
  759. hasCap && currentAvatarId === 'avatar_registered_cap'
  760. ? '#BF9DF8'
  761. : 'rgba(245,243,240, 0.3)'
  762. }`,
  763. borderRadius: px2vmin(12),
  764. marginLeft: '50%',
  765. transform: 'translateX(-50%)',
  766. position: 'relative',
  767. display: 'flex',
  768. alignItems: 'center',
  769. justifyContent: 'center',
  770. cursor: hasCap ? 'pointer' : 'pointer',
  771. }}
  772. >
  773. <img
  774. src={headCap}
  775. alt="Head Cap"
  776. style={{
  777. width: px2vmin(70),
  778. height: px2vmin(70),
  779. }}
  780. />
  781. </div>
  782. {/* Head 文字 */}
  783. <div
  784. style={{
  785. marginTop: px2vmin(8),
  786. textAlign: 'center',
  787. fontSize: px2vmin(14),
  788. color: '#fff',
  789. }}
  790. >
  791. {t('head')}
  792. </div>
  793. </div>
  794. </div>
  795. {/* 区域D */}
  796. <div
  797. style={{
  798. width: px2vmin(148),
  799. height: px2vmin(116),
  800. backgroundColor: 'rgba(245,243,240, 0.1)',
  801. borderRadius: px2vmin(15),
  802. position: 'relative',
  803. }}
  804. >
  805. {/* 112*92 容器 */}
  806. <div
  807. style={{
  808. position: 'absolute',
  809. top: px2vmin(12),
  810. left: '50%',
  811. transform: 'translateX(-50%)',
  812. width: px2vmin(112),
  813. height: px2vmin(92),
  814. }}
  815. >
  816. {/* 108*70 边框区域(暂不支持点击/分享,仅展示) */}
  817. <div
  818. style={{
  819. width: px2vmin(108),
  820. height: px2vmin(70),
  821. border: `2px solid ${
  822. hasBackgroundReward && currentBackgroundImageId === 'happynewyear'
  823. ? '#BF9DF8'
  824. : 'rgba(245,243,240, 0.3)'
  825. }`,
  826. borderRadius: px2vmin(12),
  827. marginLeft: '50%',
  828. transform: 'translateX(-50%)',
  829. position: 'relative',
  830. overflow: 'hidden',
  831. cursor: 'default',
  832. }}
  833. >
  834. <img
  835. src={bgHappyNewYear}
  836. alt="Background"
  837. style={{
  838. width: '100%',
  839. height: '100%',
  840. objectFit: 'cover',
  841. }}
  842. />
  843. {/* 暂不支持分享:不再显示礼物图标和可点击蒙层 */}
  844. </div>
  845. {/* Background 文字 */}
  846. <div
  847. style={{
  848. marginTop: px2vmin(8),
  849. textAlign: 'center',
  850. fontSize: px2vmin(14),
  851. color: '#fff',
  852. }}
  853. >
  854. {t('background')}
  855. </div>
  856. </div>
  857. </div>
  858. </div>
  859. </div>
  860. {/* 区域E */}
  861. <div
  862. style={{
  863. position: 'absolute',
  864. top: px2vmin(534),
  865. left: '50%',
  866. transform: 'translateX(-50%)',
  867. width: px2vmin(343),
  868. height: px2vmin(178),
  869. zIndex: 10,
  870. }}
  871. >
  872. {/* 意见反馈 & 帮助 */}
  873. <div
  874. onClick={handleOpenFeedbackModal}
  875. style={{
  876. display: 'flex',
  877. alignItems: 'center',
  878. justifyContent: 'space-between',
  879. height: px2vmin(59),
  880. borderTop: '1px solid #34313D',
  881. // marginLeft: px2vmin(10),
  882. // marginRight: px2vmin(10),
  883. cursor: 'pointer',
  884. }}
  885. >
  886. <span
  887. style={{
  888. fontSize: px2vmin(16),
  889. color: '#fff',
  890. marginLeft: px2vmin(10),
  891. }}
  892. >
  893. {t('feedbackAndHelp')}
  894. </span>
  895. <img
  896. src={arrowRight}
  897. alt="Arrow"
  898. style={{
  899. width: px2vmin(24),
  900. height: px2vmin(24),
  901. marginRight: '10px',
  902. }}
  903. />
  904. </div>
  905. {/* 使用协议 */}
  906. <div
  907. onClick={() => setShowAgreementModal(true)}
  908. style={{
  909. display: 'flex',
  910. alignItems: 'center',
  911. justifyContent: 'space-between',
  912. height: px2vmin(59),
  913. borderTop: '1px solid #34313D',
  914. // marginLeft: px2vmin(10),
  915. // marginRight: px2vmin(10),
  916. cursor: 'pointer',
  917. }}
  918. >
  919. <span
  920. style={{
  921. fontSize: px2vmin(16),
  922. color: '#fff',
  923. marginLeft: px2vmin(10),
  924. }}
  925. >
  926. {t('userAgreement')}
  927. </span>
  928. <img
  929. src={arrowRight}
  930. alt="Arrow"
  931. style={{
  932. width: px2vmin(24),
  933. height: px2vmin(24),
  934. marginRight: '10px',
  935. }}
  936. />
  937. </div>
  938. {/* 隐私政策 */}
  939. <div
  940. onClick={() => setShowPrivacyPolicyModal(true)}
  941. style={{
  942. display: 'flex',
  943. alignItems: 'center',
  944. justifyContent: 'space-between',
  945. height: px2vmin(59),
  946. borderTop: '1px solid #34313D',
  947. // marginLeft: px2vmin(10),
  948. // marginRight: px2vmin(10),
  949. cursor: 'pointer',
  950. }}
  951. >
  952. <span
  953. style={{
  954. fontSize: px2vmin(16),
  955. color: '#fff',
  956. marginLeft: px2vmin(10),
  957. }}
  958. >
  959. {t('privacyPolicy')}
  960. </span>
  961. <img
  962. src={arrowRight}
  963. alt="Arrow"
  964. style={{
  965. width: px2vmin(24),
  966. height: px2vmin(24),
  967. marginRight: '10px',
  968. }}
  969. />
  970. </div>
  971. </div>
  972. {/* 编辑用户名弹窗 */}
  973. {showUsernameModal && (
  974. <>
  975. {/* 遮罩层 */}
  976. <div
  977. onClick={handleCloseUsernameModal}
  978. style={{
  979. position: 'fixed',
  980. top: 0,
  981. left: 0,
  982. right: 0,
  983. bottom: 0,
  984. backgroundColor: 'rgba(0, 0, 0, 0.5)',
  985. zIndex: 9998,
  986. animation: 'fadeIn 0.3s ease-out',
  987. }}
  988. />
  989. {/* 弹窗内容 */}
  990. <div
  991. style={{
  992. position: 'fixed',
  993. bottom: 0,
  994. left: '50%',
  995. transform: 'translateX(-50%)',
  996. width: px2vw(375),
  997. backgroundColor: '#34313D',
  998. borderTopLeftRadius: px2vmin(32),
  999. borderTopRightRadius: px2vmin(32),
  1000. zIndex: 9999,
  1001. display: 'flex',
  1002. flexDirection: 'column',
  1003. alignItems: 'center',
  1004. paddingTop: px2vmin(12),
  1005. paddingBottom: px2vmin(32),
  1006. paddingLeft: px2vmin(32),
  1007. paddingRight: px2vmin(32),
  1008. }}
  1009. >
  1010. {/* 顶部拖拽指示条 */}
  1011. <div
  1012. style={{
  1013. width: px2vmin(32),
  1014. height: px2vmin(4),
  1015. backgroundColor: '#79747E',
  1016. borderRadius: px2vmin(4),
  1017. }}
  1018. />
  1019. {/* 文字标签 */}
  1020. <div
  1021. style={{
  1022. width: '100%',
  1023. fontSize: px2vmin(14),
  1024. color: '#fff',
  1025. fontWeight: 'bold',
  1026. marginTop: px2vmin(24),
  1027. marginBottom: px2vmin(16),
  1028. textAlign: 'left',
  1029. }}
  1030. >
  1031. {t('changeMyName')}
  1032. </div>
  1033. {/* 输入框容器(与 email-login 一致:12PX 圆角 + 聚焦边框 #BF9DF8) */}
  1034. <div
  1035. style={{
  1036. width: '100%',
  1037. height: px2vmin(56),
  1038. position: 'relative',
  1039. marginBottom: px2vmin(32),
  1040. }}
  1041. >
  1042. <div
  1043. className="relative overflow-visible"
  1044. style={{
  1045. height: '100%',
  1046. background: 'rgba(0,0,0,0.1)',
  1047. borderRadius: '12PX',
  1048. border: isUsernameFocused ? '1PX solid #BF9DF8' : '1PX solid transparent',
  1049. boxShadow: isUsernameFocused
  1050. ? 'none'
  1051. : 'rgba(255, 255, 255, 0.18) 0px 1px 0px 0px, rgba(0, 0, 0, 0.65) 0px 0px 0px 1px inset, rgba(0, 0, 0, 0.25) 0px 4px 8px inset',
  1052. }}
  1053. >
  1054. <input
  1055. ref={usernameInputRef}
  1056. type="text"
  1057. value={tempUsername}
  1058. onChange={(e) => setTempUsername(e.target.value)}
  1059. onFocus={() => setIsUsernameFocused(true)}
  1060. onBlur={() => setIsUsernameFocused(false)}
  1061. onKeyDown={(e) => {
  1062. if (e.key === 'Enter') {
  1063. handleSaveUsername();
  1064. } else if (e.key === 'Escape') {
  1065. handleCloseUsernameModal();
  1066. }
  1067. }}
  1068. placeholder={t('placeholderUsername')}
  1069. className="w-full h-full font-normal leading-normal tracking-[0.5px] text-[rgba(245,243,240,0.7)] bg-transparent border-none outline-none placeholder:text-[rgba(245,243,240,0.45)]"
  1070. style={{
  1071. fontSize: px2vmin(16),
  1072. paddingLeft: px2vmin(24),
  1073. paddingRight: px2vmin(24),
  1074. }}
  1075. />
  1076. {tempUsername ? (
  1077. <button
  1078. type="button"
  1079. className="absolute top-1/2 -translate-y-1/2 flex items-center justify-center transition-opacity touch-manipulation"
  1080. style={{
  1081. right: px2vmin(12),
  1082. width: px2vmin(24),
  1083. height: px2vmin(24),
  1084. background: 'transparent',
  1085. border: 'none',
  1086. cursor: 'pointer',
  1087. opacity: isUsernameFocused ? 1 : 0.6,
  1088. zIndex: 1,
  1089. }}
  1090. onClick={() => setTempUsername('')}
  1091. onMouseDown={(e) => e.preventDefault()}
  1092. aria-label={tCommon('a11y.clear')}
  1093. >
  1094. <img
  1095. src={XIconImage}
  1096. alt={tCommon('a11y.clear')}
  1097. style={{
  1098. width: px2vmin(24),
  1099. height: px2vmin(24),
  1100. objectFit: 'contain',
  1101. }}
  1102. draggable={false}
  1103. />
  1104. </button>
  1105. ) : null}
  1106. </div>
  1107. </div>
  1108. {/* 按钮组 */}
  1109. <div
  1110. style={{
  1111. display: 'flex',
  1112. gap: px2vmin(43),
  1113. justifyContent: 'center',
  1114. width: '100%',
  1115. }}
  1116. >
  1117. <button
  1118. onClick={handleCloseUsernameModal}
  1119. style={{
  1120. width: px2vmin(80),
  1121. height: px2vmin(42),
  1122. backgroundImage: `url(${secondaryDefaultButton})`,
  1123. backgroundRepeat: 'no-repeat',
  1124. backgroundPosition: 'center',
  1125. border: 'none',
  1126. cursor: 'pointer',
  1127. padding: 0,
  1128. borderRadius: px2vmin(20),
  1129. }}
  1130. >
  1131. <span
  1132. style={{
  1133. display: 'inline-block',
  1134. fontSize: px2vmin(16),
  1135. color: '#FFFFFF',
  1136. fontWeight: 500,
  1137. }}
  1138. >
  1139. {tCommon('button.cancel')}
  1140. </span>
  1141. </button>
  1142. <button
  1143. onClick={handleSaveUsername}
  1144. style={{
  1145. width: px2vmin(84),
  1146. height: px2vmin(42),
  1147. backgroundImage: `url(${primaryDefaultButton})`,
  1148. backgroundRepeat: 'no-repeat',
  1149. backgroundPosition: 'center',
  1150. border: 'none',
  1151. cursor: isUsernameChanged && tempUsername.trim() ? 'pointer' : 'default',
  1152. padding: 0,
  1153. opacity: isUsernameChanged && tempUsername.trim() ? 1 : 0.6,
  1154. borderRadius: px2vmin(20),
  1155. }}
  1156. disabled={!isUsernameChanged || !tempUsername.trim()}
  1157. >
  1158. <span
  1159. style={{
  1160. display: 'inline-block',
  1161. fontSize: px2vmin(16),
  1162. color: '#FFFFFF',
  1163. fontWeight: 500,
  1164. }}
  1165. >
  1166. {t('change')}
  1167. </span>
  1168. </button>
  1169. </div>
  1170. </div>
  1171. </>
  1172. )}
  1173. {/* 编辑 Lumi 名字弹窗 */}
  1174. {showBotNameModal && (
  1175. <>
  1176. {/* 遮罩层 */}
  1177. <div
  1178. onClick={handleCloseBotNameModal}
  1179. style={{
  1180. position: 'fixed',
  1181. top: 0,
  1182. left: 0,
  1183. right: 0,
  1184. bottom: 0,
  1185. backgroundColor: 'rgba(0, 0, 0, 0.5)',
  1186. zIndex: 9998,
  1187. animation: 'fadeIn 0.3s ease-out',
  1188. }}
  1189. />
  1190. {/* 弹窗内容 */}
  1191. <div
  1192. style={{
  1193. position: 'fixed',
  1194. bottom: 0,
  1195. left: '50%',
  1196. transform: 'translateX(-50%)',
  1197. width: px2vw(375),
  1198. backgroundColor: '#34313D',
  1199. borderTopLeftRadius: px2vmin(32),
  1200. borderTopRightRadius: px2vmin(32),
  1201. zIndex: 9999,
  1202. display: 'flex',
  1203. flexDirection: 'column',
  1204. alignItems: 'center',
  1205. paddingTop: px2vmin(12),
  1206. paddingBottom: px2vmin(32),
  1207. paddingLeft: px2vmin(32),
  1208. paddingRight: px2vmin(32),
  1209. }}
  1210. >
  1211. {/* 顶部拖拽指示条 */}
  1212. <div
  1213. style={{
  1214. width: px2vmin(32),
  1215. height: px2vmin(4),
  1216. backgroundColor: '#79747E',
  1217. borderRadius: px2vmin(4),
  1218. }}
  1219. />
  1220. {/* 文字标签 */}
  1221. <div
  1222. style={{
  1223. width: '100%',
  1224. fontSize: px2vmin(14),
  1225. color: '#fff',
  1226. marginTop: px2vmin(24),
  1227. marginBottom: px2vmin(16),
  1228. textAlign: 'left',
  1229. }}
  1230. >
  1231. {t('changeLumiName')}
  1232. </div>
  1233. {/* 输入框容器(与 email-login 一致:12PX 圆角 + 聚焦边框 #BF9DF8) */}
  1234. <div
  1235. style={{
  1236. width: '100%',
  1237. height: px2vmin(56),
  1238. position: 'relative',
  1239. marginBottom: px2vmin(32),
  1240. }}
  1241. >
  1242. <div
  1243. className="relative overflow-visible"
  1244. style={{
  1245. height: '100%',
  1246. background: 'rgba(0,0,0,0.1)',
  1247. borderRadius: '12PX',
  1248. border: isBotNameFocused ? '1PX solid #BF9DF8' : '1PX solid transparent',
  1249. boxShadow: isBotNameFocused
  1250. ? 'none'
  1251. : 'rgba(255, 255, 255, 0.18) 0px 1px 0px 0px, rgba(0, 0, 0, 0.65) 0px 0px 0px 1px inset, rgba(0, 0, 0, 0.25) 0px 4px 8px inset',
  1252. }}
  1253. >
  1254. <input
  1255. ref={botNameInputRef}
  1256. type="text"
  1257. value={tempBotName}
  1258. onChange={(e) => setTempBotName(e.target.value)}
  1259. onFocus={() => setIsBotNameFocused(true)}
  1260. onBlur={() => setIsBotNameFocused(false)}
  1261. onKeyDown={(e) => {
  1262. if (e.key === 'Enter') {
  1263. handleSaveBotName();
  1264. } else if (e.key === 'Escape') {
  1265. handleCloseBotNameModal();
  1266. }
  1267. }}
  1268. placeholder={t('placeholderLumiName')}
  1269. className="w-full h-full font-normal leading-normal tracking-[0.5px] text-[rgba(245,243,240,0.7)] bg-transparent border-none outline-none placeholder:text-[rgba(245,243,240,0.45)]"
  1270. style={{
  1271. fontSize: px2vmin(16),
  1272. paddingLeft: px2vmin(24),
  1273. paddingRight: px2vmin(24),
  1274. }}
  1275. />
  1276. {tempBotName ? (
  1277. <button
  1278. type="button"
  1279. className="absolute top-1/2 -translate-y-1/2 flex items-center justify-center transition-opacity touch-manipulation"
  1280. style={{
  1281. right: px2vmin(12),
  1282. width: px2vmin(24),
  1283. height: px2vmin(24),
  1284. background: 'transparent',
  1285. border: 'none',
  1286. cursor: 'pointer',
  1287. opacity: isBotNameFocused ? 1 : 0.6,
  1288. zIndex: 1,
  1289. }}
  1290. onClick={() => setTempBotName('')}
  1291. onMouseDown={(e) => e.preventDefault()}
  1292. aria-label={tCommon('a11y.clear')}
  1293. >
  1294. <img
  1295. src={XIconImage}
  1296. alt={tCommon('a11y.clear')}
  1297. style={{
  1298. width: px2vmin(24),
  1299. height: px2vmin(24),
  1300. objectFit: 'contain',
  1301. }}
  1302. draggable={false}
  1303. />
  1304. </button>
  1305. ) : null}
  1306. </div>
  1307. </div>
  1308. {/* 按钮组 */}
  1309. <div
  1310. style={{
  1311. display: 'flex',
  1312. gap: px2vmin(43),
  1313. justifyContent: 'center',
  1314. width: '100%',
  1315. }}
  1316. >
  1317. <button
  1318. onClick={handleCloseBotNameModal}
  1319. style={{
  1320. width: px2vmin(80),
  1321. height: px2vmin(42),
  1322. backgroundImage: `url(${secondaryDefaultButton})`,
  1323. backgroundRepeat: 'no-repeat',
  1324. backgroundPosition: 'center',
  1325. border: 'none',
  1326. cursor: 'pointer',
  1327. padding: 0,
  1328. borderRadius: px2vmin(20),
  1329. }}
  1330. >
  1331. <span
  1332. style={{
  1333. display: 'inline-block',
  1334. fontSize: px2vmin(16),
  1335. color: '#FFFFFF',
  1336. fontWeight: 500,
  1337. }}
  1338. >
  1339. {tCommon('button.cancel')}
  1340. </span>
  1341. </button>
  1342. <button
  1343. onClick={handleSaveBotName}
  1344. style={{
  1345. width: px2vmin(84),
  1346. height: px2vmin(42),
  1347. backgroundImage: `url(${primaryDefaultButton})`,
  1348. backgroundRepeat: 'no-repeat',
  1349. backgroundPosition: 'center',
  1350. border: 'none',
  1351. cursor: isBotNameChanged && tempBotName.trim() ? 'pointer' : 'default',
  1352. padding: 0,
  1353. opacity: isBotNameChanged && tempBotName.trim() ? 1 : 0.6,
  1354. borderRadius: px2vmin(20),
  1355. }}
  1356. disabled={!isBotNameChanged || !tempBotName.trim()}
  1357. >
  1358. <span
  1359. style={{
  1360. display: 'inline-block',
  1361. fontSize: px2vmin(16),
  1362. color: '#FFFFFF',
  1363. fontWeight: 500,
  1364. }}
  1365. >
  1366. {t('change')}
  1367. </span>
  1368. </button>
  1369. </div>
  1370. </div>
  1371. </>
  1372. )}
  1373. {/* 能量石弹窗 */}
  1374. <MissionEnergyStoneModal
  1375. visible={showEnergyStoneModal}
  1376. onClose={handleCloseEnergyStoneModal}
  1377. stoneType={energyStoneModalType}
  1378. />
  1379. {/* 意见反馈弹窗 */}
  1380. {showFeedbackModal && (
  1381. <>
  1382. {/* 遮罩层 */}
  1383. <div
  1384. onClick={handleCloseFeedbackModal}
  1385. style={{
  1386. position: 'fixed',
  1387. top: 0,
  1388. left: 0,
  1389. right: 0,
  1390. bottom: 0,
  1391. backgroundColor: 'rgba(0, 0, 0, 0.5)',
  1392. zIndex: 9998,
  1393. animation: 'fadeIn 0.3s ease-out',
  1394. }}
  1395. />
  1396. {/* 弹窗内容 */}
  1397. <div
  1398. style={{
  1399. position: 'fixed',
  1400. bottom: 0,
  1401. left: '50%',
  1402. transform: 'translateX(-50%)',
  1403. width: px2vw(375),
  1404. height: px2vmin(420),
  1405. backgroundColor: '#34313D',
  1406. borderTopLeftRadius: px2vmin(32),
  1407. borderTopRightRadius: px2vmin(32),
  1408. zIndex: 9999,
  1409. display: 'flex',
  1410. flexDirection: 'column',
  1411. alignItems: 'center',
  1412. paddingTop: px2vmin(12),
  1413. paddingBottom: px2vmin(32),
  1414. paddingLeft: px2vmin(32),
  1415. paddingRight: px2vmin(32),
  1416. }}
  1417. >
  1418. {/* 顶部拖拽指示条 */}
  1419. <div
  1420. style={{
  1421. width: px2vmin(32),
  1422. height: px2vmin(4),
  1423. backgroundColor: '#79747E',
  1424. borderRadius: px2vmin(4),
  1425. }}
  1426. />
  1427. {/* 文字标签 */}
  1428. <div
  1429. style={{
  1430. width: px2vmin(311),
  1431. fontSize: px2vmin(14),
  1432. color: '#fff',
  1433. fontWeight: 'bold',
  1434. marginTop: px2vmin(24),
  1435. marginBottom: px2vmin(16),
  1436. textAlign: 'left',
  1437. alignSelf: 'center',
  1438. }}
  1439. >
  1440. {t('feedbackAndHelp')}
  1441. </div>
  1442. {/* 输入区域 */}
  1443. <div
  1444. style={{
  1445. width: px2vmin(311),
  1446. height: px2vmin(224),
  1447. marginBottom: px2vmin(32),
  1448. alignSelf: 'center',
  1449. }}
  1450. >
  1451. <textarea
  1452. value={feedbackText}
  1453. onChange={(e) => setFeedbackText(e.target.value)}
  1454. placeholder={tCommon('feedbackPlaceholder')}
  1455. className="feedback-textarea"
  1456. style={{
  1457. width: '100%',
  1458. height: '100%',
  1459. backgroundColor: 'rgba(245, 243, 240, 0.1)',
  1460. border: 'none',
  1461. borderRadius: px2vmin(12),
  1462. padding: px2vmin(16),
  1463. fontSize: px2vmin(14),
  1464. color: 'rgba(245, 243, 240, 0.7)',
  1465. fontFamily: 'inherit',
  1466. resize: 'none',
  1467. outline: 'none',
  1468. }}
  1469. />
  1470. </div>
  1471. {/* 按钮组 */}
  1472. <div
  1473. style={{
  1474. display: 'flex',
  1475. gap: px2vmin(43),
  1476. justifyContent: 'center',
  1477. width: '100%',
  1478. }}
  1479. >
  1480. <button
  1481. onClick={handleCloseFeedbackModal}
  1482. disabled={isSubmittingFeedback}
  1483. style={{
  1484. width: px2vmin(85),
  1485. height: px2vmin(44),
  1486. backgroundImage: `url(${secondaryDefaultButton})`,
  1487. backgroundRepeat: 'no-repeat',
  1488. backgroundPosition: 'center',
  1489. border: 'none',
  1490. cursor: isSubmittingFeedback ? 'default' : 'pointer',
  1491. padding: 0,
  1492. opacity: isSubmittingFeedback ? 0.6 : 1,
  1493. borderRadius: px2vmin(20),
  1494. }}
  1495. >
  1496. <span
  1497. style={{
  1498. display: 'inline-block',
  1499. fontSize: px2vmin(16),
  1500. color: '#FFFFFF',
  1501. fontWeight: 500,
  1502. }}
  1503. >
  1504. {tCommon('button.cancel')}
  1505. </span>
  1506. </button>
  1507. <button
  1508. onClick={handleSubmitFeedback}
  1509. disabled={!feedbackText.trim() || isSubmittingFeedback}
  1510. style={{
  1511. width: px2vmin(72),
  1512. height: px2vmin(44),
  1513. backgroundImage: `url(${primaryDefaultButton})`,
  1514. backgroundRepeat: 'no-repeat',
  1515. backgroundPosition: 'center',
  1516. border: 'none',
  1517. cursor: feedbackText.trim() && !isSubmittingFeedback ? 'pointer' : 'default',
  1518. padding: 0,
  1519. opacity: feedbackText.trim() && !isSubmittingFeedback ? 1 : 0.6,
  1520. borderRadius: px2vmin(20),
  1521. }}
  1522. >
  1523. <span
  1524. style={{
  1525. display: 'inline-block',
  1526. fontSize: px2vmin(16),
  1527. color: '#FFFFFF',
  1528. fontWeight: 500,
  1529. }}
  1530. >
  1531. {tCommon('button.send')}
  1532. </span>
  1533. </button>
  1534. </div>
  1535. </div>
  1536. </>
  1537. )}
  1538. {/* 用户协议弹窗 */}
  1539. <UserAgreementModal
  1540. visible={showAgreementModal}
  1541. onClose={() => setShowAgreementModal(false)}
  1542. />
  1543. {/* 隐私政策弹窗 */}
  1544. <PrivacyPolicyModal
  1545. visible={showPrivacyPolicyModal}
  1546. onClose={() => setShowPrivacyPolicyModal(false)}
  1547. />
  1548. </div>
  1549. </>
  1550. );
  1551. };