resume-wizard / script.js
hepansls's picture
你需要从本地路径读取json数据,例如resume.json,而不是直接展示resume_dict,resume_dict只是一个示例。
9bc6cc2 verified
function generateResumeContent(data, container) {
// Generate Education section
if (data.education && data.education.length > 0) {
const educationSection = document.createElement('resume-section');
educationSection.setAttribute('title', 'Education');
educationSection.setAttribute('icon', 'book');
let educationHTML = '<div class="space-y-6">';
data.education.forEach(edu => {
educationHTML += `
<div class="bg-white p-6 rounded-lg shadow-sm border border-gray-100">
<div class="flex justify-between items-start">
<div>
<h3 class="text-lg font-semibold">${edu.institution}</h3>
<p class="text-gray-600">${edu.degree} - ${edu.major}</p>
</div>
<span class="text-gray-500">${edu.startDate} - ${edu.endDate}</span>
</div>
<div class="mt-2">
<p class="text-gray-700"><span class="font-medium">GPA:</span> ${edu.gpa}</p>
<p class="text-gray-700 mt-1"><span class="font-medium">Courses:</span> ${edu.courses.join(', ')}</p>
</div>
</div>
`;
});
educationHTML += '</div>';
educationSection.innerHTML = educationHTML;
container.appendChild(educationSection);
}
// Generate Work Experience section
if (data.workExperience && data.workExperience.length > 0) {
const workSection = document.createElement('resume-section');
workSection.setAttribute('title', 'Work Experience');
workSection.setAttribute('icon', 'briefcase');
let workHTML = '<div class="space-y-6">';
data.workExperience.forEach(work => {
workHTML += `
<div class="bg-white p-6 rounded-lg shadow-sm border border-gray-100">
<div class="flex justify-between items-start">
<div>
<h3 class="text-lg font-semibold">${work.company}</h3>
<p class="text-gray-600">${work.position}</p>
</div>
<span class="text-gray-500">${work.startDate} - ${work.endDate}</span>
</div>
<ul class="mt-4 space-y-3 list-disc list-inside text-gray-700">
${work.responsibilities.map(resp => `<li>${resp}</li>`).join('')}
</ul>
</div>
`;
});
workHTML += '</div>';
workSection.innerHTML = workHTML;
container.appendChild(workSection);
}
// Generate Publications section
if (data.publications && data.publications.length > 0) {
const pubSection = document.createElement('resume-section');
pubSection.setAttribute('title', 'Research Publications');
pubSection.setAttribute('icon', 'file-text');
let pubHTML = '<div class="space-y-6">';
data.publications.forEach(pub => {
pubHTML += `
<div class="bg-white p-6 rounded-lg shadow-sm border border-gray-100">
<h3 class="text-lg font-semibold">${pub.title}</h3>
<p class="text-gray-600 mt-1">${pub.authors} | ${pub.conference} | ${pub.year}</p>
<p class="text-gray-700 mt-2">${pub.description}</p>
</div>
`;
});
pubHTML += '</div>';
pubSection.innerHTML = pubHTML;
container.appendChild(pubSection);
}
// Generate Skills section
if (data.skills && data.skills.length > 0) {
const skillsSection = document.createElement('resume-section');
skillsSection.setAttribute('title', 'Skills');
skillsSection.setAttribute('icon', 'code');
const skillsHTML = `
<div class="bg-white p-6 rounded-lg shadow-sm border border-gray-100">
<ul class="space-y-3 list-disc list-inside text-gray-700">
${data.skills.map(skill => `<li>${skill}</li>`).join('')}
</ul>
</div>
`;
skillsSection.innerHTML = skillsHTML;
container.appendChild(skillsSection);
}
// Generate Awards section
if (data.awards && data.awards.length > 0) {
const awardsSection = document.createElement('resume-section');
awardsSection.setAttribute('title', 'Awards');
awardsSection.setAttribute('icon', 'award');
let awardsHTML = '<div class="grid grid-cols-1 md:grid-cols-2 gap-4">';
data.awards.forEach(award => {
awardsHTML += `
<div class="bg-white p-4 rounded-lg shadow-sm border border-gray-100">
<h4 class="font-medium">${award.name}</h4>
<p class="text-gray-600 text-sm mt-1">${award.date}</p>
</div>
`;
});
awardsHTML += '</div>';
awardsSection.innerHTML = awardsHTML;
container.appendChild(awardsSection);
}
// Generate Self Assessment section
if (data.selfAssessment) {
const selfSection = document.createElement('resume-section');
selfSection.setAttribute('title', 'Self Assessment');
selfSection.setAttribute('icon', 'user');
const selfHTML = `
<div class="bg-white p-6 rounded-lg shadow-sm border border-gray-100">
<p class="text-gray-700">${data.selfAssessment}</p>
</div>
`;
selfSection.innerHTML = selfHTML;
container.appendChild(selfSection);
}
}