CustomInputRender.jsx 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. Copyright (C) 2025 QuantumNous
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU Affero General Public License as
  5. published by the Free Software Foundation, either version 3 of the
  6. License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Affero General Public License for more details.
  11. You should have received a copy of the GNU Affero General Public License
  12. along with this program. If not, see <https://www.gnu.org/licenses/>.
  13. For commercial licensing, please contact support@quantumnous.com
  14. */
  15. import React from 'react';
  16. const CustomInputRender = (props) => {
  17. const { detailProps } = props;
  18. const { clearContextNode, uploadNode, inputNode, sendNode, onClick } = detailProps;
  19. // 清空按钮
  20. const styledClearNode = clearContextNode
  21. ? React.cloneElement(clearContextNode, {
  22. className: `!rounded-full !bg-gray-100 hover:!bg-red-500 hover:!text-white flex-shrink-0 transition-all ${clearContextNode.props.className || ''}`,
  23. style: {
  24. ...clearContextNode.props.style,
  25. width: '32px',
  26. height: '32px',
  27. minWidth: '32px',
  28. padding: 0,
  29. display: 'flex',
  30. alignItems: 'center',
  31. justifyContent: 'center',
  32. }
  33. })
  34. : null;
  35. // 发送按钮
  36. const styledSendNode = React.cloneElement(sendNode, {
  37. className: `!rounded-full !bg-purple-500 hover:!bg-purple-600 flex-shrink-0 transition-all ${sendNode.props.className || ''}`,
  38. style: {
  39. ...sendNode.props.style,
  40. width: '32px',
  41. height: '32px',
  42. minWidth: '32px',
  43. padding: 0,
  44. display: 'flex',
  45. alignItems: 'center',
  46. justifyContent: 'center',
  47. }
  48. });
  49. return (
  50. <div className="p-2 sm:p-4">
  51. <div
  52. className="flex items-center gap-2 sm:gap-3 p-2 bg-gray-50 rounded-xl sm:rounded-2xl shadow-sm hover:shadow-md transition-shadow"
  53. style={{ border: '1px solid var(--semi-color-border)' }}
  54. onClick={onClick}
  55. >
  56. {/* 清空对话按钮 - 左边 */}
  57. {styledClearNode}
  58. <div className="flex-1">
  59. {inputNode}
  60. </div>
  61. {/* 发送按钮 - 右边 */}
  62. {styledSendNode}
  63. </div>
  64. </div>
  65. );
  66. };
  67. export default CustomInputRender;