From 1b084d72f09412196c037add368a11fabfb4ef93 Mon Sep 17 00:00:00 2001 From: Zylan Date: Tue, 1 Apr 2025 15:28:19 +0800 Subject: [PATCH] debug --- components/ShareCard.tsx | 13 +++++++++---- components/calculator.tsx | 18 ++++++++---------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/components/ShareCard.tsx b/components/ShareCard.tsx index f464aa5..3b0fddc 100644 --- a/components/ShareCard.tsx +++ b/components/ShareCard.tsx @@ -3,6 +3,7 @@ import React, { useRef, useState, useEffect } from 'react'; import { ArrowLeft, Download } from 'lucide-react'; import Link from 'next/link'; +import Image from 'next/image'; import { useLanguage } from './LanguageContext'; import { countryNames } from './LanguageContext'; // 导入countryNames对象 @@ -826,19 +827,23 @@ const ShareCard: React.FC = (props) => {
- Job Worth Calculator
{t('share_custom_made')}
worthjob.zippland.com
-
diff --git a/components/calculator.tsx b/components/calculator.tsx index 3205187..459f6c4 100644 --- a/components/calculator.tsx +++ b/components/calculator.tsx @@ -468,10 +468,10 @@ const SalaryCalculator = () => { const savedHistory = localStorage.getItem('jobValueHistory'); if (savedHistory) { try { - const parsedHistory = JSON.parse(savedHistory) as any[]; + const parsedHistory = JSON.parse(savedHistory) as Partial[]; // 处理历史记录,为可能缺失的字段添加默认值 - const normalizedHistory = parsedHistory.map((item: any) => ({ + const normalizedHistory: HistoryItem[] = parsedHistory.map((item: Partial) => ({ id: item.id || Date.now().toString(), timestamp: item.timestamp || Date.now(), value: item.value || '0', @@ -719,7 +719,7 @@ const SalaryCalculator = () => { const value = calculateValue(); - const getValueAssessment = () => { + const getValueAssessment = useCallback(() => { if (!formData.salary) return { text: t('rating_enter_salary'), color: "text-gray-500" }; if (value < 0.6) return { text: t('rating_terrible'), color: "text-pink-800" }; if (value < 1.0) return { text: t('rating_poor'), color: "text-red-500" }; @@ -728,10 +728,10 @@ const SalaryCalculator = () => { if (value <= 3.2) return { text: t('rating_great'), color: "text-green-500" }; if (value <= 4.0) return { text: t('rating_excellent'), color: "text-purple-500" }; return { text: t('rating_perfect'), color: "text-yellow-400" }; - }; + }, [formData.salary, value, t]); // 获取评级的翻译键,用于分享链接 - const getValueAssessmentKey = () => { + const getValueAssessmentKey = useCallback(() => { if (!formData.salary) return 'rating_enter_salary'; if (value < 0.6) return 'rating_terrible'; if (value < 1.0) return 'rating_poor'; @@ -740,7 +740,7 @@ const SalaryCalculator = () => { if (value <= 3.2) return 'rating_great'; if (value <= 4.0) return 'rating_excellent'; return 'rating_perfect'; - }; + }, [formData.salary, value]); const RadioGroup = ({ label, name, value, onChange, options }: { label: string; @@ -954,7 +954,7 @@ const SalaryCalculator = () => {
-

v6.1.1

+

v6.2.1

{
- {formatDate(item.timestamp)} - {getCountryName(item.countryCode)} - {t(item.assessment)} + {formatDate(item.timestamp)}