dvc890 commited on
Commit
9700a4d
·
verified ·
1 Parent(s): 8a0d330

Upload 45 files

Browse files
pages/CourseList.tsx CHANGED
@@ -51,7 +51,8 @@ export const CourseList: React.FC = () => {
51
  setCourses(filteredCourses);
52
  setSubjects(s);
53
  setTeachers(t);
54
- setClasses(cls.sort(sortClasses));
 
55
  } catch (e) { console.error(e); } finally { setLoading(false); }
56
  };
57
 
 
51
  setCourses(filteredCourses);
52
  setSubjects(s);
53
  setTeachers(t);
54
+ // Safety check and sort
55
+ setClasses(Array.isArray(cls) ? cls.sort(sortClasses) : []);
56
  } catch (e) { console.error(e); } finally { setLoading(false); }
57
  };
58
 
pages/GameLucky.tsx CHANGED
@@ -347,7 +347,7 @@ export const GameLucky: React.FC<{className?: string}> = ({ className }) => {
347
  </div>
348
  </div>
349
 
350
- {/* Settings Modal (Same structure, just ensures saveLuckyConfig works) */}
351
  {isSettingsOpen && (
352
  <div className="fixed inset-0 bg-black/60 z-[1000] flex items-center justify-center p-4 backdrop-blur-sm">
353
  <div className="bg-white rounded-2xl w-full max-w-4xl h-[90vh] flex flex-col shadow-2xl animate-in zoom-in-95">
@@ -355,9 +355,9 @@ export const GameLucky: React.FC<{className?: string}> = ({ className }) => {
355
  <h3 className="text-xl font-bold text-gray-800">奖池配置 - {displayClassName}</h3>
356
  <button onClick={() => setIsSettingsOpen(false)}><X size={24} className="text-gray-400 hover:text-gray-600"/></button>
357
  </div>
358
- {/* ... (Keep existing settings UI) ... */}
359
  <div className="flex-1 overflow-y-auto p-6 bg-gray-50/50">
360
- <div className="grid grid-cols-1 md:grid-cols-3 gap-4 mb-6">
361
  <div className="bg-white p-4 rounded-xl border shadow-sm">
362
  <label className="text-xs font-bold text-gray-500 uppercase block mb-2">每日抽奖上限</label>
363
  <input type="number" className="w-full border rounded-lg px-3 py-2 font-bold text-lg text-center focus:ring-2 focus:ring-blue-500 outline-none" value={luckyConfig.dailyLimit} onChange={e => setLuckyConfig({...luckyConfig, dailyLimit: Number(e.target.value)})}/>
@@ -370,8 +370,14 @@ export const GameLucky: React.FC<{className?: string}> = ({ className }) => {
370
  <label className="text-xs font-bold text-gray-500 uppercase block mb-2">安慰奖文案</label>
371
  <input className="w-full border rounded-lg px-3 py-2 text-center focus:ring-2 focus:ring-blue-500 outline-none" value={luckyConfig.defaultPrize} onChange={e => setLuckyConfig({...luckyConfig, defaultPrize: e.target.value})}/>
372
  </div>
 
 
 
 
 
373
  </div>
374
- {/* ... (Rest of UI) ... */}
 
375
  <div className="bg-white rounded-xl border shadow-sm overflow-hidden">
376
  <table className="w-full text-sm text-left">
377
  <thead className="bg-gray-100 text-gray-500 uppercase text-xs">
 
347
  </div>
348
  </div>
349
 
350
+ {/* Settings Modal */}
351
  {isSettingsOpen && (
352
  <div className="fixed inset-0 bg-black/60 z-[1000] flex items-center justify-center p-4 backdrop-blur-sm">
353
  <div className="bg-white rounded-2xl w-full max-w-4xl h-[90vh] flex flex-col shadow-2xl animate-in zoom-in-95">
 
355
  <h3 className="text-xl font-bold text-gray-800">奖池配置 - {displayClassName}</h3>
356
  <button onClick={() => setIsSettingsOpen(false)}><X size={24} className="text-gray-400 hover:text-gray-600"/></button>
357
  </div>
358
+
359
  <div className="flex-1 overflow-y-auto p-6 bg-gray-50/50">
360
+ <div className="grid grid-cols-1 md:grid-cols-4 gap-4 mb-6">
361
  <div className="bg-white p-4 rounded-xl border shadow-sm">
362
  <label className="text-xs font-bold text-gray-500 uppercase block mb-2">每日抽奖上限</label>
363
  <input type="number" className="w-full border rounded-lg px-3 py-2 font-bold text-lg text-center focus:ring-2 focus:ring-blue-500 outline-none" value={luckyConfig.dailyLimit} onChange={e => setLuckyConfig({...luckyConfig, dailyLimit: Number(e.target.value)})}/>
 
370
  <label className="text-xs font-bold text-gray-500 uppercase block mb-2">安慰奖文案</label>
371
  <input className="w-full border rounded-lg px-3 py-2 text-center focus:ring-2 focus:ring-blue-500 outline-none" value={luckyConfig.defaultPrize} onChange={e => setLuckyConfig({...luckyConfig, defaultPrize: e.target.value})}/>
372
  </div>
373
+ <div className="bg-white p-4 rounded-xl border shadow-sm">
374
+ <label className="text-xs font-bold text-gray-500 uppercase block mb-2">安慰奖权重</label>
375
+ <input type="number" min={0} className="w-full border rounded-lg px-3 py-2 font-bold text-lg text-center focus:ring-2 focus:ring-blue-500 outline-none" value={luckyConfig.consolationWeight || 0} onChange={e => setLuckyConfig({...luckyConfig, consolationWeight: Number(e.target.value)})}/>
376
+ <p className="text-[10px] text-gray-400 mt-1 text-center">数值越大越难中奖</p>
377
+ </div>
378
  </div>
379
+
380
+ {/* Prizes List */}
381
  <div className="bg-white rounded-xl border shadow-sm overflow-hidden">
382
  <table className="w-full text-sm text-left">
383
  <thead className="bg-gray-100 text-gray-500 uppercase text-xs">
pages/GameMonster.tsx CHANGED
@@ -95,7 +95,7 @@ export const GameMonster: React.FC<{className?: string}> = ({ className }) => {
95
  stopAudio();
96
  if(reqRef.current) cancelAnimationFrame(reqRef.current);
97
  };
98
- }, []);
99
 
100
  const loadData = async () => {
101
  if (!homeroomClass) return;
 
95
  stopAudio();
96
  if(reqRef.current) cancelAnimationFrame(reqRef.current);
97
  };
98
+ }, [homeroomClass]); // Updated dependency
99
 
100
  const loadData = async () => {
101
  if (!homeroomClass) return;
pages/GameRandom.tsx CHANGED
@@ -44,7 +44,7 @@ export const GameRandom: React.FC<{className?: string}> = ({ className }) => {
44
  useEffect(() => {
45
  loadData();
46
  return () => stopAnimation();
47
- }, []);
48
 
49
  // Clear picked IDs when mode changes to avoid ID confusion
50
  useEffect(() => {
 
44
  useEffect(() => {
45
  loadData();
46
  return () => stopAnimation();
47
+ }, [homeroomClass]); // Updated dependency
48
 
49
  // Clear picked IDs when mode changes to avoid ID confusion
50
  useEffect(() => {
pages/GameZen.tsx CHANGED
@@ -64,7 +64,7 @@ export const GameZen: React.FC<{className?: string}> = ({ className }) => {
64
  stopAudio();
65
  if(reqRef.current) cancelAnimationFrame(reqRef.current);
66
  };
67
- }, []);
68
 
69
  const loadData = async () => {
70
  if (!homeroomClass) return;
 
64
  stopAudio();
65
  if(reqRef.current) cancelAnimationFrame(reqRef.current);
66
  };
67
+ }, [homeroomClass]); // Updated dependency
68
 
69
  const loadData = async () => {
70
  if (!homeroomClass) return;