Explorar el Código

Merge pull request #637 from XingHeYuZhuan/pending

星河欲转 hace 2 semanas
padre
commit
019a1340d7
Se han modificado 4 ficheros con 560 adiciones y 16 borrados
  1. 5 0
      index/root_index.yaml
  2. 8 0
      resources/CQEPC/adapters.yaml
  3. 469 0
      resources/CQEPC/cqepc.js
  4. 78 16
      resources/WUST/wust.js

+ 5 - 0
index/root_index.yaml

@@ -957,3 +957,8 @@ schools:
     name: "河南理工大学"
     initial: "H"
     resource_folder: "HPU"
+
+  - id: "CQEPC"
+    name: "重庆航天职业技术学院"
+    initial: "C"
+    resource_folder: "CQEPC"

+ 8 - 0
resources/CQEPC/adapters.yaml

@@ -0,0 +1,8 @@
+adapters:
+  - adapter_id: "CQEPC_01"
+    adapter_name: "重庆航天职业技术学院教务"
+    category: "BACHELOR_AND_ASSOCIATE"
+    asset_js_path: "cqepc.js"
+    import_url: "http://jw.cqepc.cn/"
+    maintainer: "yang01"
+    description: "重庆航天职业技术学院教务,请登录"

+ 469 - 0
resources/CQEPC/cqepc.js

