FaqPanel.jsx 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. import { Card, Collapse, Empty } from '@douyinfe/semi-ui';
  17. import { HelpCircle } from 'lucide-react';
  18. import { IconPlus, IconMinus } from '@douyinfe/semi-icons';
  19. import { marked } from 'marked';
  20. import {
  21. IllustrationConstruction,
  22. IllustrationConstructionDark,
  23. } from '@douyinfe/semi-illustrations';
  24. import ScrollableContainer from '../common/ui/ScrollableContainer';
  25. const FaqPanel = ({
  26. faqData,
  27. CARD_PROPS,
  28. FLEX_CENTER_GAP2,
  29. ILLUSTRATION_SIZE,
  30. t,
  31. }) => {
  32. return (
  33. <Card
  34. {...CARD_PROPS}
  35. className='shadow-sm !rounded-2xl lg:col-span-1'
  36. title={
  37. <div className={FLEX_CENTER_GAP2}>
  38. <HelpCircle size={16} />
  39. {t('常见问答')}
  40. </div>
  41. }
  42. bodyStyle={{ padding: 0 }}
  43. >
  44. <ScrollableContainer maxHeight='24rem'>
  45. {faqData.length > 0 ? (
  46. <Collapse
  47. accordion
  48. expandIcon={<IconPlus />}
  49. collapseIcon={<IconMinus />}
  50. >
  51. {faqData.map((item, index) => (
  52. <Collapse.Panel
  53. key={index}
  54. header={item.question}
  55. itemKey={index.toString()}
  56. >
  57. <div
  58. dangerouslySetInnerHTML={{
  59. __html: marked.parse(item.answer || ''),
  60. }}
  61. />
  62. </Collapse.Panel>
  63. ))}
  64. </Collapse>
  65. ) : (
  66. <div className='flex justify-center items-center py-8'>
  67. <Empty
  68. image={<IllustrationConstruction style={ILLUSTRATION_SIZE} />}
  69. darkModeImage={
  70. <IllustrationConstructionDark style={ILLUSTRATION_SIZE} />
  71. }
  72. title={t('暂无常见问答')}
  73. description={t('请联系管理员在系统设置中配置常见问答')}
  74. />
  75. </div>
  76. )}
  77. </ScrollableContainer>
  78. </Card>
  79. );
  80. };
  81. export default FaqPanel;