/* * @Description: * @Version: 0.0.1 * @Author: yujiangping * @Date: 2026-01-13 11:44:06 * @LastEditors: yujiangping * @LastEditTime: 2026-01-15 20:59:57 */ import React, { useState, useRef } from 'react'; import { useTranslation } from 'react-i18next'; import { useNavigate } from 'react-router-dom'; import guideBgImg from '@/assets/images/index/guide_bg@2x.png' import { Button, Tour } from 'antd'; import type { TourProps } from 'antd'; import arrowRight from '@/assets/images/index/arrow_right_blue.svg' const GuideCard: React.FC = () => { const { t } = useTranslation(); const navigate = useNavigate(); const [open, setOpen] = useState(false); const [currentStep, setCurrentStep] = useState(0); const startButtonRef = useRef(null); // Tour 步骤配置 const steps: TourProps['steps'] = [ { title: t('indexTour.startTitle'), description: t('indexTour.startDescription'), target: () => startButtonRef.current!, }, { title: t('indexTour.stepOne'), description: t('indexTour.stepOneDescription'), target: () => document.querySelector('[data-menu-id="/model"]') as HTMLElement, }, { title: t('indexTour.stepTwo'), description: t('indexTour.stepTwoDescription'), target: () => document.querySelector('[data-menu-id="/space"]') as HTMLElement, }, { title: t('indexTour.stepThree'), description: t('indexTour.stepThreeDescription'), target: () => document.querySelector('[data-menu-id="/user-management"]') as HTMLElement, } ]; // 开始引导 const handleStartGuide = () => { setCurrentStep(0); setOpen(true); }; // Tour 步骤变化处理 const handleStepChange = (current: number) => { setCurrentStep(current); // 不再自动跳转页面,让用户通过点击菜单项来导航 }; // Tour 完成处理 const handleTourFinish = () => { setOpen(false); setCurrentStep(0); // 完成后导航到模型管理页面 navigate('/model'); }; return ( <>
{ t('index.getStarted')}
{ t('index.startedDesc')}
{/* */}
setOpen(false)} steps={steps} current={currentStep} onChange={handleStepChange} onFinish={handleTourFinish} /> ); }; export default GuideCard;