@@ -0,0 +1,469 @@
+// 重庆航天职业技术学院(cqepc.cn) 拾光课程表适配脚本
+// 基于正方教务系统接口适配 (API 方案)
+
+/**
+ * 节次与周次合并去重函数
+ */
+function mergeAndDistinctCourses(courses) {
+    if (!Array.isArray(courses) || courses.length <= 1) return courses;
+
+    const list = courses.map(c => ({
+        ...c,
+        name: c.name || '',
+        teacher: c.teacher || '',
+        position: c.position || '',
+        weeks: Array.isArray(c.weeks) ? [...c.weeks].sort((a, b) => a - b) : []
+    }));
+
+    list.sort((a, b) => {
+        return a.name.localeCompare(b.name) ||
+               a.teacher.localeCompare(b.teacher) ||
+               a.position.localeCompare(b.position) ||
+               (a.day || 0) - (b.day || 0) ||
+               a.weeks.join(',').localeCompare(b.weeks.join(',')) ||
+               (a.startSection || 0) - (b.startSection || 0);
+    });
+
+    const step1Merged = [];
+    let current = list[0];
+
+    for (let i = 1; i < list.length; i++) {
+        const next = list[i];
+        const isSameCourseAndWeeks =
+            current.name === next.name &&
+            current.teacher === next.teacher &&
+            current.position === next.position &&
+            current.day === next.day &&
+            current.weeks.join(',') === next.weeks.join(',');
+
+        const isContinuous = current.endSection + 1 === next.startSection;
+        const isDuplicate = current.startSection === next.startSection && current.endSection === next.endSection;
+
+        if (isSameCourseAndWeeks && isContinuous) {
+            current.endSection = next.endSection;
+        } else if (isSameCourseAndWeeks && isDuplicate) {
+            continue;
+        } else {
+            step1Merged.push(current);
+            current = next;
+        }
+    }
+    step1Merged.push(current);
+
+    step1Merged.sort((a, b) => {
+        return a.name.localeCompare(b.name) ||
+               a.teacher.localeCompare(b.teacher) ||
+               a.position.localeCompare(b.position) ||
+               (a.day || 0) - (b.day || 0) ||
+               (a.startSection || 0) - (b.startSection || 0) ||
+               (a.endSection || 0) - (b.endSection || 0);
+    });
+
+    const step2Merged = [];
+    let cur = step1Merged[0];
+
+    for (let i = 1; i < step1Merged.length; i++) {
+        const nxt = step1Merged[i];
+        const isSameCourseAndSection =
+            cur.name === nxt.name &&
+            cur.teacher === nxt.teacher &&
+            cur.position === nxt.position &&
+            cur.day === nxt.day &&
+            cur.startSection === nxt.startSection &&
+            cur.endSection === nxt.endSection;
+
+        if (isSameCourseAndSection) {
+            cur.weeks = Array.from(new Set([...cur.weeks, ...nxt.weeks])).sort((a, b) => a - b);
+        } else {
+            step2Merged.push(cur);
+            cur = nxt;
+        }
+    }
+    step2Merged.push(cur);
+
+    return step2Merged;
+}
+
+/**
+ * 解析周次字符串,处理单双周和周次范围
+ */
+function parseWeeks(weekStr) {
+    if (!weekStr) return [];
+
+    const weekSets = weekStr.split(',');
+    let weeks = [];
+
+    for (const set of weekSets) {
+        const trimmedSet = set.trim();
+        const rangeMatch = trimmedSet.match(/(\d+)-(\d+)周/);
+        const singleMatch = trimmedSet.match(/^(\d+)周/);
+
+        let start = 0;
+        let end = 0;
+        let processed = false;
+
+        if (rangeMatch) {
+            start = Number(rangeMatch[1]);
+            end = Number(rangeMatch[2]);
+            processed = true;
+        } else if (singleMatch) {
+            start = end = Number(singleMatch[1]);
+            processed = true;
+        }
+        
+        if (processed) {
+            const isSingle = trimmedSet.includes('(单)');
+            const isDouble = trimmedSet.includes('(双)');
+
+            for (let w = start; w <= end; w++) {
+                if (isSingle && w % 2 === 0) continue;
+                if (isDouble && w % 2 !== 0) continue;
+                weeks.push(w);
+            }
+        }
+    }
+
+    return [...new Set(weeks)].sort((a, b) => a - b);
+}
+
+/**
+ * 解析 API 返回的 JSON 数据
+ */
+function parseJsonData(jsonData) {
+    if (!jsonData || !Array.isArray(jsonData.kbList)) {
+        return [];
+    }
+
+    const rawCourseList = jsonData.kbList;
+    const initialCourseList = [];
+
+    for (const rawCourse of rawCourseList) {
+        if (!rawCourse.kcmc || !rawCourse.xm || !rawCourse.cdmc || 
+            !rawCourse.xqj || !rawCourse.jcs || !rawCourse.zcd) {
+            continue;
+        }
+
+        const weeksArray = parseWeeks(rawCourse.zcd);
+        if (weeksArray.length === 0) {
+            continue;
+        }
+        
+        const sectionParts = rawCourse.jcs.split('-');
+        const startSection = Number(sectionParts[0]);
+        const endSection = Number(sectionParts[sectionParts.length - 1]);
+        const day = Number(rawCourse.xqj);
+        
+        if (isNaN(day) || isNaN(startSection) || isNaN(endSection) || 
+            day < 1 || day > 7 || startSection > endSection) {
+            continue;
+        }
+
+        initialCourseList.push({
+            name: rawCourse.kcmc.trim(),
+            teacher: rawCourse.xm.trim(),
+            position: rawCourse.cdmc.trim(),
+            day: day,
+            startSection: startSection,
+            endSection: endSection,
+            weeks: weeksArray
+        });
+    }
+
+    return mergeAndDistinctCourses(initialCourseList);
+}
+
+async function promptUserToStart() {
+    return await window.shiguangBridgePromise.showAlert(
+        "教务系统课表导入",
+        "导入前请确保您已在浏览器中成功登录重庆航天职业技术学院教务系统",
+        "好的,开始导入"
+    );
+}
+
+/**
+ * 从教务系统获取学年学期选项
+ */
+async function fetchAcademicOptions() {
+    const url = "http://jw.cqepc.cn/jwglxt/kbcx/xskbcx_cxXskbcxIndex.html?gnmkdm=N2151";
+    
+    try {
+        const response = await fetch(url, {
+            method: "GET",
+            credentials: "include"
+        });
+
+        if (!response.ok) return null;
+
+        const htmlText = await response.text();
+        const parser = new DOMParser();
+        const doc = parser.parseFromString(htmlText, "text/html");
+
+        const allYearOptions = Array.from(doc.querySelectorAll("#xnm option"))
+            .filter(opt => opt.value !== "")
+            .map(opt => ({
+                value: opt.value,
+                text: opt.textContent.trim(),
+                selected: opt.selected
+            }));
+
+        const semesterOptions = Array.from(doc.querySelectorAll("#xqm option"))
+            .filter(opt => opt.value !== "")
+            .map(opt => ({
+                value: opt.value,
+                text: opt.textContent.trim(),
+                selected: opt.selected
+            }));
+
+        if (allYearOptions.length === 0 || semesterOptions.length === 0) {
+            return null;
+        }
+
+        const selectedIndex = allYearOptions.findIndex(opt => opt.selected);
+        
+        if (selectedIndex === -1) {
+            return {
+                yearOptions: allYearOptions.slice(0, 5),
+                semesterOptions,
+                defaultYearIndex: 0,
+                defaultSemesterIndex: semesterOptions.findIndex(opt => opt.selected) !== -1 
+                    ? semesterOptions.findIndex(opt => opt.selected) 
+                    : 0
+            };
+        }
+
+        const start = Math.max(0, selectedIndex - 2);
+        const end = Math.min(allYearOptions.length, selectedIndex + 3);
+        const yearOptions = allYearOptions.slice(start, end);
+        const newDefaultIndex = selectedIndex - start;
+        const defaultSemesterIndex = semesterOptions.findIndex(opt => opt.selected);
+
+        return {
+            yearOptions,
+            semesterOptions,
+            defaultYearIndex: newDefaultIndex,
+            defaultSemesterIndex: defaultSemesterIndex !== -1 ? defaultSemesterIndex : 0
+        };
+
+    } catch (e) {
+        return null;
+    }
+}
+
+/**
+ * 提示用户选择学年和学期
+ */
+async function selectAcademicYearAndSemester() {
+    const optionsData = await fetchAcademicOptions();
+
+    if (!optionsData) {
+        window.shiguangBridge.showToast("从教务系统读取学年学期失败,请确保登录状态。");
+        return null;
+    }
+
+    const { yearOptions, semesterOptions, defaultYearIndex, defaultSemesterIndex } = optionsData;
+
+    const yearTexts = yearOptions.map(item => item.text);
+    const yearIndex = await window.shiguangBridgePromise.showSingleSelection(
+        "选择学年",
+        JSON.stringify(yearTexts),
+        defaultYearIndex
+    );
+
+    if (yearIndex === null || yearIndex === -1) return null;
+    const selectedYearCode = yearOptions[yearIndex].value;
+
+    const semesterTexts = semesterOptions.map(item => item.text);
+    const semesterIndex = await window.shiguangBridgePromise.showSingleSelection(
+        "选择学期",
+        JSON.stringify(semesterTexts),
+        defaultSemesterIndex
+    );
+
+    if (semesterIndex === null || semesterIndex === -1) return null;
+    const selectedSemesterCode = semesterOptions[semesterIndex].value;
+
+    return {
+        academicYear: selectedYearCode,
+        semesterCode: selectedSemesterCode
+    };
+}
+
+/**
+ * 获取学期开学日期
+ */
+async function fetchSemesterStartDate(academicYear, semesterCode) {
+    const url = "http://jw.cqepc.cn/jwglxt/kbcx/xskbcxZccx_cxZcByXnxq.html?gnmkdm=N2154";
+    const requestBody = `xnm=${academicYear}&xqm=${semesterCode}`;
+
+    try {
+        const response = await fetch(url, {
+            method: "POST",
+            headers: {
+                "accept": "application/json, text/javascript, */*; q=0.01",
+                "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
+                "x-requested-with": "XMLHttpRequest"
+            },
+            body: requestBody,
+            credentials: "include"
+        });
+
+        if (response.ok) {
+            const json = await response.json();
+            if (Array.isArray(json) && json.length > 0) {
+                const firstWeekObj = json.find(item => String(item.zs) === "1" || String(item.zsmc) === "1") || json[0];
+                
+                if (firstWeekObj.rq) {
+                    const startDateStr = firstWeekObj.rq.split('/')[0];
+                    if (/^\d{4}-\d{2}-\d{2}$/.test(startDateStr)) {
+                        return startDateStr;
+                    }
+                }
+                if (firstWeekObj.zcrq) {
+                    const match = firstWeekObj.zcrq.match(/(\d{4}-\d{2}-\d{2})/);
+                    if (match) return match[1];
+                }
+                if (firstWeekObj.ksrq) {
+                    const match = firstWeekObj.ksrq.match(/(\d{4}-\d{2}-\d{2})/);
+                    if (match) return match[1];
+                }
+            }
+        }
+    } catch (e) {
+        // 获取失败不影响主流程
+    }
+    return null;
+}
+
+/**
+ * 请求和解析课程数据
+ */
+async function fetchAndParseCourses(academicYear, semesterCode) {
+    const requestBody = `xnm=${academicYear}&xqm=${semesterCode}&kzlx=ck&xsdm=&kclbdm=`;
+    const targetUrl = "http://jw.cqepc.cn/jwglxt/kbcx/xskbcx_cxXsgrkb.html?gnmkdm=N2151";
+
+    const [courseResponse, semesterStartDate] = await Promise.all([
+        fetch(targetUrl, {
+            method: "POST",
+            headers: {
+                "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8"
+            },
+            body: requestBody,
+            credentials: "include"
+        }),
+        fetchSemesterStartDate(academicYear, semesterCode)
+    ]);
+
+    try {
+        if (courseResponse.ok) {
+            const jsonText = await courseResponse.text();
+            const jsonData = JSON.parse(jsonText);
+            if (jsonData && jsonData.kbList) {
+                const parsedCourses = parseJsonData(jsonData);
+                if (parsedCourses.length > 0) {
+                    return {
+                        courses: parsedCourses,
+                        config: {
+                            semesterStartDate: semesterStartDate,
+                            semesterTotalWeeks: 20
+                        }
+                    };
+                }
+            }
+        }
+    } catch (e) {
+        // 请求失败
+    }
+
+    window.shiguangBridge.showToast("未能获取课表数据,请检查网络环境或登录状态。");
+    return null;
+}
+
+async function saveCourses(parsedCourses) {
+    try {
+        await window.shiguangBridgePromise.saveImportedCourses(JSON.stringify(parsedCourses));
+        return true;
+    } catch (error) {
+        window.shiguangBridge.showToast(`课程保存失败: ${error.message}`);
+        return false;
+    }
+}
+
+/**
+ * 重庆航天职业技术学院独家定制作息时间(包含 5、6 节午休占位)
+ */
+const TimeSlots = [
+    { number: 1, startTime: "09:00", endTime: "09:40" },
+    { number: 2, startTime: "09:50", endTime: "10:30" },
+    { number: 3, startTime: "10:50", endTime: "11:30" },
+    { number: 4, startTime: "11:40", endTime: "12:20" },
+    { number: 5, startTime: "13:00", endTime: "13:40" }, // 午休占位
+    { number: 6, startTime: "13:40", endTime: "13:50" }, // 午休占位
+    { number: 7, startTime: "14:00", endTime: "14:40" }, // 下午正课精准落在此处
+    { number: 8, startTime: "14:50", endTime: "15:30" },
+    { number: 9, startTime: "15:50", endTime: "16:30" },
+    { number: 10, startTime: "16:40", endTime: "17:20" },
+    { number: 11, startTime: "18:30", endTime: "19:10" },
+    { number: 12, startTime: "19:20", endTime: "20:00" },
+    { number: 13, startTime: "20:10", endTime: "20:50" },
+    { number: 14, startTime: "21:00", endTime: "21:40" }
+];
+
+async function importPresetTimeSlots(timeSlots) {
+    if (timeSlots.length === 0) {
+        window.shiguangBridge.showToast("警告:时间段为空,未导入时间段信息。");
+        return;
+    }
+
+    try {
+        await window.shiguangBridgePromise.savePresetTimeSlots(JSON.stringify(timeSlots));
+        window.shiguangBridge.showToast("预设时间段导入成功!");
+    } catch (error) {
+        window.shiguangBridge.showToast("导入时间段失败: " + error.message);
+    }
+}
+
+async function runImportFlow() {
+    const alertConfirmed = await promptUserToStart();
+    if (!alertConfirmed) {
+        window.shiguangBridge.showToast("用户取消了导入。");
+        return;
+    }
+
+    const selection = await selectAcademicYearAndSemester();
+    if (!selection) {
+        window.shiguangBridge.showToast("未选择学年学期,导入流程终止。");
+        return;
+    }
+
+    const { academicYear, semesterCode } = selection;
+
+    const result = await fetchAndParseCourses(academicYear, semesterCode);
+    if (result === null) {
+        return;
+    }
+
+    const { courses, config } = result;
+
+    const saveResult = await saveCourses(courses);
+    if (!saveResult) {
+        return;
+    }
+    
+    try {
+        await window.shiguangBridgePromise.saveCourseConfig(JSON.stringify(config));
+        let configMsg = "课表配置更新成功!";
+        if (config.semesterStartDate) {
+            configMsg += ` 开学日期:${config.semesterStartDate}`;
+        }
+        window.shiguangBridge.showToast(configMsg);
+    } catch (error) {
+        window.shiguangBridge.showToast(`课表配置保存失败: ${error.message}`);
+    }
+
+    await importPresetTimeSlots(TimeSlots);
+
+    window.shiguangBridge.showToast(`课程导入成功,共导入 ${courses.length} 门课程!`);
+    window.shiguangBridge.notifyTaskCompletion();
+}
+
+runImportFlow();

