feat: add originalSubject and originalTeacher

This commit is contained in:
Starcea 2024-07-14 20:36:01 +09:00
commit a1e506b7b2
No known key found for this signature in database
GPG key ID: B7A77E32374911E1
3 changed files with 31 additions and 7 deletions

View file

@ -2,7 +2,7 @@ import axios from 'axios'
import { BASE_URL, USER_AGENT } from './constants'
import DataManager from './data'
import School from './models/School'
import type Timetable from './models/Timetable'
import type { Timetable } from './models/Timetable'
import { encodeBase64, encodeEUCKR } from './utils/encode'
import { parseResponse } from './utils/parse'
@ -64,13 +64,26 @@ export default class Comcigan {
cls.slice(1).map((day, dIdx) =>
day.slice(1).map((period, pIdx) => {
const p = period.toString()
const changed =
period !== original[gIdx + 1][cIdx + 1][dIdx + 1][pIdx + 1]
return {
subject: subjects[Number(p.slice(0, p.length - teachersLen - 1))],
teacher: teachers[Number(p.slice(-teachersLen))],
changed:
period !== original[gIdx + 1][cIdx + 1][dIdx + 1][pIdx + 1],
}
changed,
...(changed
? {
originalSubject:
subjects[
original[gIdx + 1][cIdx + 1][dIdx + 1][pIdx + 1]
],
originalTeacher:
teachers[
original[gIdx + 1][cIdx + 1][dIdx + 1][pIdx + 1]
],
}
: {}),
} as Timetable
}),
),
),