feat: 精確化星星顯示條件
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
650a19c998
commit
8d85366a45
|
|
@ -273,7 +273,7 @@ API回應格式:
|
||||||
- 語音資訊: IPA發音標記、音頻播放功能
|
- 語音資訊: IPA發音標記、音頻播放功能
|
||||||
- 學習輔助: 同義詞、例句、例句翻譯
|
- 學習輔助: 同義詞、例句、例句翻譯
|
||||||
- 個人化: CEFR等級、學習狀態
|
- 個人化: CEFR等級、學習狀態
|
||||||
- 使用頻率: 當詞彙為常用時,於詞彙框線內右上角顯示星星
|
- 使用頻率: 除了簡單詞彙「學習者的CEFR>詞彙CEFR」以外,當詞彙為常用時,於詞彙框線內右上角顯示星星
|
||||||
|
|
||||||
前端渲染邏輯:
|
前端渲染邏輯:
|
||||||
- 條件渲染: 檢查 isCommon 欄位存在且為 true 時顯示 ⭐
|
- 條件渲染: 檢查 isCommon 欄位存在且為 true 時顯示 ⭐
|
||||||
|
|
@ -302,7 +302,7 @@ API回應格式:
|
||||||
- 基礎定義: 慣用語、中英文解釋、發音
|
- 基礎定義: 慣用語、中英文解釋、發音
|
||||||
- 學習輔助: 同義表達、實用例句
|
- 學習輔助: 同義表達、實用例句
|
||||||
- 難度標記: CEFR等級
|
- 難度標記: CEFR等級
|
||||||
- 使用頻率: 當慣用語為常用時,於慣用語框線內右上角顯示星星
|
- 使用頻率: 除了簡單慣用語「學習者的CEFR>慣用語CEFR」以外,當慣用語為常用時,於慣用語框線內右上角顯示星星
|
||||||
|
|
||||||
前端渲染邏輯:
|
前端渲染邏輯:
|
||||||
- 條件渲染: 檢查 isCommon 欄位存在且為 true 時顯示 ⭐
|
- 條件渲染: 檢查 isCommon 欄位存在且為 true 時顯示 ⭐
|
||||||
|
|
|
||||||
|
|
@ -466,14 +466,22 @@ function GenerateContent() {
|
||||||
title={`${idiom.idiom}: ${idiom.translation}`}
|
title={`${idiom.idiom}: ${idiom.translation}`}
|
||||||
>
|
>
|
||||||
{idiom.idiom}
|
{idiom.idiom}
|
||||||
{idiom?.frequency === 'high' && (
|
{(() => {
|
||||||
<span
|
// 只有當慣用語為常用且不是簡單慣用語時才顯示星星
|
||||||
className="absolute -top-1 -right-1 text-xs pointer-events-none z-10"
|
// 簡單慣用語定義:學習者CEFR > 慣用語CEFR
|
||||||
style={{ fontSize: '8px', lineHeight: 1 }}
|
const isHighFrequency = idiom?.frequency === 'high'
|
||||||
>
|
const idiomCefr = idiom?.cefrLevel || 'A1'
|
||||||
⭐
|
const isNotSimpleIdiom = !compareCEFRLevels(userLevel, idiomCefr, '>')
|
||||||
</span>
|
|
||||||
)}
|
return isHighFrequency && isNotSimpleIdiom ? (
|
||||||
|
<span
|
||||||
|
className="absolute -top-1 -right-1 text-xs pointer-events-none z-10"
|
||||||
|
style={{ fontSize: '8px', lineHeight: 1 }}
|
||||||
|
>
|
||||||
|
⭐
|
||||||
|
</span>
|
||||||
|
) : null
|
||||||
|
})()}
|
||||||
</span>
|
</span>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -149,12 +149,19 @@ export function ClickableTextV2({
|
||||||
if (!wordAnalysis) return false
|
if (!wordAnalysis) return false
|
||||||
|
|
||||||
const frequency = getWordProperty(wordAnalysis, 'frequency')
|
const frequency = getWordProperty(wordAnalysis, 'frequency')
|
||||||
return frequency === 'high'
|
const wordCefr = getWordProperty(wordAnalysis, 'cefrLevel')
|
||||||
|
|
||||||
|
// 只有當詞彙為常用且不是簡單詞彙時才顯示星星
|
||||||
|
// 簡單詞彙定義:學習者CEFR > 詞彙CEFR
|
||||||
|
const isHighFrequency = frequency === 'high'
|
||||||
|
const isNotSimpleWord = !compareCEFRLevels(userLevel, wordCefr, '>')
|
||||||
|
|
||||||
|
return isHighFrequency && isNotSimpleWord
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn('Error checking word frequency for star display:', error)
|
console.warn('Error checking word frequency for star display:', error)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}, [findWordAnalysis, getWordProperty])
|
}, [findWordAnalysis, getWordProperty, userLevel])
|
||||||
|
|
||||||
const words = useMemo(() => text.split(/(\s+|[.,!?;:])/g), [text])
|
const words = useMemo(() => text.split(/(\s+|[.,!?;:])/g), [text])
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue