index.tsx 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. 'use client'
  2. import { useRef } from 'react'
  3. import cn from '@/utils/classnames'
  4. import { useTabSearchParams } from '@/hooks/use-tab-searchparams'
  5. import TabSliderNew from '@/app/components/base/tab-slider-new'
  6. import CorpusIndex from '@/app/components/skill/corpus'
  7. import IntentIndex from '@/app/components/skill/intent'
  8. import LogIndex from '@/app/components/skill/log'
  9. const SkillIndex = () => {
  10. const containerRef = useRef<HTMLDivElement>(null)
  11. const [activeTab, setActiveTab] = useTabSearchParams({
  12. defaultTab: 'corpus',
  13. })
  14. const options = [
  15. { value: 'corpus', text: '训练语料' },
  16. { value: 'intent', text: '意图识别' },
  17. { value: 'log', text: '训练日志' },
  18. ]
  19. return (
  20. <>
  21. <div className='relative flex h-0 shrink-0 grow flex-col overflow-hidden'>
  22. <div
  23. ref={containerRef}
  24. className='relative flex flex-col overflow-y-auto bg-background-body'
  25. >
  26. <div className={cn('sticky top-0 z-20 flex flex-wrap items-center justify-between gap-y-2 bg-background-body px-12 pb-2 pt-4 leading-[56px]')}>
  27. <TabSliderNew
  28. value={activeTab}
  29. onChange={(state) => {
  30. setActiveTab(state)
  31. }}
  32. options={options}
  33. />
  34. </div>
  35. </div>
  36. <div className="flex-1">
  37. {
  38. activeTab === 'corpus' && <CorpusIndex/>
  39. }
  40. {
  41. activeTab === 'intent' && <IntentIndex/>
  42. }
  43. {
  44. activeTab === 'log' && <LogIndex/>
  45. }
  46. </div>
  47. </div>
  48. </>
  49. )
  50. }
  51. SkillIndex.displayName = 'SkillIndex'
  52. export default SkillIndex