100 lines
4.1 KiB
JavaScript
100 lines
4.1 KiB
JavaScript
|
|
// 验证岗位剩余招聘量隐藏逻辑
|
|||
|
|
|
|||
|
|
const fs = require('fs');
|
|||
|
|
const path = require('path');
|
|||
|
|
|
|||
|
|
console.log('🔍 验证岗位剩余招聘量隐藏逻辑\n');
|
|||
|
|
console.log('='.repeat(80));
|
|||
|
|
|
|||
|
|
// 检查 JobInfoModal 组件
|
|||
|
|
console.log('\n1. 检查 JobInfoModal/index.jsx');
|
|||
|
|
const jsxContent = fs.readFileSync(
|
|||
|
|
path.join(__dirname, 'src/pages/CompanyJobsPage/components/JobInfoModal/index.jsx'),
|
|||
|
|
'utf-8'
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
// 查找剩余招聘量的展示逻辑
|
|||
|
|
const remainingPositionsMatch = jsxContent.match(/\{[^}]*!data\?\.\isDelivered[^}]*岗位招聘数量仅剩[^}]*\}/s);
|
|||
|
|
|
|||
|
|
if (remainingPositionsMatch) {
|
|||
|
|
console.log(' ✅ 找到岗位剩余招聘量展示逻辑');
|
|||
|
|
|
|||
|
|
const logicBlock = remainingPositionsMatch[0];
|
|||
|
|
|
|||
|
|
// 检查各个条件
|
|||
|
|
const hasIsDeliveredCheck = logicBlock.includes('!data?.isDelivered');
|
|||
|
|
console.log(` ${hasIsDeliveredCheck ? '✅' : '❌'} 检查已投递状态 (!data?.isDelivered)`);
|
|||
|
|
|
|||
|
|
const hasIsExpiredCheck = logicBlock.includes('!data?.isExpired');
|
|||
|
|
console.log(` ${hasIsExpiredCheck ? '✅' : '❌'} 检查已过期状态 (!data?.isExpired)`);
|
|||
|
|
|
|||
|
|
const hasStatusExpiredCheck = logicBlock.includes("data?.status !== 'expired'");
|
|||
|
|
console.log(` ${hasStatusExpiredCheck ? '✅' : '❌'} 检查status过期状态 (data?.status !== 'expired')`);
|
|||
|
|
|
|||
|
|
const hasHideDeliverButtonCheck = logicBlock.includes('!hideDeliverButton');
|
|||
|
|
console.log(` ${hasHideDeliverButtonCheck ? '✅' : '❌'} 检查面试状态 (!hideDeliverButton)`);
|
|||
|
|
|
|||
|
|
const hasRemainingPositionsCheck = logicBlock.includes('data?.remainingPositions');
|
|||
|
|
console.log(` ${hasRemainingPositionsCheck ? '✅' : '❌'} 检查剩余招聘量存在 (data?.remainingPositions)`);
|
|||
|
|
|
|||
|
|
console.log('\n 📋 完整逻辑:');
|
|||
|
|
console.log(' 只有同时满足以下所有条件时才显示剩余招聘量:');
|
|||
|
|
console.log(' 1. 岗位未投递 (!isDelivered)');
|
|||
|
|
console.log(' 2. 岗位未过期 (!isExpired)');
|
|||
|
|
console.log(' 3. 岗位状态不是expired (status !== "expired")');
|
|||
|
|
console.log(' 4. 不隐藏投递按钮,即非面试状态点击 (!hideDeliverButton)');
|
|||
|
|
console.log(' 5. 存在剩余招聘量数据 (remainingPositions)');
|
|||
|
|
|
|||
|
|
const allConditionsMet =
|
|||
|
|
hasIsDeliveredCheck &&
|
|||
|
|
hasIsExpiredCheck &&
|
|||
|
|
hasStatusExpiredCheck &&
|
|||
|
|
hasHideDeliverButtonCheck &&
|
|||
|
|
hasRemainingPositionsCheck;
|
|||
|
|
|
|||
|
|
console.log(`\n ${allConditionsMet ? '✅' : '❌'} 所有必要条件都已实现`);
|
|||
|
|
|
|||
|
|
} else {
|
|||
|
|
console.log(' ❌ 未找到岗位剩余招聘量展示逻辑');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 检查 CompanyJobsPage 组件中的数据传递
|
|||
|
|
console.log('\n2. 检查 CompanyJobsPage/index.jsx 数据传递');
|
|||
|
|
const pageContent = fs.readFileSync(
|
|||
|
|
path.join(__dirname, 'src/pages/CompanyJobsPage/index.jsx'),
|
|||
|
|
'utf-8'
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
const hasIsFromInterviewFlag = pageContent.includes('isFromInterview');
|
|||
|
|
console.log(` ${hasIsFromInterviewFlag ? '✅' : '❌'} 使用 isFromInterview 标识`);
|
|||
|
|
|
|||
|
|
const hasHideDeliverButtonProp = pageContent.includes('hideDeliverButton={isFromInterview}');
|
|||
|
|
console.log(` ${hasHideDeliverButtonProp ? '✅' : '❌'} 将 isFromInterview 传递给 hideDeliverButton`);
|
|||
|
|
|
|||
|
|
const hasDeliveredJobsFlag = pageContent.includes('isDelivered: true');
|
|||
|
|
console.log(` ${hasDeliveredJobsFlag ? '✅' : '❌'} 已投递岗位标记 isDelivered: true`);
|
|||
|
|
|
|||
|
|
console.log('\n' + '='.repeat(80));
|
|||
|
|
|
|||
|
|
const allChecksPassed =
|
|||
|
|
remainingPositionsMatch &&
|
|||
|
|
hasIsDeliveredCheck &&
|
|||
|
|
hasIsExpiredCheck &&
|
|||
|
|
hasStatusExpiredCheck &&
|
|||
|
|
hasHideDeliverButtonCheck &&
|
|||
|
|
hasRemainingPositionsCheck &&
|
|||
|
|
hasIsFromInterviewFlag &&
|
|||
|
|
hasHideDeliverButtonProp &&
|
|||
|
|
hasDeliveredJobsFlag;
|
|||
|
|
|
|||
|
|
if (allChecksPassed) {
|
|||
|
|
console.log('\n✅ 所有检查通过!岗位剩余招聘量隐藏逻辑已正确实现。\n');
|
|||
|
|
console.log('📝 功能说明:');
|
|||
|
|
console.log(' - ✅ 已投递岗位:不显示剩余招聘量');
|
|||
|
|
console.log(' - ✅ 已过期岗位:不显示剩余招聘量');
|
|||
|
|
console.log(' - ✅ 岗位面试状态中的岗位:不显示剩余招聘量');
|
|||
|
|
console.log(' - ✅ 只有未投递、未过期的普通岗位才显示剩余招聘量');
|
|||
|
|
} else {
|
|||
|
|
console.log('\n⚠️ 部分检查未通过,请检查上述标记为❌的项目。\n');
|
|||
|
|
}
|