feat: 移除不再使用的配置文件和更新组件,提升代码整洁性
- 删除 .claude/settings.local.json 配置文件,清理不必要的代码。 - 更新多个组件以引入音频资源,增强用户互动体验。 - 调整引导对话文本,确保信息准确性和一致性。 - 更新图像资源,提升视觉内容的准确性和一致性。
This commit is contained in:
1 parent
cf64e7ec50
commit
8ba36a4a1a
132 files changed
+546
-454
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { useEffect, useState, useRef } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { AnimatePresence, motion } from "framer-motion";
|
||||
import { getStaticImage } from "@/lib/utils";
|
||||
import { Image, Select } from "@/components";
|
||||
@@ -30,9 +30,6 @@ const LetterToHuangyanpei = ({
|
||||
// 是否已提交:提交后隐藏编辑信件,展示只读信件
|
||||
const [submitted, setSubmitted] = useState(false);
|
||||
|
||||
// 用于跟踪是否已经自动填入过答案,避免重复填入
|
||||
const autoFilledRef = useRef(false);
|
||||
|
||||
// 填空类型定义:0=填空1(限填),1=填空2(任填),2=填空3(任填),3=填空4(限填)
|
||||
const BLANK_1_ANSWER = "手脑并用";
|
||||
const BLANK_4_ANSWER = "有业者乐业";
|
||||
@@ -40,6 +37,7 @@ const LetterToHuangyanpei = ({
|
||||
// 填空1的选项
|
||||
const BLANK_1_OPTIONS = [
|
||||
"手脑并用",
|
||||
"有业者乐业",
|
||||
// "知行合一",
|
||||
// "学以致用",
|
||||
// "理论实践"
|
||||
@@ -47,47 +45,13 @@ const LetterToHuangyanpei = ({
|
||||
|
||||
// 填空4的选项
|
||||
const BLANK_4_OPTIONS = [
|
||||
"手脑并用",
|
||||
"有业者乐业",
|
||||
// "有业者敬业",
|
||||
// "有业者精业",
|
||||
// "有业者成业",
|
||||
];
|
||||
|
||||
// 自动浮现答案:填空1、4空白时自动填入正确答案
|
||||
useEffect(() => {
|
||||
// 只在组件可见且未自动填入过时检查
|
||||
if (!visible) {
|
||||
autoFilledRef.current = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (autoFilledRef.current) return;
|
||||
|
||||
setBlankValues((prevValues) => {
|
||||
const nextValues = [...prevValues];
|
||||
let changed = false;
|
||||
|
||||
// 填空1(索引0):如果为空,自动填入正确答案
|
||||
if (!nextValues[0] || nextValues[0].trim() === "") {
|
||||
nextValues[0] = BLANK_1_ANSWER;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
// 填空4(索引3):如果为空,自动填入正确答案
|
||||
if (!nextValues[3] || nextValues[3].trim() === "") {
|
||||
nextValues[3] = BLANK_4_ANSWER;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (changed || nextValues.length > 0) {
|
||||
// 如果已经有值或已更改,标记为已处理,避免重复检查
|
||||
autoFilledRef.current = true;
|
||||
}
|
||||
|
||||
return nextValues;
|
||||
});
|
||||
}, [visible]);
|
||||
|
||||
// 校验输入:确保所有填空符合标准
|
||||
const validateBlanks = () => {
|
||||
// 计算占位总数,防止有些没被输入过而是 undefined
|
||||
@@ -137,7 +101,6 @@ const LetterToHuangyanpei = ({
|
||||
setSubmitted(false);
|
||||
setBlankValues([]);
|
||||
setBlankErrors([]);
|
||||
autoFilledRef.current = false; // 重置自动填入标记
|
||||
}
|
||||
}, [visible]);
|
||||
|
||||
|
||||
@@ -36,11 +36,13 @@ const LetterToLuxun = ({
|
||||
// 填空1的选项
|
||||
const BLANK_1_OPTIONS = [
|
||||
"首在立人",
|
||||
"批判求真",
|
||||
// 可以添加其他选项
|
||||
];
|
||||
|
||||
// 填空2的选项
|
||||
const BLANK_2_OPTIONS = [
|
||||
"首在立人",
|
||||
"批判求真",
|
||||
// 可以添加其他选项
|
||||
];
|
||||
@@ -262,7 +264,7 @@ const LetterToLuxun = ({
|
||||
// 任填:文本输入
|
||||
<input
|
||||
name={`blank-${currentIndex}`}
|
||||
className={`inline-block w-[100px] h-[36px] mx-2 align-middle bg-transparent border-b-2 border-dashed [font-size:26px_!important] text-center outline-none ${
|
||||
className={`inline-block w-[100px] h-[36px] mx-2 mb-2 align-middle bg-transparent border-b-2 border-dashed [font-size:26px_!important] text-center outline-none ${
|
||||
blankErrors[currentIndex]
|
||||
? "border-red-500"
|
||||
: "border-[#4e402e]"
|
||||
|
||||
@@ -39,7 +39,7 @@ const LetterToSunzhongshan = ({
|
||||
const BLANK_1_ANSWER = "天下为公";
|
||||
const BLANK_2_ANSWER = "与时俱进";
|
||||
// 最后一个空的正确答案
|
||||
const LAST_BLANK_ANSWER = "仍须努力";
|
||||
const LAST_BLANK_ANSWER = "仍需努力";
|
||||
|
||||
// 前三个空的选项(所有空都用这三个选项)
|
||||
const SELECT_OPTIONS = [
|
||||
@@ -48,7 +48,7 @@ const LetterToSunzhongshan = ({
|
||||
{ value: "与时俱进", label: "与时俱进" },
|
||||
];
|
||||
|
||||
// 校验输入:前三个空必须选择正确答案,最后一个空必须是"仍须努力",其他空不能为空且不超过 10 个字符
|
||||
// 校验输入:前三个空必须选择正确答案,最后一个空必须是"仍需努力",其他空不能为空且不超过 10 个字符
|
||||
const validateBlanks = () => {
|
||||
// 计算占位总数,防止有些没被输入过而是 undefined
|
||||
const placeholderCount = (letterContent.match(/____/g) || []).length;
|
||||
@@ -69,7 +69,7 @@ const LetterToSunzhongshan = ({
|
||||
hasError = true;
|
||||
}
|
||||
} else if (i === placeholderCount - 1) {
|
||||
// 最后一个空:必须是"仍须努力"
|
||||
// 最后一个空:必须是"仍需努力"
|
||||
if (!v || v !== LAST_BLANK_ANSWER) {
|
||||
nextValues[i] = "";
|
||||
nextErrors[i] = true;
|
||||
@@ -251,31 +251,31 @@ const LetterToSunzhongshan = ({
|
||||
}
|
||||
|
||||
// 立即验证选择是否正确
|
||||
let correctAnswer = "";
|
||||
if (currentIndex === 0) {
|
||||
correctAnswer = BLANK_0_ANSWER;
|
||||
} else if (currentIndex === 1) {
|
||||
correctAnswer = BLANK_1_ANSWER;
|
||||
} else if (currentIndex === 2) {
|
||||
correctAnswer = BLANK_2_ANSWER;
|
||||
}
|
||||
// let correctAnswer = "";
|
||||
// if (currentIndex === 0) {
|
||||
// correctAnswer = BLANK_0_ANSWER;
|
||||
// } else if (currentIndex === 1) {
|
||||
// correctAnswer = BLANK_1_ANSWER;
|
||||
// } else if (currentIndex === 2) {
|
||||
// correctAnswer = BLANK_2_ANSWER;
|
||||
// }
|
||||
|
||||
if (
|
||||
correctAnswer &&
|
||||
selectedValue !== correctAnswer
|
||||
) {
|
||||
// 选择错误,显示错误提示
|
||||
setErrorAlertText(
|
||||
"请选择正确答案"
|
||||
);
|
||||
setShowErrorAlert(true);
|
||||
// 清空选择
|
||||
next[currentIndex] = "";
|
||||
setBlankValues(next);
|
||||
const nextErrs = [...blankErrors];
|
||||
nextErrs[currentIndex] = true;
|
||||
setBlankErrors(nextErrs);
|
||||
}
|
||||
// if (
|
||||
// correctAnswer &&
|
||||
// selectedValue !== correctAnswer
|
||||
// ) {
|
||||
// // 选择错误,显示错误提示
|
||||
// setErrorAlertText(
|
||||
// "请选择正确答案"
|
||||
// );
|
||||
// setShowErrorAlert(true);
|
||||
// // 清空选择
|
||||
// next[currentIndex] = "";
|
||||
// setBlankValues(next);
|
||||
// const nextErrs = [...blankErrors];
|
||||
// nextErrs[currentIndex] = true;
|
||||
// setBlankErrors(nextErrs);
|
||||
// }
|
||||
}}
|
||||
placeholder="请选择"
|
||||
error={blankErrors[currentIndex]}
|
||||
@@ -286,7 +286,7 @@ const LetterToSunzhongshan = ({
|
||||
// 其他空:文本输入
|
||||
<input
|
||||
name={`blank-${currentIndex}`}
|
||||
className={`inline-block w-[110px] h-[36px] mx-2 mb-2 align-middle bg-transparent border-b-2 border-dashed [font-size:26px_!important] text-center outline-none ${
|
||||
className={`inline-block w-[110px] h-[36px] mx-2 bg-transparent border-b-2 border-dashed [font-size:26px_!important] text-center outline-none ${
|
||||
blankErrors[currentIndex]
|
||||
? "border-red-500"
|
||||
: "border-[#4e402e]"
|
||||
|
||||
Reference in new issue
Block a user