+ 78 - 16
resources/WUST/wust.js

@@ -3,17 +3,69 @@
 (function () {
 	"use strict";
 
+	// 教务系统课表接口地址。
 	var SCHEDULE_PATH = "/jsxsd/xskb/xskb_list.do";
+	// 黄家湖校区的默认节次时间。
+	var DEFAULT_TIME_SLOTS = [
+		{ number: 1, startTime: "08:20", endTime: "09:05" },
+		{ number: 2, startTime: "09:15", endTime: "10:00" },
+		{ number: 3, startTime: "10:20", endTime: "11:05" },
+		{ number: 4, startTime: "11:15", endTime: "12:00" },
+		{ number: 5, startTime: "14:00", endTime: "14:45" },
+		{ number: 6, startTime: "14:55", endTime: "15:40" },
+		{ number: 7, startTime: "16:00", endTime: "16:45" },
+		{ number: 8, startTime: "16:55", endTime: "17:40" },
+		{ number: 9, startTime: "18:40", endTime: "19:25" },
+		{ number: 10, startTime: "19:35", endTime: "20:20" },
+		{ number: 11, startTime: "20:40", endTime: "21:25" },
+		{ number: 12, startTime: "21:35", endTime: "22:20" }
+	];
+	// 校区选项,选择结果用于确定课程时间。
+	var CAMPUS_OPTIONS = ["黄家湖校区", "青山校区"];
+
+	// 根据校区生成对应的节次时间,青山校区上午前四节提前。
+	function getCampusTimeSlots(campusIndex) {
+		var timeSlots = DEFAULT_TIME_SLOTS.map(function (slot) {
+			return {
+				number: slot.number,
+				startTime: slot.startTime,
+				endTime: slot.endTime
+			};
+		});
+		if (campusIndex !== 1) return timeSlots;
+
+		return timeSlots.map(function (slot) {
+			var minutes = slot.number <= 2 ? 20 : (slot.number <= 4 ? 10 : 0);
+			if (minutes === 0) return slot;
+			return {
+				number: slot.number,
+				startTime: shiftTime(slot.startTime, -minutes),
+				endTime: shiftTime(slot.endTime, -minutes)
+			};
+		});
+	}
+
+	// 按指定分钟数调整 HH:mm 格式的时间。
+	function shiftTime(time, offsetMinutes) {
+		var parts = time.split(":").map(Number);
+		var totalMinutes = parts[0] * 60 + parts[1] + offsetMinutes;
+		var hours = Math.floor(totalMinutes / 60).toString().padStart(2, "0");
+		var minutes = (totalMinutes % 60).toString().padStart(2, "0");
+		return hours + ":" + minutes;
+	}
+	// 通过应用桥接 API 显示提示信息。
 	function toast(message) {
 		if (window.shiguangBridge && window.shiguangBridge.showToast) {
 			window.shiguangBridge.showToast(message);
 		}
 	}
 
+	// 清理教务页面文本中的空格和非断行空格。
 	function normalizeText(value) {
 		return (value || "").replace(/\u00a0/g, " ").replace(/\s+/g, " ").trim();
 	}
 
+	// 将周次文本解析为排序后的周次数组。
 	function parseWeeks(value) {
 		var text = normalizeText(value).replace(/\(周\)|周/g, "");
 		var weeks = new Set();
@@ -28,6 +80,7 @@
 		return Array.from(weeks).sort(function (a, b) { return a - b; });
 	}
 
+	// 将节次文本解析为连续的节次数组。
 	function parsePeriods(value) {
 		var match = normalizeText(value).match(/\[([^\]]+)\]/);
 		if (!match) return [];
@@ -40,6 +93,7 @@
 		return periods;
 	}
 
+	// 查找主页面或同源 iframe 中的课表文档。
 	function findScheduleDocument() {
 		if (document.querySelector("#kbtable")) return document;
 		return Array.from(document.querySelectorAll("iframe")).reduce(function (found, frame) {
@@ -53,6 +107,7 @@
 		}, null);
 	}
 
+	// 解析单个课程块,生成应用需要的课程对象。
 	function parseCourseBlock(block) {
 		var holder = document.createElement("div");
 		holder.innerHTML = block;
@@ -78,6 +133,7 @@
 		};
 	}
 
