From 5783e205048693605cfa94e96be5925ea4c5dff0 Mon Sep 17 00:00:00 2001 From: Zylan Date: Thu, 3 Apr 2025 01:53:01 +0800 Subject: [PATCH] return --- components/LanguageContext.tsx | 93 +----- components/calculator.tsx | 594 +++++++++++++-------------------- 2 files changed, 233 insertions(+), 454 deletions(-) diff --git a/components/LanguageContext.tsx b/components/LanguageContext.tsx index 6db56ea..73812d9 100644 --- a/components/LanguageContext.tsx +++ b/components/LanguageContext.tsx @@ -573,13 +573,13 @@ const translations: Record> = { zh: { // 标题和导航 'title': '这b班上得值不值·测算版', - 'app_description': '计算薪资之外的工作真实价值', + 'github': 'GitHub', 'email': 'Email', 'xiaohongshu': '小红书', 'redirect_notice': '已自动跳转,新网址无需科学上网', 'visits': '访问量', 'visitors': '访客数', - 'star_request': '到GitHub给个⭐', + 'star_request': '如果觉得好用,请给项目点个⭐Star吧!', 'history': '历史记录', 'no_history': '暂无历史记录', 'history_notice': '查看报告后将自动保存', @@ -807,44 +807,17 @@ const translations: Record> = { 'rating_excellent': '爽到爆炸', 'rating_perfect': '人生巅峰', 'share_country': '工作国家/地区', - - // 添加步骤式表单相关翻译 - 'step_basic_info': '基本信息', - 'step_education_work': '学历与工作', - 'step_environment': '工作环境', - 'step_extras': '额外福利', - 'basic_info': '基本薪资与工作时间', - 'work_time_schedule': '工作排班', - 'daily_schedule': '日常时间分配', - 'education_and_experience': '学历与工作经验', - 'work_environment_factors': '工作环境因素', - 'environment_location': '环境与位置', - 'relationships': '人际关系', - 'additional_benefits': '额外福利项目', - 'job_type': '工作类型', - 'previous': '上一步', - 'next': '下一步', - - // 添加表单完成度相关翻译 - 'completed': '已完成', - 'steps': '步骤', - 'continue_filling': '继续完成以下步骤可获得更准确的评估结果', - 'preliminary_result': '初步结果 - 完成所有步骤获得更准确的评估', - - // 添加新的提示信息翻译 - 'complete_steps_to_view': '完成所有步骤后可查看工作性价比报告', - 'please_enter_salary': '请输入年薪以生成报告', }, en: { // Title and navigation 'title': 'Is My Job Worth the Grind?', - 'app_description': 'Calculating the actual value of your job beyond just salary', + 'github': 'GitHub', 'email': 'Email', 'xiaohongshu': 'Rednote', 'redirect_notice': 'Automatically redirected, no VPN needed', 'visits': 'Visits', 'visitors': 'Visitors', - 'star_request': 'Star on GitHub', + 'star_request': 'If you find this tool helpful, please give it a ⭐Star!', 'history': 'History', 'no_history': 'No history records', 'history_notice': 'Records will be saved after viewing reports', @@ -1072,44 +1045,17 @@ const translations: Record> = { 'rating_excellent': 'Excellent', 'rating_perfect': 'Outstanding', 'share_country': 'Work Country/Region', - - // 添加步骤式表单相关翻译 - 'step_basic_info': 'Basic Info', - 'step_education_work': 'Education', - 'step_environment': 'Environment', - 'step_extras': 'Benefits', - 'basic_info': 'Basic Salary & Schedule', - 'work_time_schedule': 'Work Schedule', - 'daily_schedule': 'Daily Time Allocation', - 'education_and_experience': 'Education & Experience', - 'work_environment_factors': 'Work Environment', - 'environment_location': 'Environment & Location', - 'relationships': 'Relationships', - 'additional_benefits': 'Additional Benefits', - 'job_type': 'Job Type', - 'previous': 'Previous', - 'next': 'Next', - - // 添加表单完成度相关翻译 - 'completed': 'completed', - 'steps': 'steps', - 'continue_filling': 'Continue with the next steps for a more accurate assessment', - 'preliminary_result': 'Preliminary result - Complete all steps for better accuracy', - - // 添加新的提示信息翻译 - 'complete_steps_to_view': 'Complete all steps to view your job value report', - 'please_enter_salary': 'Please enter your salary to generate the report', }, ja: { // タイトルとナビゲーション 'title': 'この仕事、割に合ってる?', - 'app_description': '給料だけでなく、仕事の本当の価値を計算する', + 'github': 'GitHub', 'email': 'Email', 'xiaohongshu': '小紅書', 'redirect_notice': '自動的にリダイレクトされました', 'visits': 'アクセス数', 'visitors': '訪問者数', - 'star_request': 'GitHubで⭐する', + 'star_request': '役に立ったら、⭐スターを付けてください!', 'history': '履歴', 'no_history': '履歴がありません', 'history_notice': 'レポートを見た後、自動的に保存されます', @@ -1337,33 +1283,6 @@ const translations: Record> = { 'rating_excellent': '非常に優れている', 'rating_perfect': '理想的', 'share_country': '勤務国・地域', - - // 添加步骤式表单相关翻译 - 'step_basic_info': '基本情報', - 'step_education_work': '学歴・経験', - 'step_environment': '職場環境', - 'step_extras': '福利厚生', - 'basic_info': '給与・勤務時間', - 'work_time_schedule': '勤務スケジュール', - 'daily_schedule': '日常の時間配分', - 'education_and_experience': '学歴と職歴', - 'work_environment_factors': '職場環境要素', - 'environment_location': '環境と勤務地', - 'relationships': '人間関係', - 'additional_benefits': '追加の福利厚生', - 'job_type': '雇用形態', - 'previous': '前へ', - 'next': '次へ', - - // 添加表单完成度相关翻译 - 'completed': '完了', - 'steps': 'ステップ', - 'continue_filling': 'より正確な評価のために次のステップを続けてください', - 'preliminary_result': '暫定結果 - すべてのステップを完了してより正確な評価を得る', - - // 添加新的提示信息翻译 - 'complete_steps_to_view': 'すべてのステップを完了して仕事の価値レポートを確認してください', - 'please_enter_salary': 'レポートを生成するには給与を入力してください', } }; diff --git a/components/calculator.tsx b/components/calculator.tsx index ef58c6e..2504dbf 100644 --- a/components/calculator.tsx +++ b/components/calculator.tsx @@ -467,30 +467,6 @@ const SalaryCalculator = () => { const [assessmentColor, setAssessmentColor] = useState("text-gray-500"); const [visitorVisible, setVisitorVisible] = useState(false); - // 添加步骤控制状态 - const [activeStep, setActiveStep] = useState(0); - - // 定义表单步骤 - const formSteps = [ - { title: t('step_basic_info'), icon: "💰" }, - { title: t('step_education_work'), icon: "🎓" }, - { title: t('step_environment'), icon: "🏢" }, - { title: t('step_extras'), icon: "✨" } - ]; - - // 步骤切换函数 - const nextStep = () => { - if (activeStep < formSteps.length - 1) { - setActiveStep(activeStep + 1); - } - }; - - const prevStep = () => { - if (activeStep > 0) { - setActiveStep(activeStep - 1); - } - }; - // 添加检查document对象存在的逻辑 useEffect(() => { // 确保在客户端环境中执行 @@ -979,22 +955,28 @@ const SalaryCalculator = () => {

{t('title')}

- {/* 添加应用描述文字 - 调整样式使其更加醒目 */} -

- {t('app_description')} -

+ - {/* 删除单独的star_request元素,直接将star_request作为GitHub链接文本 */} - {/* 修改表单为步骤式表单 */} -
- {/* 步骤指示器 */} -
-
- {formSteps.map((step, index) => ( - - ))} -
- - {/* 删除此处的完成度指示器 */} -
- - {/* 表单内容 */} +
- {/* 步骤1: 基础信息 */} - {activeStep === 0 && ( -
-

- {t('basic_info')} -

- + {/* 薪资与工作时间 section */} +
-
-

{t('work_time_schedule')}

-
+
{ onChange={(e) => handleInputChange('paidSickLeave', e.target.value)} className="mt-1 block w-full rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent text-gray-900 dark:text-white" /> -
-
-

{t('daily_schedule')}

-
- )} - - {/* 步骤2: 学历和工作经验 */} - {activeStep === 1 && ( -
-

- {t('education_and_experience')} -

- -
-
-
- -
-
- - -
-
- - -
-
- - {/* 硕士显示本科背景选项 */} - {formData.degreeType === 'masters' && ( -
- - -
- )} -
- {/* 工作年限选择 */} -
- +
+ + {/* 环境系数 */} +
+ {/* 学历和工作年限 */} +
+
+ +
+
+ +
+
+ +
+ + {/* 硕士显示本科背景选项 */} + {formData.degreeType === 'masters' && ( +
+ + +
+ )}
- -
-

{t('job_type')}

+ + {/* 工作年限选择 */} +
+ + +
+
+ + {/* 添加工作类型RadioGroup */} { onChange={handleInputChange} options={[ { label: t('job_government'), value: 'government' }, - { label: t('job_state'), value: 'state' }, - { label: t('job_foreign'), value: 'foreign' }, - { label: t('job_private'), value: 'private' }, - { label: t('job_dispatch'), value: 'dispatch' }, - { label: t('job_freelance'), value: 'freelance' }, - ]} - /> -
-
- )} - - {/* 步骤3: 工作环境 */} - {activeStep === 2 && ( -
-

- {t('work_environment_factors')} -

- -
-

{t('environment_location')}

-
+ { label: t('job_state'), value: 'state' }, + { label: t('job_foreign'), value: 'foreign' }, + { label: t('job_private'), value: 'private' }, + { label: t('job_dispatch'), value: 'dispatch' }, + { label: t('job_freelance'), value: 'freelance' }, + ]} + /> + { { label: t('is_hometown'), value: 'yes' }, ]} /> -
-
-
-

{t('relationships')}

-
{ { label: t('team_excellent'), value: '1.2' }, ]} /> -
+ + {/* 班车和食堂选项作为加分项,加上勾选框控制 */} +
+
+ handleInputChange('hasShuttle', e.target.checked)} + className="h-4 w-4 text-blue-600 rounded border-gray-300 focus:ring-blue-500" + /> +
-
- )} - - {/* 步骤4: 额外福利 */} - {activeStep === 3 && ( -
-

- {t('additional_benefits')} -

-
-
-
- handleInputChange('hasShuttle', e.target.checked)} - className="h-4 w-4 text-blue-600 rounded border-gray-300 focus:ring-blue-500" - /> - -
- - {formData.hasShuttle && ( -
- -
- )} -
- -
-
- handleInputChange('hasCanteen', e.target.checked)} - className="h-4 w-4 text-blue-600 rounded border-gray-300 focus:ring-blue-500" - /> - -
- - {formData.hasCanteen && ( -
- -
- )} -
-
+ {formData.hasShuttle && ( + + )}
- )} - - {/* 步骤导航按钮 */} -
- - - {activeStep < formSteps.length - 1 ? ( - - ) : ( -
/* 占位 */ - )} -
- {/* 将完成度指示器移动到这里 */} -
-
-
+
+
+ handleInputChange('hasCanteen', e.target.checked)} + className="h-4 w-4 text-blue-600 rounded border-gray-300 focus:ring-blue-500" + /> +
-
- {Math.min((activeStep + 1) * 25, 100)}% {t('completed')} - {activeStep + 1}/{formSteps.length} {t('steps')} + + {formData.hasCanteen && ( + + )}
- - {/* 删除提示信息 */}
- {/* 结果卡片 - 完全重新设计 */} -
-
- {/* 根据完成状态显示不同内容 */} - {activeStep < formSteps.length - 1 ? ( - /* 未完成全部步骤 - 显示鼓励提示 */ -
-
- {t('complete_steps_to_view')} -
-
- {Math.min((activeStep + 1) * 25, 100)}% {t('completed')} -
+ {/* 结果卡片优化 */} +
+
+
+
{t('working_days_per_year')}
+
{calculateWorkingDays()}{t('days_unit')}
+
+
+
{t('average_daily_salary')}
+
+ {getCurrencySymbol(selectedCountry)}{getDisplaySalary()}
- ) : ( - /* 已完成全部步骤 - 显示查看报告按钮 */ -
- {formData.salary ? ( - saveToHistory()} - > - - {t('view_report')} - - ) : ( -
- {t('please_enter_salary')} -
- )} +
+
+
{t('job_value')}
+
+ {value.toFixed(2)} + ({getValueAssessment().text})
- )} +
+
+ + {/* 修改分享按钮为链接到分享页面,并保存到历史 */} +
+ formData.salary ? saveToHistory() : null} + > + + {t('view_report')} +