/** * MBTI人格测试工具函数 */ // MBTI测试题目库(简化版,包含16个核心题目) export const MBTI_QUESTIONS = [ // E(外向) vs I(内向) - 4题 { id: 1, question: '在聚会中,你通常会:', type: 'choice', dimension: 'EI', options: [ { text: '主动与新朋友交谈,享受热闹的气氛', score: { E: 2, I: 0 } }, { text: '与少数熟悉的朋友深入交流', score: { E: 0, I: 2 } } ] }, { id: 2, question: '工作时,你更喜欢:', type: 'choice', dimension: 'EI', options: [ { text: '在开放的环境中与同事协作', score: { E: 2, I: 0 } }, { text: '在安静的环境中独立工作', score: { E: 0, I: 2 } } ] }, { id: 3, question: '休息时间,你倾向于:', type: 'choice', dimension: 'EI', options: [ { text: '出去活动,与朋友聚会', score: { E: 2, I: 0 } }, { text: '在家安静地放松,独处或看书', score: { E: 0, I: 2 } } ] }, { id: 4, question: '面对压力时,你会:', type: 'choice', dimension: 'EI', options: [ { text: '寻求朋友的陪伴和支持', score: { E: 2, I: 0 } }, { text: '独自思考,寻找解决方案', score: { E: 0, I: 2 } } ] }, // S(感觉) vs N(直觉) - 4题 { id: 5, question: '学习新知识时,你更喜欢:', type: 'choice', dimension: 'SN', options: [ { text: '从具体的例子和实践中学习', score: { S: 2, N: 0 } }, { text: '理解概念和理论框架', score: { S: 0, N: 2 } } ] }, { id: 6, question: '你更关注:', type: 'choice', dimension: 'SN', options: [ { text: '当下的事实和细节', score: { S: 2, N: 0 } }, { text: '未来的可能性和潜力', score: { S: 0, N: 2 } } ] }, { id: 7, question: '描述一个地方时,你会:', type: 'choice', dimension: 'SN', options: [ { text: '详细描述看到的具体景物', score: { S: 2, N: 0 } }, { text: '描述那里的氛围和感受', score: { S: 0, N: 2 } } ] }, { id: 8, question: '你更信任:', type: 'choice', dimension: 'SN', options: [ { text: '已被证实的方法和经验', score: { S: 2, N: 0 } }, { text: '新颖的想法和创新方案', score: { S: 0, N: 2 } } ] }, // T(思考) vs F(情感) - 4题 { id: 9, question: '做决定时,你主要考虑:', type: 'choice', dimension: 'TF', options: [ { text: '逻辑分析和客观事实', score: { T: 2, F: 0 } }, { text: '个人价值观和他人感受', score: { T: 0, F: 2 } } ] }, { id: 10, question: '批评他人时,你会:', type: 'choice', dimension: 'TF', options: [ { text: '直接指出问题所在', score: { T: 2, F: 0 } }, { text: '考虑对方感受,委婉表达', score: { T: 0, F: 2 } } ] }, { id: 11, question: '你更重视:', type: 'choice', dimension: 'TF', options: [ { text: '公平和原则', score: { T: 2, F: 0 } }, { text: '和谐和理解', score: { T: 0, F: 2 } } ] }, { id: 12, question: '解决冲突时,你倾向于:', type: 'choice', dimension: 'TF', options: [ { text: '分析问题,寻找最优解', score: { T: 2, F: 0 } }, { text: '关注各方情感,寻求妥协', score: { T: 0, F: 2 } } ] }, // J(判断) vs P(知觉) - 4题 { id: 13, question: '对于计划,你的态度是:', type: 'choice', dimension: 'JP', options: [ { text: '制定详细计划并严格执行', score: { J: 2, P: 0 } }, { text: '保持灵活,根据情况调整', score: { J: 0, P: 2 } } ] }, { id: 14, question: '工作环境中,你喜欢:', type: 'choice', dimension: 'JP', options: [ { text: '有明确的截止日期和规范', score: { J: 2, P: 0 } }, { text: '灵活的时间安排和自由度', score: { J: 0, P: 2 } } ] }, { id: 15, question: '面对选择时,你会:', type: 'choice', dimension: 'JP', options: [ { text: '快速决定,然后坚持下去', score: { J: 2, P: 0 } }, { text: '保持开放,随时准备改变', score: { J: 0, P: 2 } } ] }, { id: 16, question: '你的生活方式更像:', type: 'choice', dimension: 'JP', options: [ { text: '有条不紊,按计划进行', score: { J: 2, P: 0 } }, { text: '随性自然,充满变化', score: { J: 0, P: 2 } } ] } ] // MBTI 16种人格类型数据 export const MBTI_TYPES = { INTJ: { type: 'INTJ', name: '建筑师', description: '富有想象力和战略性的思想家,一切皆在计划之中。', traits: ['独立', '有远见', '坚定', '追求完美', '善于规划'], careers: ['软件工程师', '科学家', '建筑师', '战略规划师', '投资分析师'], loveStyle: '在恋爱中寻求深度和意义,重视心灵契合,需要理解和空间。', compatibility: ['ENFP', 'ENTP', 'INFJ'], dimensions: [ { name: '内向(I) vs 外向(E)', percent: 75, color: '#667eea', description: '更喜欢独处思考' }, { name: '直觉(N) vs 感觉(S)', percent: 85, color: '#764ba2', description: '关注未来可能性' }, { name: '思考(T) vs 情感(F)', percent: 80, color: '#f093fb', description: '逻辑导向决策' }, { name: '判断(J) vs 知觉(P)', percent: 90, color: '#f5576c', description: '喜欢计划和结构' } ] }, INTP: { type: 'INTP', name: '思想家', description: '创新的发明者,对知识有着止不住的渴望。', traits: ['好奇心强', '独立思考', '逻辑清晰', '创新', '灵活'], careers: ['研究员', '哲学家', '数学家', '程序员', '理论物理学家'], loveStyle: '重视智力交流和精神连接,需要个人空间和理解。', compatibility: ['ENFJ', 'ENTJ', 'INFP'], dimensions: [ { name: '内向(I) vs 外向(E)', percent: 70, color: '#667eea', description: '更喜欢独处思考' }, { name: '直觉(N) vs 感觉(S)', percent: 80, color: '#764ba2', description: '关注理论和概念' }, { name: '思考(T) vs 情感(F)', percent: 85, color: '#f093fb', description: '逻辑导向决策' }, { name: '判断(J) vs 知觉(P)', percent: 25, color: '#f5576c', description: '保持灵活开放' } ] }, ENTJ: { type: 'ENTJ', name: '指挥官', description: '大胆、富有想象力、意志强烈的领导者,总能找到或创造解决方法。', traits: ['领导力强', '果断', '自信', '有野心', '善于规划'], careers: ['CEO', '管理顾问', '律师', '投资银行家', '企业家'], loveStyle: '直接而热情,寻求能够匹配其野心和智慧的伴侣。', compatibility: ['INFP', 'INTP', 'ENFP'], dimensions: [ { name: '内向(I) vs 外向(E)', percent: 25, color: '#667eea', description: '精力来源于外界' }, { name: '直觉(N) vs 感觉(S)', percent: 80, color: '#764ba2', description: '关注大局和未来' }, { name: '思考(T) vs 情感(F)', percent: 85, color: '#f093fb', description: '理性客观决策' }, { name: '判断(J) vs 知觉(P)', percent: 90, color: '#f5576c', description: '喜欢控制和计划' } ] }, ENTP: { type: 'ENTP', name: '辩论家', description: '聪明好奇的思想者,不能抗拒智力上的挑战。', traits: ['创新', '机智', '热情', '善于辩论', '适应力强'], careers: ['创业家', '市场营销', '记者', '心理学家', '发明家'], loveStyle: '充满激情和创意,喜欢智力刺激的关系。', compatibility: ['INFJ', 'INTJ', 'ENFJ'], dimensions: [ { name: '内向(I) vs 外向(E)', percent: 20, color: '#667eea', description: '外向活跃' }, { name: '直觉(N) vs 感觉(S)', percent: 85, color: '#764ba2', description: '充满创意想法' }, { name: '思考(T) vs 情感(F)', percent: 75, color: '#f093fb', description: '逻辑分析优先' }, { name: '判断(J) vs 知觉(P)', percent: 20, color: '#f5576c', description: '灵活适应' } ] }, INFJ: { type: 'INFJ', name: '提倡者', description: '安静而神秘,同时鼓舞他人的理想主义者。', traits: ['有洞察力', '理想主义', '有决心', '富有创意', '利他主义'], careers: ['心理咨询师', '作家', '教师', '人力资源', '非营利组织工作者'], loveStyle: '寻求深层的情感连接,重视精神契合和相互成长。', compatibility: ['ENTP', 'ENFP', 'INTJ'], dimensions: [ { name: '内向(I) vs 外向(E)', percent: 80, color: '#667eea', description: '内向但关心他人' }, { name: '直觉(N) vs 感觉(S)', percent: 85, color: '#764ba2', description: '洞察力强' }, { name: '思考(T) vs 情感(F)', percent: 30, color: '#f093fb', description: '重视价值观和情感' }, { name: '判断(J) vs 知觉(P)', percent: 80, color: '#f5576c', description: '有条理有决断' } ] }, INFP: { type: 'INFP', name: '调停者', description: '富有诗意、善良、利他的人,总是热切地寻求帮助好的事业。', traits: ['理想主义', '忠诚', '适应性强', '好奇心强', '善于表达'], careers: ['作家', '艺术家', '心理学家', '社工', '人力资源专员'], loveStyle: '温暖而深情,重视真诚和个人价值观的匹配。', compatibility: ['ENFJ', 'ENTJ', 'INFJ'], dimensions: [ { name: '内向(I) vs 外向(E)', percent: 85, color: '#667eea', description: '需要安静的环境' }, { name: '直觉(N) vs 感觉(S)', percent: 80, color: '#764ba2', description: '关注可能性' }, { name: '思考(T) vs 情感(F)', percent: 20, color: '#f093fb', description: '价值观驱动' }, { name: '判断(J) vs 知觉(P)', percent: 25, color: '#f5576c', description: '灵活开放' } ] }, ENFJ: { type: 'ENFJ', name: '主人公', description: '富有魅力、鼓舞人心的领导者,有能力吸引听众。', traits: ['有感染力', '可靠', '利他主义', '善于沟通', '天生的领导者'], careers: ['教师', '人力资源', '政治家', '心理咨询师', '公关专员'], loveStyle: '热情而支持性强,致力于伴侣的成长和幸福。', compatibility: ['INFP', 'ISFP', 'INTP'], dimensions: [ { name: '内向(I) vs 外向(E)', percent: 20, color: '#667eea', description: '外向且善于社交' }, { name: '直觉(N) vs 感觉(S)', percent: 80, color: '#764ba2', description: '有远见有洞察' }, { name: '思考(T) vs 情感(F)', percent: 25, color: '#f093fb', description: '以人为本' }, { name: '判断(J) vs 知觉(P)', percent: 85, color: '#f5576c', description: '有组织有计划' } ] }, ENFP: { type: 'ENFP', name: '竞选者', description: '热情、有创造力、社交能力强的自由精神,总能找到微笑的理由。', traits: ['热情', '创造力', '社交能力强', '好奇心强', '精力充沛'], careers: ['市场营销', '记者', '演员', '心理学家', '创业家'], loveStyle: '充满激情和创意,寻求能够分享冒险和梦想的伴侣。', compatibility: ['INTJ', 'INFJ', 'ENTJ'], dimensions: [ { name: '内向(I) vs 外向(E)', percent: 15, color: '#667eea', description: '外向且充满活力' }, { name: '直觉(N) vs 感觉(S)', percent: 85, color: '#764ba2', description: '想象力丰富' }, { name: '思考(T) vs 情感(F)', percent: 30, color: '#f093fb', description: '重视个人价值' }, { name: '判断(J) vs 知觉(P)', percent: 20, color: '#f5576c', description: '灵活自发' } ] }, ISTJ: { type: 'ISTJ', name: '物流师', description: '实用主义的逻辑学家,忠实可靠。', traits: ['责任心强', '实际', '有条理', '传统', '诚实正直'], careers: ['会计师', '审计员', '银行家', '法官', '工程师'], loveStyle: '忠诚可靠,通过实际行动表达爱意。', compatibility: ['ESFP', 'ESTP', 'ISFP'], dimensions: [ { name: '内向(I) vs 外向(E)', percent: 80, color: '#667eea', description: '内向且专注' }, { name: '直觉(N) vs 感觉(S)', percent: 20, color: '#764ba2', description: '注重事实细节' }, { name: '思考(T) vs 情感(F)', percent: 75, color: '#f093fb', description: '逻辑决策' }, { name: '判断(J) vs 知觉(P)', percent: 90, color: '#f5576c', description: '有序可靠' } ] }, ISFJ: { type: 'ISFJ', name: '守护者', description: '非常专注、温暖的守护者,时刻准备保护挚爱的人。', traits: ['支持性强', '可靠', '耐心', '勤奋', '忠诚'], careers: ['护士', '教师', '社工', '人力资源', '心理咨询师'], loveStyle: '温暖体贴,通过照顾和支持表达爱意。', compatibility: ['ESTP', 'ESFP', 'ISFP'], dimensions: [ { name: '内向(I) vs 外向(E)', percent: 75, color: '#667eea', description: '内向但关心他人' }, { name: '直觉(N) vs 感觉(S)', percent: 25, color: '#764ba2', description: '关注现实需求' }, { name: '思考(T) vs 情感(F)', percent: 20, color: '#f093fb', description: '情感导向' }, { name: '判断(J) vs 知觉(P)', percent: 85, color: '#f5576c', description: '有条理负责' } ] }, ESTJ: { type: 'ESTJ', name: '总经理', description: '出色的管理者,在管理事情和人员方面无与伦比。', traits: ['组织能力强', '实际', '逻辑性强', '果断', '忠诚'], careers: ['经理', '行政人员', '法官', '老师', '销售经理'], loveStyle: '传统而稳定,重视承诺和家庭责任。', compatibility: ['ISFP', 'INFP', 'ISTP'], dimensions: [ { name: '内向(I) vs 外向(E)', percent: 15, color: '#667eea', description: '外向且善于领导' }, { name: '直觉(N) vs 感觉(S)', percent: 25, color: '#764ba2', description: '务实现实' }, { name: '思考(T) vs 情感(F)', percent: 80, color: '#f093fb', description: '客观理性' }, { name: '判断(J) vs 知觉(P)', percent: 90, color: '#f5576c', description: '组织性强' } ] }, ESFJ: { type: 'ESFJ', name: '执政官', description: '非常关心他人、社交能力强、在意他人需要的人。', traits: ['热心', '负责任', '合作', '善于社交', '忠诚'], careers: ['护士', '教师', '社工', '客服代表', '活动策划'], loveStyle: '温暖支持,重视和谐的关系和共同的价值观。', compatibility: ['ISFP', 'INFP', 'ISTP'], dimensions: [ { name: '内向(I) vs 外向(E)', percent: 20, color: '#667eea', description: '外向且善于交际' }, { name: '直觉(N) vs 感觉(S)', percent: 30, color: '#764ba2', description: '关注具体需求' }, { name: '思考(T) vs 情感(F)', percent: 25, color: '#f093fb', description: '重视他人感受' }, { name: '判断(J) vs 知觉(P)', percent: 80, color: '#f5576c', description: '有条理有责任' } ] }, ISTP: { type: 'ISTP', name: '鉴赏家', description: '大胆而务实的实验家,善于使用各种工具。', traits: ['独立', '适应性强', '务实', '灵活', '好奇心强'], careers: ['工程师', '机械师', '飞行员', '法医', '运动员'], loveStyle: '独立而低调,通过行动而非言语表达关爱。', compatibility: ['ESFJ', 'ESTJ', 'ENFJ'], dimensions: [ { name: '内向(I) vs 外向(E)', percent: 85, color: '#667eea', description: '独立内向' }, { name: '直觉(N) vs 感觉(S)', percent: 20, color: '#764ba2', description: '关注现实操作' }, { name: '思考(T) vs 情感(F)', percent: 80, color: '#f093fb', description: '逻辑分析' }, { name: '判断(J) vs 知觉(P)', percent: 25, color: '#f5576c', description: '灵活适应' } ] }, ISFP: { type: 'ISFP', name: '探险家', description: '灵活、迷人的艺术家,时刻准备探索新的可能性。', traits: ['友善', '敏感', '温和', '艺术天赋', '价值观强'], careers: ['艺术家', '音乐家', '心理咨询师', '兽医', '厨师'], loveStyle: '温柔而深情,重视个人空间和价值观的契合。', compatibility: ['ENFJ', 'ESFJ', 'ESTJ'], dimensions: [ { name: '内向(I) vs 外向(E)', percent: 80, color: '#667eea', description: '内向且敏感' }, { name: '直觉(N) vs 感觉(S)', percent: 30, color: '#764ba2', description: '注重当下体验' }, { name: '思考(T) vs 情感(F)', percent: 15, color: '#f093fb', description: '价值观导向' }, { name: '判断(J) vs 知觉(P)', percent: 20, color: '#f5576c', description: '灵活开放' } ] }, ESTP: { type: 'ESTP', name: '企业家', description: '聪明、精力充沛、善于感知的人,真正享受生活在边缘的感觉。', traits: ['精力充沛', '实际', '友善', '适应性强', '善于观察'], careers: ['销售', '企业家', '娱乐业', '紧急服务', '运动员'], loveStyle: '活跃而有趣,喜欢充满活力和冒险的关系。', compatibility: ['ISFJ', 'ISTJ', 'INFJ'], dimensions: [ { name: '内向(I) vs 外向(E)', percent: 10, color: '#667eea', description: '外向且活跃' }, { name: '直觉(N) vs 感觉(S)', percent: 15, color: '#764ba2', description: '注重现实体验' }, { name: '思考(T) vs 情感(F)', percent: 75, color: '#f093fb', description: '实用主义' }, { name: '判断(J) vs 知觉(P)', percent: 15, color: '#f5576c', description: '灵活自发' } ] }, ESFP: { type: 'ESFP', name: '表演者', description: '自发的、精力充沛、热情的表演者——生活在他们周围绝不无聊。', traits: ['热情', '友善', '自发', '灵活', '善于激励他人'], careers: ['表演者', '教师', '社工', '销售', '活动策划'], loveStyle: '热情而浪漫,喜欢分享快乐和创造美好回忆。', compatibility: ['ISFJ', 'ISTJ', 'INFJ'], dimensions: [ { name: '内向(I) vs 外向(E)', percent: 5, color: '#667eea', description: '极度外向' }, { name: '直觉(N) vs 感觉(S)', percent: 20, color: '#764ba2', description: '享受当下' }, { name: '思考(T) vs 情感(F)', percent: 20, color: '#f093fb', description: '情感丰富' }, { name: '判断(J) vs 知觉(P)', percent: 10, color: '#f5576c', description: '自发灵活' } ] } } /** * 计算MBTI结果 * @param {Array} answers - 用户答案数组 * @returns {String} MBTI类型 (如: 'INTJ') */ export function calculateMBTI(answers) { if (!answers || answers.length !== MBTI_QUESTIONS.length) { throw new Error('答案数据不完整') } // 初始化各维度得分 const scores = { E: 0, I: 0, // 外向 vs 内向 S: 0, N: 0, // 感觉 vs 直觉 T: 0, F: 0, // 思考 vs 情感 J: 0, P: 0 // 判断 vs 知觉 } // 计算各维度得分 answers.forEach((answer, index) => { const question = MBTI_QUESTIONS[index] if (answer !== null && question && question.options[answer]) { const option = question.options[answer] Object.keys(option.score).forEach(key => { scores[key] += option.score[key] }) } }) // 确定每个维度的倾向 const result = [ scores.E > scores.I ? 'E' : 'I', scores.S > scores.N ? 'S' : 'N', scores.T > scores.F ? 'T' : 'F', scores.J > scores.P ? 'J' : 'P' ].join('') return result } /** * 获取维度分析数据 * @param {Array} answers - 用户答案数组 * @returns {Object} 维度分析结果 */ export function getDimensionAnalysis(answers) { const scores = { E: 0, I: 0, S: 0, N: 0, T: 0, F: 0, J: 0, P: 0 } // 计算得分 answers.forEach((answer, index) => { const question = MBTI_QUESTIONS[index] if (answer !== null && question && question.options[answer]) { const option = question.options[answer] Object.keys(option.score).forEach(key => { scores[key] += option.score[key] }) } }) // 计算百分比 return { EI: { E: Math.round((scores.E / (scores.E + scores.I)) * 100), I: Math.round((scores.I / (scores.E + scores.I)) * 100) }, SN: { S: Math.round((scores.S / (scores.S + scores.N)) * 100), N: Math.round((scores.N / (scores.S + scores.N)) * 100) }, TF: { T: Math.round((scores.T / (scores.T + scores.F)) * 100), F: Math.round((scores.F / (scores.T + scores.F)) * 100) }, JP: { J: Math.round((scores.J / (scores.J + scores.P)) * 100), P: Math.round((scores.P / (scores.J + scores.P)) * 100) } } } /** * 获取MBTI类型的详细信息 * @param {String} type - MBTI类型 * @returns {Object} 类型详细信息 */ export function getMBTITypeInfo(type) { return MBTI_TYPES[type] || null } /** * 获取随机的MBTI小贴士 * @returns {String} 小贴士文本 */ export function getRandomTip() { const tips = [ 'MBTI只是了解自己的工具之一,不要完全依赖测试结果', '人格类型会随着年龄和经历发生变化', '每种类型都有其独特的优势,没有好坏之分', '了解伴侣的MBTI类型有助于建立更好的关系', '在团队合作中,不同类型的人能够发挥不同的优势' ] return tips[Math.floor(Math.random() * tips.length)] }