exit-presentation-button.tsx 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. 'use client'
  2. import { memo } from 'react';
  3. import { XMarkIcon } from '@heroicons/react/24/solid';
  4. import { useSentioPresentationStore } from '@/lib/store/sentio';
  5. import { useChatWithAgent } from '../hooks/chat';
  6. import clsx from 'clsx';
  7. export const ExitPresentationButton = memo(() => {
  8. const { isPresentationMode, exitPresentationMode } = useSentioPresentationStore();
  9. const { abort } = useChatWithAgent();
  10. const handleExit = () => {
  11. console.log('用户点击退出展示模式按钮');
  12. // 停止数字人说话(如果正在说话)
  13. abort();
  14. // 退出展示模式
  15. exitPresentationMode();
  16. // 恢复录音和语音识别
  17. if (typeof window !== 'undefined') {
  18. console.log('发送恢复录音事件');
  19. window.dispatchEvent(new Event('sentio-resume-recording'));
  20. }
  21. };
  22. // 只在展示模式下显示
  23. if (!isPresentationMode) {
  24. return null;
  25. }
  26. return (
  27. <button
  28. onClick={handleExit}
  29. className={clsx(
  30. 'fixed top-4 right-4 w-10 h-10 rounded-full',
  31. 'flex items-center justify-center',
  32. 'bg-red-500 hover:bg-red-600',
  33. 'text-white shadow-lg',
  34. 'transition-all duration-200',
  35. 'z-50',
  36. 'focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2',
  37. 'backdrop-blur-sm'
  38. )}
  39. aria-label="退出展示模式"
  40. title="退出展示模式"
  41. style={{
  42. border: '2px solid rgba(255, 255, 255, 0.3)',
  43. boxShadow: '0 4px 12px rgba(0, 0, 0, 0.3), 0 0 8px rgba(239, 68, 68, 0.5)',
  44. }}
  45. >
  46. <XMarkIcon className="w-5 h-5" />
  47. </button>
  48. );
  49. });
  50. ExitPresentationButton.displayName = 'ExitPresentationButton';