+	// 遍历课表单元格,解析课程并合并重复的课程记录。
 	function parseCourses(doc) {
 		var table = doc.querySelector("#kbtable");
 		if (!table) return [];
@@ -109,26 +165,27 @@
 		});
 	}
 
-	function parseTimeSlots(doc) {
-		var slots = new Map();
-		Array.from(doc.querySelectorAll("#kbtable tr")).forEach(function (row) {
-			var header = row.querySelector("th");
-			if (!header) return;
-			var match = normalizeText(header.textContent).match(/^(\d+).*?(\d{1,2}:\d{2})\s*[-~至]\s*(\d{1,2}:\d{2})/);
-			if (!match) return;
-			var number = parseInt(match[1], 10);
-			if (!slots.has(number)) {
-				slots.set(number, { number: number, startTime: match[2].padStart(5, "0"), endTime: match[3].padStart(5, "0") });
-			}
-		});
-		return Array.from(slots.values()).sort(function (a, b) { return a.number - b.number; });
+	// 使用 v2 桥接 API 让用户选择上课校区。
+	async function selectCampus() {
+		var selectedIndex = await window.shiguangBridgePromise.showSingleSelection(
+			"选择上课校区",
+			JSON.stringify(CAMPUS_OPTIONS),
+			0
+		);
+		if (selectedIndex === null || selectedIndex < 0 || selectedIndex >= CAMPUS_OPTIONS.length) {
+			toast("已取消导入");
+			return null;
+		}
+		return selectedIndex;
 	}
 
+	// 获取当前页面选择的学期编号。
 	function getSemesterId(doc) {
 		var select = doc.querySelector("#xnxq01id");
 		return select ? select.value : "";
 	}
 
+	// 请求指定学期的课表页面并解析为文档对象。
 	async function fetchScheduleDocument(semesterId) {
 		var body = "cj0701id=&zc=&demo=&xnxq01id=" + encodeURIComponent(semesterId) + "&sfFD=1&wkbkc=1";
 		var response = await fetch(SCHEDULE_PATH, {
@@ -141,6 +198,7 @@
 		return new DOMParser().parseFromString(await response.text(), "text/html");
 	}
 
+	// 保存课程配置、校区时间段和课程数据。
 	async function saveData(courses, timeSlots) {
 		var maxWeek = Math.max.apply(null, courses.map(function (course) {
 			return Math.max.apply(null, course.weeks);
@@ -151,17 +209,20 @@
 			defaultClassDuration: 45,
 			defaultBreakDuration: 5
 		};
-		if (window.shiguangBridgePromise.saveCourseConfig) {
+		if (window.shiguangBridgePromise && window.shiguangBridgePromise.saveCourseConfig) {
 			await window.shiguangBridgePromise.saveCourseConfig(JSON.stringify(config));
 		}
-		if (timeSlots.length > 0 && window.shiguangBridgePromise.savePresetTimeSlots) {
+		if (timeSlots.length > 0 && window.shiguangBridgePromise && window.shiguangBridgePromise.savePresetTimeSlots) {
 			await window.shiguangBridgePromise.savePresetTimeSlots(JSON.stringify(timeSlots));
 		}
 		return await window.shiguangBridgePromise.saveImportedCourses(JSON.stringify(courses));
 	}
 
+	// 编排校区选择、课表获取、解析和保存的完整导入流程。
 	async function runImport() {
 		try {
+			var campusIndex = await selectCampus();
+			if (campusIndex === null) return;
 			var currentDoc = findScheduleDocument() || document;
 			var semesterId = getSemesterId(currentDoc);
 			var scheduleDoc = currentDoc.querySelector("#kbtable") ? currentDoc : await fetchScheduleDocument(semesterId);
@@ -170,7 +231,7 @@
 				toast("未解析到课程,请确认已登录且课表页面已加载完成");
 				return;
 			}
-			var saved = await saveData(courses, parseTimeSlots(scheduleDoc));
+			var saved = await saveData(courses, getCampusTimeSlots(campusIndex));
 			if (!saved) {
 				toast("课程导入失败");
 				return;
@@ -183,6 +244,7 @@
 		}
 	}
 
+	// 检查桥接 API 可用后启动导入流程。
 	if (window.shiguangBridgePromise && window.shiguangBridgePromise.saveImportedCourses) {
 		runImport();
 	}