修复了课表周数硬编码
This commit is contained in:
@@ -30,6 +30,7 @@ import {
|
||||
TimeSlot,
|
||||
getCourseColor,
|
||||
hasCourseInWeek,
|
||||
getCurrentWeek,
|
||||
} from '../../types/schedule';
|
||||
import type { ScheduleStackParamList } from '../../navigation/types';
|
||||
import { scheduleService } from '../../services/scheduleService';
|
||||
@@ -130,9 +131,17 @@ const getWeekDates = (weekOffset: number = 0) => {
|
||||
return getWeekInfo(weekOffset).dates;
|
||||
};
|
||||
|
||||
// 学期起始日期字符串(用于 getCurrentWeek 函数)
|
||||
const SEMESTER_START_DATE = '2026-03-09';
|
||||
|
||||
// 计算当前实际周数
|
||||
const getInitialWeek = (): number => {
|
||||
return getCurrentWeek(SEMESTER_START_DATE, TOTAL_WEEKS);
|
||||
};
|
||||
|
||||
export const ScheduleScreen: React.FC = () => {
|
||||
const navigation = useNavigation<NativeStackNavigationProp<ScheduleStackParamList>>();
|
||||
const [currentWeek, setCurrentWeek] = useState(1);
|
||||
const [currentWeek, setCurrentWeek] = useState(getInitialWeek);
|
||||
const [courses, setCourses] = useState<Course[]>([]);
|
||||
const [isAddModalVisible, setIsAddModalVisible] = useState(false);
|
||||
const [pendingDay, setPendingDay] = useState<number>(0);
|
||||
@@ -163,8 +172,10 @@ export const ScheduleScreen: React.FC = () => {
|
||||
};
|
||||
}, []);
|
||||
const todayColumnIndex = getTodayColumnIndex();
|
||||
// currentWeek === 1 对应今天所在的真实周(offset 0),其他周不高亮今日列
|
||||
const isViewingCurrentWeek = currentWeek === 1;
|
||||
// 获取当前实际周数,用于判断是否在查看当前周
|
||||
const actualCurrentWeek = getInitialWeek();
|
||||
// 只有在查看当前实际周时才高亮今日列
|
||||
const isViewingCurrentWeek = currentWeek === actualCurrentWeek;
|
||||
const activeTodayColumn = isViewingCurrentWeek ? todayColumnIndex : -1;
|
||||
|
||||
const dayColumnWidth = getDayColumnWidth();
|
||||
|
||||
Reference in New Issue
Block a user