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

+82 -83
View File
@@ -1,4 +1,4 @@
import { useState } from "react";
import { useState } from 'react'
import {
ExhibitOverlay,
Title,
@@ -7,89 +7,89 @@ import {
GuideSteps,
GuideStepsItem,
MultipleChoiceQuizPanel,
} from "@/components";
import { getBackgroundImage, getPublicPath, getStaticImage } from "@/lib/utils";
import { useNavigate, useParams } from "react-router-dom";
import { useChenyunStore } from "@/store/chenyunStore";
import { usePuzzleAnimation } from "@/contexts/PuzzleAnimationContext";
import { useCursorController } from "@/hooks/useCursorController";
import SuccessAlert from "@/components/layout/alert/success-alert";
import ScaledPortal from "@/components/layout/ScaledPortal";
} from '@/components'
import { getBackgroundImage, getPublicPath, getStaticImage } from '@/lib/utils'
import { useNavigate, useParams } from 'react-router-dom'
import { useChenyunStore, saveChenyunStore } from '@/store/chenyunStore'
import { usePuzzleAnimation } from '@/contexts/PuzzleAnimationContext'
import { useCursorController } from '@/hooks/useCursorController'
import SuccessAlert from '@/components/layout/alert/success-alert'
import ScaledPortal from '@/components/layout/ScaledPortal'
// starName 固定为 chenyun
const starName = "chenyun";
const starName = 'chenyun'
// 展品 ID 与资源路径映射
const exhibitSrcMap: Record<1 | 2, string> = {
1: "chenyun/place4/场景4展品1",
2: "chenyun/place4/场景4展品2",
};
1: 'chenyun/place4/场景4展品1',
2: 'chenyun/place4/场景4展品2',
}
const ChenyunPlace4 = () => {
const navigate = useNavigate();
const navigate = useNavigate()
const { moduleName } = useParams<{
moduleName: string;
}>();
moduleName: string
}>()
// 获取碎片动画触发方法
const { triggerPuzzleAnimation } = usePuzzleAnimation();
const { triggerPuzzleAnimation } = usePuzzleAnimation()
const [activeExhibitId, setActiveExhibitId] = useState<1 | 2 | null>(null);
const [activeExhibitId, setActiveExhibitId] = useState<1 | 2 | null>(null)
// 使用持久化的访问状态
const place = "place4";
const { markExhibitVisited, getVisitedExhibits } = useChenyunStore();
const place = 'place4'
const { markExhibitVisited, getVisitedExhibits } = useChenyunStore()
// 从 store 获取已访问的展品,转换为 Set 用于兼容现有代码
const visitedExhibits = getVisitedExhibits(place);
const visited = new Set(visitedExhibits);
const visitedExhibits = getVisitedExhibits(place)
const visited = new Set(visitedExhibits)
const { isEnabled } = useCursorController({
initialEnabled: [1],
dependencies: { 2: [1] },
visited,
});
})
// 展品1引导对话
const [guideVisible, setGuideVisible] = useState(false);
const [guideStep, setGuideStep] = useState(0);
const [guideVisible, setGuideVisible] = useState(false)
const [guideStep, setGuideStep] = useState(0)
// 展品2的引导对话
const [guideVisible2, setGuideVisible2] = useState(false);
const [guideStep2, setGuideStep2] = useState(0);
const [guideVisible2, setGuideVisible2] = useState(false)
const [guideStep2, setGuideStep2] = useState(0)
// 展品2关闭后的题目状态(多选)
const [quiz2Visible, setQuiz2Visible] = useState(false);
const [successAlert2Visible, setSuccessAlert2Visible] = useState(false);
const [quiz2Visible, setQuiz2Visible] = useState(false)
const [successAlert2Visible, setSuccessAlert2Visible] = useState(false)
const handleOpenExhibit = (index: 1 | 2) => {
if (index === 1) {
// 展品1:点击时同时打开展品和引导对话
setActiveExhibitId(1);
setGuideVisible(true);
setGuideStep(0);
setActiveExhibitId(1)
setGuideVisible(true)
setGuideStep(0)
} else {
// 展品2:点击时同时打开展品和引导对话
setActiveExhibitId(2);
setGuideVisible2(true);
setGuideStep2(0);
setActiveExhibitId(2)
setGuideVisible2(true)
setGuideStep2(0)
}
};
}
// 监听GuideSteps步骤变化,仅同步当前步骤
const handleGuideStepChange = (step: number) => {
setGuideStep(step);
};
setGuideStep(step)
}
const handleGuideStepChange2 = (step: number) => {
setGuideStep2(step);
};
setGuideStep2(step)
}
const progressCount = visited.size;
const total = 2;
const completed = progressCount >= total;
const progressCount = visited.size
const total = 2
const completed = progressCount >= total
const subtitle = completed
? "探索该阶段相关资料(已完成)"
: `探索该阶段相关资料(${progressCount}/${total})`;
? '探索该阶段相关资料(已完成)'
: `探索该阶段相关资料(${progressCount}/${total})`
const subtitleClassName = completed
? "text-[#fff998] [text-shadow:_0_8px_8px_rgba(0,0,0,0.35),_0_0_16px_rgba(0,0,0,0.25)]"
: undefined;
? 'text-[#fff998] [text-shadow:_0_8px_8px_rgba(0,0,0,0.35),_0_0_16px_rgba(0,0,0,0.25)]'
: undefined
return (
<div
className="w-full h-full bg-cover bg-center bg-no-repeat"
@@ -108,11 +108,11 @@ const ChenyunPlace4 = () => {
{/* 返回上一章 */}
<Image
className="absolute right-5 top-5"
src={getStaticImage("components/离开")}
src={getStaticImage('components/离开')}
button
onClick={() => {
if (moduleName && starName) {
navigate(`/${moduleName}/${starName}/place3`);
navigate(`/${moduleName}/${starName}/place3`)
}
}}
/>
@@ -136,10 +136,11 @@ const ChenyunPlace4 = () => {
{completed && (
<Image
className="absolute bottom-0 right-0"
src={getStaticImage("chenyun/place3/继续前进3")}
src={getStaticImage('chenyun/place3/继续前进3')}
button
onClick={() => {
navigate(`/${moduleName}/${starName}/place5`);
saveChenyunStore()
navigate(`/${moduleName}/${starName}/place5`)
}}
/>
)}
@@ -147,25 +148,25 @@ const ChenyunPlace4 = () => {
{/* 遮罩层 */}
<ExhibitOverlay
visible={activeExhibitId !== null}
src={activeExhibitId ? exhibitSrcMap[activeExhibitId] : ""}
src={activeExhibitId ? exhibitSrcMap[activeExhibitId] : ''}
onOpen={() => {
if (activeExhibitId === 1) {
triggerPuzzleAnimation(6);
triggerPuzzleAnimation(6)
}
}}
onClose={() => {
// 展品2:关闭后先进入答题,答对后再标记已读
if (activeExhibitId === 2) {
setActiveExhibitId(null);
setQuiz2Visible(true);
return;
setActiveExhibitId(null)
setQuiz2Visible(true)
return
}
// 其他展品:关闭即标记已读
if (activeExhibitId !== null) {
markExhibitVisited(place, activeExhibitId);
markExhibitVisited(place, activeExhibitId)
}
setActiveExhibitId(null);
setActiveExhibitId(null)
}}
/>
@@ -177,39 +178,37 @@ const ChenyunPlace4 = () => {
title="【多选】中央苏区时期,陈云开展经济工作的主要做法包括:"
options={[
{
value: "A",
label:
"A.从实际出发,实事求是地制定符合企业发展需求的劳动政策",
value: 'A',
label: 'A.从实际出发,实事求是地制定符合企业发展需求的劳动政策',
},
{
value: "B",
label:
"B.提议建立合作社,吸收失业工人并增强企业管理的民主性",
value: 'B',
label: 'B.提议建立合作社,吸收失业工人并增强企业管理的民主性',
},
{
value: "C",
label: "C.照搬“左”倾经济政策,严格推行统一的劳动标准",
value: 'C',
label: 'C.照搬“左”倾经济政策,严格推行统一的劳动标准',
},
{
value: "D",
label: "D.审查企业、作坊的实际承受能力,避免政策脱离实际",
value: 'D',
label: 'D.审查企业、作坊的实际承受能力,避免政策脱离实际',
},
]}
correctAnswer={["A", "B", "D"]}
correctAnswer={['A', 'B', 'D']}
minSelections={1}
maxSelections={4}
errorMessage={(selectedValues) => {
// 选了 C:给出截图中的专属提示
if (selectedValues.includes("C")) {
return "陈云反对“左”倾错误。请你再想想吧!";
if (selectedValues.includes('C')) {
return '陈云反对“左”倾错误。请你再想想吧!'
}
// 没选 C 但仍不正确:通常是“选不全”
return "你的选择还不够全面哦~请你再想想吧!";
return '你的选择还不够全面哦~请你再想想吧!'
}}
onSubmit={(_values, isCorrect) => {
if (isCorrect) {
setQuiz2Visible(false);
setSuccessAlert2Visible(true);
setQuiz2Visible(false)
setSuccessAlert2Visible(true)
}
}}
zIndex={10000}
@@ -218,8 +217,8 @@ const ChenyunPlace4 = () => {
<SuccessAlert
visible={successAlert2Visible}
onContinue={() => {
setSuccessAlert2Visible(false);
markExhibitVisited(place, 2);
setSuccessAlert2Visible(false)
markExhibitVisited(place, 2)
}}
/>
</>
@@ -237,13 +236,13 @@ const ChenyunPlace4 = () => {
>
<GuideStepsItem
speaker="student"
audioSrc={getPublicPath("audio/chenyun/mp3_chenyun_11.mp3")}
audioSrc={getPublicPath('audio/chenyun/mp3_chenyun_11.mp3')}
>
这组史料看起来陈云前往中央苏区了,他在中央苏区主要负责哪些工作呢?
</GuideStepsItem>
<GuideStepsItem
speaker="guide"
audioSrc={getPublicPath("audio/chenyun/mp3_chenyun_12.mp3")}
audioSrc={getPublicPath('audio/chenyun/mp3_chenyun_12.mp3')}
>
1932年3月,陈云担任中共临时中央政治局常委,兼任全国总工会党团书记。1933年1月,陈云离开上海前往中央苏区首府瑞金,继续参加中共中央和全国总工会的领导工作。
</GuideStepsItem>
@@ -267,13 +266,13 @@ const ChenyunPlace4 = () => {
>
<GuideStepsItem
speaker="student"
audioSrc={getPublicPath("audio/chenyun/mp3_chenyun_13.mp3")}
audioSrc={getPublicPath('audio/chenyun/mp3_chenyun_13.mp3')}
>
苏区的经济工作一定不简单,陈云是如何开展工作的呢?
</GuideStepsItem>
<GuideStepsItem
speaker="guide"
audioSrc={getPublicPath("audio/chenyun/mp3_chenyun_14.mp3")}
audioSrc={getPublicPath('audio/chenyun/mp3_chenyun_14.mp3')}
>
中央苏区时期的经济斗争,是陈云经济工作能力的“淬炼场”。陈云分析了“左”倾经济政策的表现、危害以及原因。
</GuideStepsItem>
@@ -285,7 +284,7 @@ const ChenyunPlace4 = () => {
</GuideStepsItem>
</GuideSteps>
</div>
);
};
)
}
export default ChenyunPlace4;
export default ChenyunPlace4