import { useRef, useState, useEffect } from "react"; import { Spin, Empty } from "@arco-design/web-react"; import toast from "@/components/Toast"; import InterviewQuestionsModal from "./components/InterviewQuestionsModal"; import ResumeInfoModal from "@/pages/CompanyJobsPage/components/ResumeInfoModal"; import { getPageData } from "@/services/resumeInterview"; import "./index.css"; const ResumeInterviewPage = () => { const [activeIndustry, setActiveIndustry] = useState("frontend"); const [interviewModalVisible, setInterviewModalVisible] = useState(false); const [resumeModalVisible, setResumeModalVisible] = useState(false); const [interviewModalData, setInterviewModalData] = useState(undefined); const [resumeModalData, setResumeModalData] = useState(undefined); const [pageData, setPageData] = useState(null); const [loading, setLoading] = useState(true); const sectionsRef = useRef({}); // 导航到指定行业段落 const handleNavClick = (industryId) => { setActiveIndustry(industryId); sectionsRef.current[industryId]?.scrollIntoView({ behavior: "smooth", block: "start", }); }; // 面试题点击处理 const handleQuestionClick = (item) => { if (item) { setInterviewModalVisible(true); setInterviewModalData(item); } else { toast.error("加载数据失败"); } }; // 职位点击处理 const handlePositionClick = (position, industry) => { // Find resume templates for this industry const templates = pageData.resumeTemplates[industry.name] || []; // 首先根据岗位名称精确匹配 const selectedTemplate = templates.find((t) => t.position === position.title) || templates.find((t) => t.level === position.level) || templates[0]; setResumeModalData({ selectedTemplate, studentResume: pageData.myResume, }); setResumeModalVisible(true); }; const handleCloseInterviewModal = () => { setInterviewModalVisible(false); setInterviewModalData(undefined); }; const handleCloseResumeModal = () => { setResumeModalVisible(false); setResumeModalData(undefined); }; const filterPositions = (positions) => { return positions.filter((position) => position.title?.toLowerCase()); }; // 获取页面数据 useEffect(() => { const fetchPageData = async () => { try { setLoading(true); const response = await getPageData(); if (response.success) { console.log('页面数据加载成功:', response.data); setPageData(response.data); // 设置默认选中第一个行业 if (response.data.industries && response.data.industries.length > 0) { setActiveIndustry(response.data.industries[0].id); } } } catch (error) { console.error("Failed to fetch page data:", error); } finally { setLoading(false); } }; fetchPageData(); }, []); // 监听滚动位置更新导航状态 useEffect(() => { if (!pageData?.industries) return; const handleScroll = () => { const scrollPosition = window.scrollY + 200; pageData.industries.forEach((industry) => { const section = sectionsRef.current[industry.id]; if (section) { const sectionTop = section.offsetTop; const sectionBottom = sectionTop + section.offsetHeight; if (scrollPosition >= sectionTop && scrollPosition < sectionBottom) { setActiveIndustry(industry.id); } } }); }; window.addEventListener("scroll", handleScroll); return () => window.removeEventListener("scroll", handleScroll); }, [pageData?.industries]); // 添加鼠标滚轮横向滚动功能 useEffect(() => { const navigation = document.querySelector('.resume-interview-navigation'); if (!navigation) return; const handleWheel = (e) => { const tabs = navigation.querySelector('.navigation-tabs'); if (!tabs) return; // 检查是否在导航栏区域 if (e.currentTarget === navigation || navigation.contains(e.target)) { if (Math.abs(e.deltaY) > Math.abs(e.deltaX)) { e.preventDefault(); tabs.scrollLeft += e.deltaY * 0.5; // 减慢滚动速度使其更平滑 } } }; navigation.addEventListener('wheel', handleWheel, { passive: false }); return () => navigation.removeEventListener('wheel', handleWheel); }, []); return (
{item.name}
简历与面试题
{position.title}
详情 >{question.question}