SyncWizardModal.jsx 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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, { useEffect, useState } from 'react';
  16. import { Modal, RadioGroup, Radio, Steps, Button } from '@douyinfe/semi-ui';
  17. import { useIsMobile } from '../../../../hooks/common/useIsMobile';
  18. const SyncWizardModal = ({ visible, onClose, onConfirm, loading, t }) => {
  19. const [step, setStep] = useState(0);
  20. const [option, setOption] = useState('official');
  21. const [locale, setLocale] = useState('zh-CN');
  22. const isMobile = useIsMobile();
  23. useEffect(() => {
  24. if (visible) {
  25. setStep(0);
  26. setOption('official');
  27. setLocale('zh-CN');
  28. }
  29. }, [visible]);
  30. return (
  31. <Modal
  32. title={t('同步向导')}
  33. visible={visible}
  34. onCancel={onClose}
  35. footer={
  36. <div className='flex justify-end'>
  37. {step === 1 && (
  38. <Button onClick={() => setStep(0)}>{t('上一步')}</Button>
  39. )}
  40. <Button onClick={onClose}>{t('取消')}</Button>
  41. {step === 0 && (
  42. <Button
  43. type='primary'
  44. onClick={() => setStep(1)}
  45. disabled={option !== 'official'}
  46. >
  47. {t('下一步')}
  48. </Button>
  49. )}
  50. {step === 1 && (
  51. <Button
  52. type='primary'
  53. theme='solid'
  54. loading={loading}
  55. onClick={async () => {
  56. await onConfirm?.({ option, locale });
  57. }}
  58. >
  59. {t('开始同步')}
  60. </Button>
  61. )}
  62. </div>
  63. }
  64. width={isMobile ? '100%' : 'small'}
  65. >
  66. <div className='mb-3'>
  67. <Steps type='basic' current={step} size='small'>
  68. <Steps.Step title={t('选择方式')} description={t('选择同步来源')} />
  69. <Steps.Step title={t('选择语言')} description={t('选择同步语言')} />
  70. </Steps>
  71. </div>
  72. {step === 0 && (
  73. <div className='mt-2 flex justify-center'>
  74. <RadioGroup
  75. value={option}
  76. onChange={(e) => setOption(e?.target?.value ?? e)}
  77. type='card'
  78. direction='horizontal'
  79. aria-label='同步方式选择'
  80. name='sync-mode-selection'
  81. >
  82. <Radio value='official' extra={t('从官方模型库同步')}>
  83. {t('官方模型同步')}
  84. </Radio>
  85. <Radio value='config' extra={t('从配置文件同步')} disabled>
  86. {t('配置文件同步')}
  87. </Radio>
  88. </RadioGroup>
  89. </div>
  90. )}
  91. {step === 1 && (
  92. <div className='mt-2'>
  93. <div className='mb-2 text-[var(--semi-color-text-2)]'>
  94. {t('请选择同步语言')}
  95. </div>
  96. <div className='flex justify-center'>
  97. <RadioGroup
  98. value={locale}
  99. onChange={(e) => setLocale(e?.target?.value ?? e)}
  100. type='card'
  101. direction='horizontal'
  102. aria-label='语言选择'
  103. name='sync-locale-selection'
  104. >
  105. <Radio value='en' extra='English'>
  106. en
  107. </Radio>
  108. <Radio value='zh-CN' extra='简体中文'>
  109. zh-CN
  110. </Radio>
  111. <Radio value='zh-TW' extra='繁體中文'>
  112. zh-TW
  113. </Radio>
  114. <Radio value='ja' extra='日本語'>
  115. ja
  116. </Radio>
  117. </RadioGroup>
  118. </div>
  119. </div>
  120. )}
  121. </Modal>
  122. );
  123. };
  124. export default SyncWizardModal;