feat: 更新 ESLint 和 Prettier 配置,增强代码质量管理

- 在 .gitignore 中添加 public/audio/* 以忽略音频文件。
- 更新 bun.lock,添加 eslint-config-prettier 和 eslint-plugin-prettier 依赖,确保 ESLint 与 Prettier 的兼容性。
- 修改 eslint.config.ts,整合 Prettier 规则,优化代码风格一致性。
- 在 package.json 中添加 lint:fix 和 format 脚本,简化代码格式化和修复流程。
- 更新 tailwind.config.ts 和其他组件文件,统一代码风格,提升可读性。
This commit is contained in:
zhongyidian committed 2026-03-05 13:50:47 +08:00
1 parent 5d00adc1a5
commit 76c67b492e
216 files changed
+12454 -13976

No files matched your search

@@ -1,6 +1,6 @@
import { useEffect, useState } from "react";
import { SingleChoice } from "@/components";
import type { SingleChoiceQuizPanelProps } from "./types";
import { useEffect, useState } from 'react'
import { SingleChoice } from '@/components'
import type { SingleChoiceQuizPanelProps } from './types'
/**
* 单选题面板组件
@@ -39,70 +39,61 @@ const SingleChoiceQuizPanel = ({
onError,
disabled = false,
}: SingleChoiceQuizPanelProps) => {
const [selectedValue, setSelectedValue] = useState<string>("");
const [error, setError] = useState<string>("");
const [selectedValue, setSelectedValue] = useState<string>('')
const [error, setError] = useState<string>('')
// 当窗口关闭时,重置内部状态
useEffect(() => {
if (!visible) {
setSelectedValue("");
setError("");
setSelectedValue('')
setError('')
}
}, [visible]);
}, [visible])
if (!visible) return null;
if (!visible) return null
// 处理选项点击
const handleOptionClick = (value: string) => {
if (disabled) return;
if (disabled) return
setSelectedValue(value);
setError("");
setSelectedValue(value)
setError('')
// 验证答案
const isCorrect =
correctAnswer !== undefined ? value === correctAnswer : undefined;
const isCorrect = correctAnswer !== undefined ? value === correctAnswer : undefined
// 如果提供了正确答案,进行验证
if (correctAnswer !== undefined) {
if (isCorrect) {
// 答题成功:清空状态,执行 onSubmit(外部控制关闭窗口)
setSelectedValue("");
setError("");
onSubmit?.(value, true);
setSelectedValue('')
setError('')
onSubmit?.(value, true)
} else {
// 答题失败:清空状态,执行 onError,允许重新选择
setSelectedValue("");
const customError = onWrongSelect?.(value);
const errorMsg =
customError || errorMessage || "很抱歉,你选错了!请你再思考一下吧!";
setError(errorMsg);
onError?.(errorMsg);
setSelectedValue('')
const customError = onWrongSelect?.(value)
const errorMsg = customError || errorMessage || '很抱歉,你选错了!请你再思考一下吧!'
setError(errorMsg)
onError?.(errorMsg)
}
} else {
// 没有提供正确答案,直接提交
setSelectedValue("");
setError("");
onSubmit?.(value, true);
setSelectedValue('')
setError('')
onSubmit?.(value, true)
}
};
}
return (
<div
className="fixed inset-0 flex items-center justify-center bg-black/40"
style={{ zIndex }}
>
<div className="fixed inset-0 flex items-center justify-center bg-black/40" style={{ zIndex }}>
<div className="relative w-[1728px] h-[972px] flex flex-col items-center justify-center">
{/* 题干卡片 */}
<div className="w-[1700px] rounded-[32px] bg-black px-20 py-8 shadow-[0_20px_60px_rgba(240,190,117,0.8)] border-4 border-[#d4c5a9]">
<div className="text-[34px] leading-relaxed text-white">{title}</div>
{/* 答案反馈 */}
{error && (
<div className="mt-5 text-center text-[26px] text-[#fcbe53]">
{error}
</div>
)}
{error && <div className="mt-5 text-center text-[26px] text-[#fcbe53]">{error}</div>}
</div>
{/* 选项区域 */}
@@ -119,13 +110,11 @@ const SingleChoiceQuizPanel = ({
>
<div
className={`w-[1500px] flex items-center p-4 text-[28px] leading-relaxed rounded-tr-[50px] rounded-bl-4xl transition-all duration-150 ${
disabled
? "opacity-60 cursor-not-allowed"
: "cursor-pointer"
disabled ? 'opacity-60 cursor-not-allowed' : 'cursor-pointer'
} ${
isSelected
? "bg-[#d4a574] text-[#5c3e2e]"
: "bg-[#d7b888] text-[#5c3e2e] hover:bg-gradient-to-r from-[#ddf3e1] to-[#fbdd97]"
? 'bg-[#d4a574] text-[#5c3e2e]'
: 'bg-[#d7b888] text-[#5c3e2e] hover:bg-gradient-to-r from-[#ddf3e1] to-[#fbdd97]'
}`}
>
{option.label}
@@ -136,7 +125,7 @@ const SingleChoiceQuizPanel = ({
</div>
</div>
</div>
);
};
)
}
export default SingleChoiceQuizPanel;
export default SingleChoiceQuizPanel